CLI Commands

cnspec run

Run an MQL query on the command line and display the results.

Run a single MQL query from the command line and display the results. This is useful for quick one-off checks, scripting, and piping query results into other tools. Use the -c flag to pass a query directly:

cnspec run local -c "mondoo.version"

You can also run queries against remote targets:

cnspec run ssh user@HOST -c "sshd.config.params"
cnspec run [flags]

Options

      --ast                     Parse the query and return the abstract syntax tree (AST)
  -c, --command string          MQL query to execute in the shell
      --exit-1-on-failure       Exit with error code 1 if one or more query results fail
  -h, --help                    help for run
      --info                    Parse the query and provide information about it
      --inventory-file string   Set the path to the inventory file
  -j, --json                    Run the query and return the object in a JSON structure
      --parse                   Parse the query and return the logical structure
      --platform-id string      Select a specific target asset by providing its platform ID
      --sudo                    Elevate privileges with sudo

Options inherited from parent commands

      --api-proxy string   Set the proxy for communications with Mondoo Platform API
      --auto-update        Enable automatic provider installation and update (default true)
      --config string      Set config file path (default $HOME/.config/mondoo/mondoo.yml)
      --log-level string   Set the log level: error, warn, info, debug, trace (default "info")
  -v, --verbose            Enable verbose output

SEE ALSO

On this page