Mondoo Docs
Built-in FunctionsArray

containsOnly

containsOnly

Check that all elements in an array are from an allowlist. Returns true if no other values appear.


Examples

Ensure only root and shadow groups own /etc/gshadow:

["/etc/gshadow"].where(file(_).exists) {
  file(_) {
    group.name.lines.containsOnly(["root","shadow"])
  }
}

Example output:

["/etc/gshadow"].where(file(_).exists) {
} } group.name.lines.containsOnly(["root","shadow"])
where: [
  0: {
    file: {
      [].containsOnly(): true
    }
  }
]

On this page