Query Findings and Vulnerabilities with the Mondoo API
List the vulnerabilities in a space, find the assets a CVE affects, and list the findings on one asset with the Mondoo GraphQL API.
These recipes read the security findings Mondoo has for your assets: vulnerabilities (CVEs), vendor advisories, and failed checks. Each one is a complete curl command. To run them, set MONDOO_API_TOKEN and install jq as described in Make your first request. If your organization is in the EU region, replace us.api.mondoo.com with eu.api.mondoo.com.
These queries return their results or an error object, so they use inline fragments (... on TypeName). To learn why, read Results that can be errors.
List the vulnerabilities in a space
Use this query to get every CVE that affects a space, with the riskiest first. Each result is one CVE, with the number of assets it affects. The findings list in the Mondoo App reads the same data.
QUERY='
query ListVulnerabilities($entityMrn: String!, $after: String) {
aggregateScores(
entityMrn: $entityMrn
first: 50
after: $after
filter: { scoreTypes: [VULNERABILITY], maxRiskScore: 99 }
orderBy: { field: RISK_VALUE, direction: DESC }
) {
... on AggregateScoresConnection {
totalCount
edges {
node {
findingMrn
title
rating
riskValue
assetCount
firstDetectedAt
}
}
pageInfo {
endCursor
hasNextPage
}
}
... on RequestError {
message
}
... on NotFoundError {
message
}
}
}'
VARIABLES='{"entityMrn": "//captain.api.mondoo.app/spaces/YOUR_SPACE_ID"}'
curl -s https://us.api.mondoo.com/query \
-H "Authorization: Bearer $MONDOO_API_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg query "$QUERY" --argjson variables "$VARIABLES" '{query: $query, variables: $variables}')" | jq- Scope: a space MRN, or an organization MRN to list the vulnerabilities across every space in the organization.
- Access: any role that can view the space, such as Viewer.
- Pagination: while
hasNextPageistrue, add"after": "END_CURSOR"to the variables, using the previous page'sendCursor.
findingMrn is the CVE's MRN, such as //vadvisor.api.mondoo.app/cves/CVE-2024-3094. Use it to find the affected assets, create an exception, or create a ticket. maxRiskScore: 99 keeps only the vulnerabilities that still present risk, as the findings list in the Mondoo App does.
To change what the query returns, edit the filter:
scoreTypes: [CHECK]lists checks instead of CVEs, andscoreTypes: [ADVISORY]lists vendor advisories. You can list several types at once.rating: [CRITICAL, HIGH]returns only findings with the ratings you list.queryTerms: ["CVE-2024"]returns only findings that match the terms.
Find the assets a vulnerability affects
Use this query to list every asset in a space that a specific CVE affects, for example to hand the list to the team that owns them. Get the CVE's MRN from the vulnerabilities list.
QUERY='
query AffectedAssets($scopeMrn: String!, $findingMrn: String!, $after: String) {
assetsForFinding(scopeMrn: $scopeMrn, findingMrn: $findingMrn, first: 50, after: $after) {
... on AffectedAssetsConnection {
totalCount
edges {
node {
asset {
mrn
name
}
rating
riskValue
}
}
pageInfo {
endCursor
hasNextPage
}
}
... on RequestError {
message
}
... on NotFoundError {
message
}
}
}'
VARIABLES='{
"scopeMrn": "//captain.api.mondoo.app/spaces/YOUR_SPACE_ID",
"findingMrn": "//vadvisor.api.mondoo.app/cves/CVE-2024-3094"
}'
curl -s https://us.api.mondoo.com/query \
-H "Authorization: Bearer $MONDOO_API_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg query "$QUERY" --argjson variables "$VARIABLES" '{query: $query, variables: $variables}')" | jq- Scope: a space MRN, or an organization MRN to search every space in the organization.
- Access: any role that can view the space, such as Viewer.
- Pagination: while
hasNextPageistrue, add"after": "END_CURSOR"to the variables, using the previous page'sendCursor.
riskValue and rating are the CVE's risk on that one asset, which can differ from asset to asset.
List the findings on one asset
Use this query to get the open vulnerabilities and failed checks on a single asset, for example to show them in your own dashboard or CMDB. Get the asset's MRN from the assets list.
QUERY='
query AssetFindings($scopeMrn: String!, $after: String) {
findings(
scopeMrn: $scopeMrn
first: 50
after: $after
filter: { types: [CVE, CHECK], state: OPEN }
orderBy: { field: RISK_VALUE, direction: DESC }
) {
... on FindingsConnection {
totalCount
edges {
node {
__typename
... on CveFinding {
mrn
id
title
rating
riskValue
firstDetectedAt
}
... on CheckFinding {
mrn
title
rating
riskValue
}
}
}
pageInfo {
endCursor
hasNextPage
}
}
... on RequestError {
message
}
... on NotFoundError {
message
}
}
}'
VARIABLES='{"scopeMrn": "//assets.api.mondoo.app/spaces/YOUR_SPACE_ID/assets/YOUR_ASSET_ID"}'
curl -s https://us.api.mondoo.com/query \
-H "Authorization: Bearer $MONDOO_API_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg query "$QUERY" --argjson variables "$VARIABLES" '{query: $query, variables: $variables}')" | jq- Scope: an asset MRN.
- Access: any role that can view the asset's space, such as Viewer.
- Pagination: while
hasNextPageistrue, add"after": "END_CURSOR"to the variables, using the previous page'sendCursor.
state: OPEN returns only open findings. Without a state, the query returns findings in every state, including checks that pass. To list only vulnerabilities, set types: [CVE]. To include vendor advisories, add ADVISORY and a matching ... on AdvisoryFinding fragment.
Next steps
- Create and Review Exceptions: set an exception on a finding you accept.
- Create Tickets: open a ticket for one or more findings.
Last updated on
Spaces and Assets
List the spaces in an organization, list and filter the assets in a space, read one asset's risk, and delete assets with the Mondoo GraphQL API.
Exceptions
Create exceptions for vulnerabilities and checks, list exceptions waiting for review, and approve or reject them with the Mondoo GraphQL API.