Skip to content

cnspec policy lint not correctly setting line numbers #2005

Description

@tas50

Describe the bug
When a specific query is not compiling in a large policy we're setting the failure on the bundle instead of the query. It would be very helpful to narrow this down to the actual query so we can attribute it in GitHub and the user can more easily find it.

Example of output:

$cnspec policy lint content/mondoo-linux-security.mql.yaml
                                                         
→ lint policy bundle file=content/mondoo-linux-security.mql.yaml
 RULE ID               LEVEL  FILE                            LINE  MESSAGE
 bundle-compile-error  error  mondoo-linux-security.mql.yaml  1     Could not compile policy bundle: failed to validate query '//local.cnspec.io/run/local-execution/queries/mondoo-linux-security-session-initiation-information-is-collected': failed to compile query '["/var/run/utmp"].where(file(_).exists).all( props.mondooLinuxSecurityAuditFiles.any(_.contains(/^(\s+)?\-w\s+\/var\/run\/utmp\s+\-p\s+wa\s+\-k\s+session(\s+)?$/)) )
                                                                    ["/var/log/wtmp"].where(file(_).exists).all( props.mondooLinuxSecurityAuditFiles.any(_.contains(/^(\s+)?\-w\s+\/var\/log\/wtmp\s+\-p\s+wa\s+\-k\s+(logins|session)(\s+)?$/)) )
                                                                    ["/var/log/btmp"].where(file(_).exists).all( props.mondooLinuxSecurityAuditFiles.any(_.contains(/^(\s+)?\-w\s+\/var\/log\/btmp\s+\-p\s+wa\s+\-k\s+(logins|session)(\s+)?$/)) )
                                                                    ': cannot find '[]' function on type bool
FTL invalid policy bundle

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions