-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix: handle artifact rule evaluation differently #1030
Conversation
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.
You have some lint errors around headers as well (some ordering, one that you introduced a header that's shadowed by a method argument in one place).
|
internal/engine/executor.go
Outdated
}) | ||
// 1. Traverse each rule within this policy | ||
err = TraverseRules(relevant, func(rule *pb.Policy_Rule) error { | ||
// this is used to flag we found a matching artifact and also completed processing the rule |
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.
I realise this comment is not very useful without a concrete proposal, but what makes me uneasy about this approach is that we leak a lot of details about how artifacts are laid out in the DB into the evaluator code. Would it be possible to create a method on the EntityInfoWrapper that would return a slice of generic protobuf objects the executor could iterate on without having to call into the DB layer for artifacts?
I'll try to poke at the code more tomorrow, just leaving this comment here for now in hopes someone can articulate what I mean better..
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.
I think that's a pretty reasonable callout, though I don't have a concrete proposal at the moment, either.
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.
I tried doing something different which hopefully makes more sense. Combined all versioned artifacts to be part of an artifact and that made more of the things a bit clearer, but I still have to verify it properly since I tried it with a patched evaluator. I tried doing rego unsuccessfully for creating a new artifacts rule type since now we pass a list of metadata for each versioned artifact that passed our filtering so we want to iterate over it. Even though it's not working properly, I've added it to the PR so Ozz can share his feedback and once it's okay it will replace the existing one which uses jq.
2156710
to
a335ad9
Compare
I've moved the random package out of utils to a standalone as I had some import cycle errors. It's a fairly simple change, but I realise it might make the PR difficult to review. Let me know if you want to have that moved to a separate PR 👍 |
I rebased again. Added more artifact tests and did the same thing for jsonyaml in order to solve import cycle errors. Let me know if the helper function about collecting the artifact versions has a better place so I can move it there 👍 |
LGTM, I like how the reconciler looks way cleaner thanks to this. |
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
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.
LGTM!
Sorry I was so slow with reviews lately, I was trying to get some implementation of the remediations going. This is a really nice work though!
No longer applicable since the code changed since then. Nevertheless, if there's any feedback I'll address it in a separate PR.
The following PR proposes a change for how we process artifacts and their versions and also how we evaluate the rules in case of artifact entities.
Currently we evaluate a policy/rule in the same way for all entities. This happens on an entity event basis:
Artifacts can change over time, i.e. a signed image tagged with [latest, v1.0.0] can pass its policy, but then if we push another image tagged only with [latest] this policy should now be failing.
The proposed change includes two things:
Fixes #961
Fixes #967