feat: add unless conditions to disallowed_attributes rule data#1744
feat: add unless conditions to disallowed_attributes rule data#1744lcarva wants to merge 1 commit into
Conversation
|
Warning Review limit reached
More reviews will be available in 47 minutes and 27 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThis PR introduces conditional per-attribute exceptions to SBOM policy rules via an ChangesSBOM attribute conditional exclusion via unless patterns
🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🤖 Finished Review · ✅ Success · Started 5:29 PM UTC · Completed 5:38 PM UTC |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@policy/lib/sbom/sbom.rego`:
- Around line 478-482: The shared helper attribute_excluded currently runs
regex.match(condition.purl, purl) against the raw PURL text, which causes
mismatches between percent-encoded SPDX PURLs and unencoded CycloneDX PURLs;
modify attribute_excluded to canonicalize candidate PURLs before matching (e.g.,
percent-decode percent-encoded characters like %3A → :, normalize case/scheme if
needed) by introducing/using a normalize_purl step on the purl variable prior to
regex.match so the same unless.purl regex applies consistently across both SBOM
formats; update any references to purl within attribute_excluded (and reuse
normalize_purl if you add a helper) so all matches use the normalized value.
- Around line 265-268: The schema for unless[].purl currently allows any string
but purl is later used as a regular expression; update the schema entry for purl
in policy/lib/sbom/sbom.rego so that purl is validated as a regex string (e.g.,
change the property from "type": "string" to include a regex validation such as
adding "format": "regex" or an appropriate "pattern" that enforces valid regex
syntax), ensuring the unless[].purl property rejects invalid regexes at
validation time so the runtime regex evaluation (unless[].purl usage) cannot
silently fail.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 6e136a93-ffe6-4d6a-a8d6-d4972b3be736
📒 Files selected for processing (8)
antora/docs/modules/ROOT/pages/packages/release_sbom_cyclonedx.adocantora/docs/modules/ROOT/pages/packages/release_sbom_spdx.adocpolicy/lib/sbom/sbom.regopolicy/release/sbom/sbom_test.regopolicy/release/sbom_cyclonedx/sbom_cyclonedx.regopolicy/release/sbom_cyclonedx/sbom_cyclonedx_test.regopolicy/release/sbom_spdx/sbom_spdx.regopolicy/release/sbom_spdx/sbom_spdx_test.rego
ReviewFindingsMedium
Low
Info
Previous runReviewFindingsMedium
Info
|
Allow exempting packages from disallowed attribute checks based on PURL patterns. Each disallowed_attributes entry now accepts an optional "unless" array of objects with a "purl" regex field. When a package's PURL matches any pattern, the attribute is permitted. Multiple unless entries are OR'd — any match exempts the package. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d8deb10 to
822eadc
Compare
|
🤖 Finished Review · ✅ Success · Started 5:41 PM UTC · Completed 5:56 PM UTC |
|
Closing this in favor of #1739 |
|
🤖 Finished Retro · ✅ Success · Started 5:58 PM UTC · Completed 6:04 PM UTC |
Retro: PR #1744 —
|
| Issue | Topic |
|---|---|
| #1418, #1422, #1452, #1357 | Deduplicate review runs on force-push |
| #1870, #1439, #885 | Skip review dispatch on closed PRs |
| #1771 | Sub-agent model fallback on unavailability |
| #2176, #1411 | Skip retro on closed-without-merge PRs |
No new proposals are warranted — this workflow exhibited known patterns that are already being addressed.
Allow exempting packages from disallowed attribute checks based on PURL patterns. Each disallowed_attributes entry now accepts an optional "unless" array of objects with a "purl" regex field. When a package's PURL matches any pattern, the attribute is permitted. Multiple unless entries are OR'd — any match exempts the package.