Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce no variants defined inline in packs #4064

Open
preslavgerchev opened this issue May 23, 2024 · 0 comments
Open

Enforce no variants defined inline in packs #4064

preslavgerchev opened this issue May 23, 2024 · 0 comments

Comments

@preslavgerchev
Copy link
Contributor

Take the following sample pack:

packs:
  - uid: mondoo-incident-response-aws
    name: AWS Incident Response Pack (Test)
    queries:
      - uid: mondoo-incident-response-aws-iam-administrator-access
        title: IAM users, groups, and roles to which the AdministratorAccess policy is attached
        variants:
          - uid: mondoo-incident-response-aws-iam-administrator-access-all
          - uid: mondoo-incident-response-aws-iam-administrator-access-user
      - uid: mondoo-incident-response-aws-iam-administrator-access-all
        filters: |
          asset.platform == "aws"
        mql: |
          aws.iam.attachedPolicies.
            where( arn == "arn:aws:iam::aws:policy/AdministratorAccess" ) {
              attachedUsers
              attachedGroups
              attachedRoles
            }
      - uid: mondoo-incident-response-aws-iam-administrator-access-user
        filters: |
          asset.platform == "aws-iam-user"
          aws.iam.attachedPolicies
            .where(arn == "arn:aws:iam::aws:policy/AdministratorAccess")
            .any(attachedUsers
              .contains(
                arn.in(asset.ids)
              )
            )
        mql: |
          aws.iam.user {
            arn
            name
            policies
            id
            tags
            attachedPolicies
            createDate
            accessKeys
            loginProfile
            groups
          }

Structurally it looks fine and is compliant with the struct that we expose for query packs. However, we want to enforce that no variants are defined inline and those are only defined top-level (bundle level). We should adjust the bundle code to ensure that this pack above spits out a better error when being compiled. We should also adjust the linting/fmting to show this as an error when formatting policies/packs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant