-
Notifications
You must be signed in to change notification settings - Fork 119
feat(policy): Enable selectors for providers #1174
Conversation
7f17173
to
13d2187
Compare
@@ -614,3 +614,120 @@ spec: | |||
assert.Equal(t, 14, firstResult.Metadata().Range().GetEndLine()) | |||
assert.Equal(t, "k8s.yaml", firstResult.Metadata().Range().GetFilename()) | |||
} | |||
|
|||
// TODO(simar): Uncomment once all k8s policies have subtype selector added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I've left this in as "failing example" that should "pass" when we add selectors to all Kubernetes policies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @chen-keinan just a heads up.
bd4f422
to
9f7249a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks promising! will need to add relevant documentation (separate PR)
we should define (and test) the following cases:
- selector is not defined (IMO policy applies to all)
- selector is empty (IMO policy applies to none)
- selector is defined without subtype (IMO policy applies to all of type)
- selector is defined with empty subtype (IMO policy applies to none)
- selector is conflicting with service field (IMO we should remove service field)
- subtype is partially defined, for example only kind is defined on k8s check (should apply to matching types)
- subtype is mixing fields from different types, for example using service on k8s check (should consider just what's relevant)
how does this apply to other types besides k8s and cloud? (e.g Dockerfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make the cloud selector more specific. When we get to multi-cloud what will happen if subtype is IAM (AWS) or IAM (GCP). I believe currently it will try to evaluate policies for both clouds.
we can easily extend this to other types as well. at the moment, only cloud and kubernetes are supported. |
right, actually this gave me another idea which I think will help us eliminate some of the extra fields in the custom metadata in the future and instead make them common with the input selectors (specifically, I'm talking about provider and service custom metadata fields). I've implemented that in the next few commits. |
thanks for these, I've opened new issues to track them. https://github.com/aquasecurity/defsec/issues/1201 |
a0a5831
to
34b3319
Compare
sure we can add tests later but the reason I wrote those cases was to make sure the code (in this PR) works according to this desired (IMO) behavior. If that's the case, then great, if not we should fix it here |
not sure I see the change in the code, can you please explain what you mean by that? |
ac5bd89
to
fadb428
Compare
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
Addresses: https://github.com/aquasecurity/defsec/issues/1200 Signed-off-by: Simar <[email protected]>
Signed-off-by: Simar <[email protected]>
fadb428
to
c404766
Compare
In this commit I've implemented the support for providing provider as part of the selector logic 5edd823 - the idea is that these selectors are common for any provider (cloud, docker, k8s..) in the future we should be able to remove the "provider" and "service" fields that are only meant for cloud for now https://github.com/aquasecurity/defsec/blob/master/rules/cloud/policies/aws/rds/disable_public_access.rego#L11-L12 - This can be tracked in a separate issue. |
This PR adds support for subtype selectors for policies.
Addresses: aquasecurity/trivy#3441
Small example:
Cloud
Kubernetes
Signed-off-by: Simar [email protected]