Skip to content

Conversation

preslavgerchev
Copy link
Contributor

@preslavgerchev preslavgerchev commented Jul 31, 2025

Following up on mondoohq/cnquery#5788

A query that would panic during execution because it has no datapoints/entrypoints is now reported when doing policy linting:

→ lint policy bundle file=test.yaml
  RULE ID                       LEVEL    FILE       LINE  MESSAGE                                                                                                                                                                                                                                  
  bundle-compile-error          error    test.yaml  1     Could not compile policy bundle: failed to validate query '//local.cnspec.io/run/local-execution/queries/check-1': failed to compile query '(asset.eol.date - time.now() > 90*time.day) && (asset.eol.date - time.now() < 180*time.day)  
                                                          ': failed to compile: received an empty code structure. this is a bug with the query compilation                                                                                                                                         
                                                                                                                                                                                                                                                                                                   
  policy-required-tags-missing  warning  test.yaml  2     policy 'test-uid' does not contain the required tag `mondoo.com/category`                                                                                                                                                                
  policy-required-tags-missing  warning  test.yaml  2     policy 'test-uid' does not contain the required tag `mondoo.com/platform`                                                                                                                                                                
FTL invalid policy bundle

To make this a lint-only feature for now, we use the provided feature flag for this to not break anything else

To test, here's a sample one:

policies:
  - uid: test-uid
    name: Test
    version: 1.0
    groups:
      - title: Check EOL
        filters: |
          asset.platform != ''
        checks:
          - uid: check-1
queries:
  - uid: check-1
    title: Check EOL
    impact: 100
    mql: |
      (asset.eol.date - time.now() > 90*time.day) && (asset.eol.date - time.now() < 180*time.day)

Signed-off-by: Preslav <preslav@mondoo.com>
Copy link
Contributor

github-actions bot commented Jul 31, 2025

Test Results

  1 files   28 suites   1m 18s ⏱️
518 tests 517 ✅ 1 💤 0 ❌
519 runs  518 ✅ 1 💤 0 ❌

Results for commit d717741.

♻️ This comment has been updated with latest results.

@preslavgerchev preslavgerchev merged commit cd2eb23 into main Jul 31, 2025
22 of 23 checks passed
@preslavgerchev preslavgerchev deleted the preslav/lint-ctx branch July 31, 2025 16:00
@github-actions github-actions bot locked and limited conversation to collaborators Jul 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants