Repository navigation
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files
|
ritiksah141
left a comment
There was a problem hiding this comment.
All good on my side.
Approving it.
|
@m-khan-97 can you please review that pr. Thank you |
2a1551d to
05378bd
Compare
|
@ritiksah141 looks like your approval came through as a comment rather than a formal review approval. Could you re-submit it as an approval so the PR can move forward? No code changes since you reviewed it. |
parthrohit22
left a comment
There was a problem hiding this comment.
Read the collector and the shared evaluator in full before touching individual rules, since all 10 route through them. Genuinely solid work in both: GovernanceCollector handles all three pagination shapes correctly (ARM nextLink, Resource Graph $skipToken, OData @odata.nextLink), and it defensively checks that a nextLink actually starts with the real ARM endpoint before following it - a real guard against a malformed or redirected pagination link, not something I see everywhere. Every evidence set (hierarchy, policy_assignments, locks, etc.) is independently nullable so one API failure can't corrupt or silently zero out an unrelated evidence set, load_governance_policy() fails loud on any missing/malformed field instead of defaulting, and test_missing_evidence_never_becomes_failure proving the indeterminate-handling discipline across all 10 rules in one parametrized test is good test design. No RULE_ID collisions, all 10 playbooks exist and pass bash -n, all four compliance framework JSONs have complete AZ-GOV-001..010 mappings. Ran the full suite myself in a clean clone: 737 passed, 3 skipped, 0 failed, ruff clean, CI 20/20 green.
One real bug though, confirmed with a repro rather than just reasoning about it - left inline on the specific line.
AZ-GOV-006 (excessive subscription Owners) undercounts real Owner exposure. The collector queries roleAssignments?...&$filter=atScope(), and Azure's atScope() filter returns assignments made at the queried scope and any ancestor scope that applies down to it - a management group grant included, not just direct subscription-level grants. But the AZ-GOV-006 branch only counts an Owner assignment toward the total when it's scoped exactly at the subscription. I fed evaluate() two real Owner assignments - one at the subscription, one inherited from a parent management group - against a policy capping Owners at 1, and got zero findings back. Two effective Owners, threshold of one, nothing flagged. test_gov_006_owner_threshold only ever constructs subscription-scoped fixtures, so this gap is genuinely untested. For a rule whose whole purpose is bounding effective Owner exposure, silently missing the most common enterprise pattern (Owner granted at a parent management group) is a real false negative, not a style nit.
| item | ||
| for item in assignments | ||
| if normal(properties(item).get("roleDefinitionId")).endswith(OWNER_ROLE_ID) | ||
| and _assignment_scope(item) == normal(subscription_scope) |
There was a problem hiding this comment.
This only counts an Owner assignment when it's scoped exactly at the subscription (_assignment_scope(item) == normal(subscription_scope)). But the collector's roleAssignments query uses $filter=atScope(), which Azure documents as returning assignments at the given scope and any scope above it that applies down - so a management-group-level Owner grant is included in assignments here, just with a scope that will never equal subscription_scope.
Verified with a direct repro: fed evaluate() one subscription-scoped Owner assignment and one Owner assignment whose id is rooted at /providers/Microsoft.Management/managementGroups/corp/..., against a policy with maximum_subscription_owners=1. Result was [] - two real effective Owners, zero findings, when it should have flagged with owner_count: 2.
Suggest counting any assignment in assignments that resolves to Owner and applies to this subscription (i.e. don't filter on exact scope equality here) rather than only ones scoped directly at the subscription - _assignment_scope(item) is still useful to report where the grant originates in the finding metadata, just not as a filter that excludes inherited grants from the count.
05378bd to
14f9d83
Compare
|
@parthrohit22 the one bug you confirmed is fixed: AZ-GOV-006 now counts all Owner assignments returned by |
14f9d83 to
c645347
Compare
|
@m-khan-97 @ritiksah141 @parthrohit22 rebase and the requrent fixes are done. Have a Look Please. thank you |
parthrohit22
left a comment
There was a problem hiding this comment.
Confirmed the AZ-GOV-006 fix — _governance_common.py now counts every Owner assignment atScope() returns instead of filtering to subscription-exact scope, which is the right call since that filter is exactly what was discarding management-group-inherited grants. Ran the new regression test myself: test_gov_006_owner_threshold and the parametrized test_missing_evidence_never_becomes_failure case both pass.
Approving.
|
Thank you for approving merging now as every requirement met. |
ab79b6b
c645347 to
ab79b6b
Compare
… prevent SSRF Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
|
@m-khan-97 the URL validation fix is in place: both |
|
@parthrohit22 @m-khan-97 All blocking concerns are addressed. Please re-review when you get a chance. |
…graph, exc_info on collection failures, exact GUID match via rsplit Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
…alogue Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
…interface Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
|
@ritiksah141 @parthrohit22 could you please re-review the latest head (c56bd81)? Governance integration conflicts, engine dispatch, compliance documentation and dependency fixes are updated. The fixes are pushed and all checks are passing on this head (the deployment skip is expected). Please review the updated code and tests, and update your review decision or resolve the relevant conversations when satisfied. |
parthrohit22
left a comment
There was a problem hiding this comment.
Re-reviewed c56bd81. My approval was dismissed by later pushes, so re-checking what changed since 732361e:
_post_graph()now passesallow_redirects=False(my non-blocking point), so all three credentialed calls are pinned to the ARM origin._is_valid_arm_continuation()and the fail-closedreturn Noneare unchanged. The new warnings log the rejectednextLinkwith%r, so a crafted URL can't inject lines into the log._strings()strips trailing slashes, so a management-group ID written as.../mg-root/in the policy file still matches.- The
devmerge is clean. Againstdev, the diff is only the governance work, and the new ISO mappings use 2022 control IDs (A.5.15, A.5.1, A.8.9, A.5.18), which the mapping-pack validator accepts. 303ed7akeeps the findings helpers out of the coverage-evaluator interface, with tests.
Approving. @m-khan-97, your 8 Sep change request (ARM pagination) is fixed on this head. It needs your re-review to clear.
|
@m-khan-97, the ARM pagination credential-boundary issue you identified has been fixed since commit 732361e (merged Sep 8). parthrohit22 re-reviewed and confirmed the fix in their Oct 12 re-review (see their APPROVED comment on c56bd81). Could you take a final look and clear your CHANGES_REQUESTED so this can merge? The fix addresses all three vectors you listed (suffix host, userinfo, unexpected port) via strict netloc comparison plus allow_redirects=False on all credentialed calls. |
…le replays load_context() stored the governance snapshot on the azure_client object without associating it with a subscription ID. When a scan evaluated rules across multiple subscriptions in one process, all subscriptions after the first would read the first subscription's snapshot instead of collecting their own. Added a _governance_snapshot_cache_sub sentinel alongside the cache. If the stored subscription does not match the current call, the cache is invalidated and a fresh GovernanceCollector.collect() is run for the new subscription. Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
Added TestLoadContextCaching with three cases: - cache populated on first call - cache reused for the same subscription (collector called only once) - cache invalidated when subscription changes (stale-replay guard) Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
Dependency lock updates are handled in #401 (fix/security-deps-python). Removing from this PR to resolve conflict with dev. Signed-off-by: Tanvir Farhad <tanvirfarhad007@gmail.com> Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
parthrohit22
left a comment
There was a problem hiding this comment.
Re-reviewed 21cea04. The code looks good:
- The subscription-keyed snapshot cache (339a718) is right, and the three new tests cover first use, reuse and invalidation.
AzureClientis created per scan, so the cache doesn't outlive a scan. - The ARM continuation fix that @m-khan-97 asked for is unchanged.
- The files synced from dev in 85e97ed (
engine.py,evaluation.py,azure_client.py,az_kv_006.py,docs/adding-a-rule.md) match dev exactly, so the net diff is only the governance work.
One change before merge. Since #381 landed, docs/adding-a-rule.md says new rules should expose evaluate(). A rule with only scan() is recorded as UNKNOWN / LEGACY_RULE_NOT_MIGRATED, and every compliance control mapped to it reads UNKNOWN. All ten AZ-GOV rules are scan()-only, so they'd join the #380 migration backlog on the day they merge.
They all go through _governance_common.evaluate(), so this should be one contained change:
- Return
RuleEvaluations from the shared evaluator and add a module-levelevaluate()to each rule, keepingscan()as a thin wrapper. - When the governance policy is missing or invalid, or the collector fails, report
ERROR(orNOT_APPLICABLEwhen no policy is configured on purpose) instead of an empty list. - Use
subscription_scope_id(subscription_id)for subscription-level results. - Register PASS/FAIL fixtures in
tests/test_rule_evaluation_contract.py.
…contract Each governance rule now reports per-resource PASS/FAIL/ERROR/NOT_APPLICABLE via evaluate(), with scan() a thin wrapper over its FAIL findings. Missing evidence and an unset or invalid governance policy fail closed as ERROR instead of reading as a silent pass. Snapshot collection moves behind AzureClient.get_governance_snapshot; the subscription-keyed cache semantics are unchanged. Contract fixtures are registered for all ten rules, with a passing/failing scenario each so subscription-singular rules (001/002/006) can satisfy the PASS and FAIL checks. Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
|
Thanks @parthrohit22. Addressed the Nov 2 blocker in 9ee9e55: all ten AZ-GOV rules now expose
Full test suite is green locally and |
|
Note on the red check: |
parthrohit22
left a comment
There was a problem hiding this comment.
Approved: the governance evaluation contract, ARM pagination validation, and rebase conflicts called out in review are resolved; regression coverage is in place and the suite is passing on the current head.
parthrohit22
left a comment
There was a problem hiding this comment.
Thanks for the rebase and for cleaning up the earlier issues. The governance evaluation contract, ARM pagination validation, and merge-conflict fixes are all in place, and the relevant regression coverage is passing. This gives me confidence the PR is ready to merge, so I’m approving it.
Summary
Adds AZ-GOV-001 through AZ-GOV-010, strict organization-owned policy configuration, read-only evidence collection, remediation playbooks and four framework mappings. Inherited Owner assignments and ARM pagination credential boundaries are covered. The engine regression now exercises public scan behavior against current dev rather than the removed private interface.
Runtime dependency inputs and Linux Python 3.11 hash locks include the patched aiohttp, multidict, Werkzeug and certifi versions. No new vulnerability suppressions were added.
Validation
85e97ed069d44c04fecab9ba29383c7c0ef31e4e.Focused governance checks: 52 passed. No live Azure subscription smoke test was performed.
Review status
Code and current-head CI are ready for independent re-review. Existing reviewer approvals and conversations are intentionally left for reviewers to confirm; this is not approval or merge authorization.