-
Notifications
You must be signed in to change notification settings - Fork 546
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 handling of policy in verify-attestation #1672
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1672 +/- ##
==========================================
+ Coverage 28.08% 29.34% +1.26%
==========================================
Files 139 141 +2
Lines 8025 8372 +347
==========================================
+ Hits 2254 2457 +203
- Misses 5523 5646 +123
- Partials 248 269 +21
Continue to review full report at Codecov.
|
Previously, the code was comparing a predicate URI against a payload type. This is never expected to match. Modify the code to extract the actual predicate type from within the payload so the verification can be done successfully. Signed-off-by: Luiz Carvalho <[email protected]>
7969eaf
to
89219e2
Compare
This commit addresses multiple issues when applying a rego policy against the payload of an attestation. 1. If `data.signature.deny` evaluated to `true`, the policy verification would pass. This is obviously unexpected. The code now looks for `data.signature.allow` instead, and expects it to be `true`. 2. If a query result returned an undefined results, the policy verification would pass. The code now explicitly checks for this condition and ensure that if `ResultSet.IsAllowed()` returns `false`, the policy verification also fails. 3. Improve error messages to assist user in defining correct variable name and type. 4. Add unit tests to validate behavior and prevent breaking changes in the future. Signed-off-by: Luiz Carvalho <[email protected]>
89219e2
to
90009e9
Compare
Thanks @lcarva for doing this! I'm going to merge this so I can start adding the e2e tests in a followup. |
* Fix sanity checks during policy processing Previously, the code was comparing a predicate URI against a payload type. This is never expected to match. Modify the code to extract the actual predicate type from within the payload so the verification can be done successfully. Signed-off-by: Luiz Carvalho <[email protected]> * Fix rego policy verification This commit addresses multiple issues when applying a rego policy against the payload of an attestation. 1. If `data.signature.deny` evaluated to `true`, the policy verification would pass. This is obviously unexpected. The code now looks for `data.signature.allow` instead, and expects it to be `true`. 2. If a query result returned an undefined results, the policy verification would pass. The code now explicitly checks for this condition and ensure that if `ResultSet.IsAllowed()` returns `false`, the policy verification also fails. 3. Improve error messages to assist user in defining correct variable name and type. 4. Add unit tests to validate behavior and prevent breaking changes in the future. Signed-off-by: Luiz Carvalho <[email protected]>
Summary
The first commit fixes the sanity checks during policy processing. Previously, the code was comparing a predicate URI against a payload type. This is never expected to match.
The code was modifying to extract the actual predicate type from within the payload so the verification can be done successfully.
The second commit addresses multiple issues when applying a rego policy against the payload of an attestation:
data.signature.deny
evaluated totrue
, the policy verification would pass. This is obviously unexpected. The code now looks fordata.signature.allow
instead, and expects it to betrue
.condition and ensures that if
ResultSet.Allowed()
returnsfalse
the policy verification also fails.Release Note