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

feat(misconf): support of selectors for all providers for Rego #6905

Merged
merged 2 commits into from
Jun 17, 2024

Conversation

nikpivkin
Copy link
Contributor

@nikpivkin nikpivkin commented Jun 11, 2024

Description

This will allow specifying selectors for all providers.

Fixes #6911

For example:

# METADATA
# title: "Test"
# scope: package
# schemas:
# - input: schema["cloud"]
# custom:
#   id: TEST001
#   avd_id: TEST001
#   severity: LOW
#   input:
#     selector:
#     - type: cloud
#       subtypes:
#         - service: compute
#           provider: google

package user.test001

import rego.v1

deny contains res if {
    some instance in input.google.compute.instances
    instance.name.value == "my-instance"
    res := result.new("deny", instance.name)
}

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io>
@nikpivkin nikpivkin changed the title feat(misconf): support all providers for Rego feat(misconf): support of selectors for all providers for Rego Jun 11, 2024
@nikpivkin nikpivkin marked this pull request as ready for review June 11, 2024 12:29
@nikpivkin nikpivkin requested a review from simar7 as a code owner June 11, 2024 12:29
Comment on lines 35 to 41
func init() {
supportedProviders = make(map[string]struct{})
for _, p := range providers.AllProviders() {
supportedProviders[string(p)] = struct{}{}
}
supportedProviders["kind"] = struct{}{} // kubernetes
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Do we need this to be an init func? The abstraction into the providers package is nice but IMO not at the cost of keeping an init func. I usually try to avoid having init funcs as they can get a bit problematic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed: 9d2240a

@simar7 simar7 added this pull request to the merge queue Jun 17, 2024
Merged via the queue into aquasecurity:main with commit bc3741a Jun 17, 2024
12 checks passed
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

Successfully merging this pull request may close these issues.

feat(misconf): Add selector support for all providers
2 participants