Repository navigation
Fix false positives across AWS/GCP/Azure rego rules + modernize policies - #579
Merged
Merged
Conversation
…adata - Add shared common.rego (package common) to all 14 CSP subdirectories - Migrate 95 cloud rego files to use import data.common, removing all local helper function definitions (has_property, array_contains, etc.) - Replace magic numbers with named constants (ninety_days_seconds, etc.) - Remove ~800+ lines of commented-out code across all three CSPs - Fix null handling inconsistencies in GCP cloud (consolidate redundant triple-check patterns into common.non_empty) - Clean up AWS/Azure master-compliance-test.json titles: fix grammar, trailing periods, capitalization, contractions, subject-verb agreement - Enrich compliance tags: +6027 AWS tags, +1373 Azure tags across NIST 800-53, PCI DSS, SOC 2, CIS, ISO 27001, Azure Security Benchmark - Fix AWS PR-AWS-CLD-S3-026 severity typo (low -> Low) - Expand .gitignore to cover credentials, binaries, and test artifacts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cherry-picked from claude/review branch and adapted for our repo structure: - CI workflow validates rego syntax, JSON integrity, compliance metadata, file references, best practices, and PR size across all CSPs - Updated OPA checks to load common.rego alongside policy files - Updated paths from lib/ to utils/ to match our common.rego structure - Added local validation script (scripts/validate-pr.sh) - Added sample security group unit test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When resources don't exist in input, rules previously returned true (pass) due to default=true and the = false body never firing. Changed to: - default=null (skip when resource absent) - _violation helpers for each check - Explicit pass rule with resource existence guard - Explicit false rule on violation 28 AWS cloud files + 3 GCP cloud files modified. 788 violation helpers created. All OPA syntax checks pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Complete the false-positive fix across entire repo. Changed last 3 rules with default=true to default=null in google/iac/container.rego, google/terraform/iam.rego, and google/terraform/app.rego. Zero default=true remaining in the entire repository. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… check IAM rules (iam.rego): - Added is_aws_managed_policy helper to detect arn:aws:iam::aws:policy/ - Added guard to all 16 PolicyVersion-based rules (49 violation bodies + 16 pass rules) - AWS managed policies (AdministratorAccess, PowerUserAccess, etc.) now return null instead of false, eliminating 1,600 false positives Security Groups (securitygroup.rego): - Fixed port_proto_all (PR-AWS-CLD-SG-020) to check IpPermissions (inbound) instead of IpPermissionsEgress (outbound), matching the rule title - Added IpProtocol == "-1" check for all-protocols detection - Removed default-only filter to check all security groups - Eliminates 2 false positives from self-referencing SG rules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Removed PR-AWS-CLD-VPC-004, PR-AWS-CLD-IAM-047, PR-AWS-CLD-IAM-048 as these cannot be accurately validated at the rego level and generate false positives that cannot be fixed without framework changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… input Changed ecr_repository, lambda_function, s3_bucket, sqs_queue, secret_manager_secret, and sns publicly-accessible-through-IAM rules from default=false to default=null with _violation helpers and input.Role guards to prevent false positives on empty/null role data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR eliminates 1,620+ false positives in Prancer compliance scans by fixing rego rule logic across AWS, GCP, and Azure, while also modernizing all cloud rego files.
False Positive Fixes
1. Null-Safe Pattern — eliminates FPs when resources don't exist (all CSPs)
default = nullwith_violationhelper pattern to 399+ rules across 28 AWS, 15 GCP, and 52 Azure cloud rego filesnull(not applicable) instead oftrue(pass), preventing Prancer from misinterpreting the result as a failure2. AWS Managed Policy Filter — eliminates FPs from scanning AWS-owned policies
is_aws_managed_policyguard to all 16 IAM PolicyVersion-based rules (65 guard insertions)arn:aws:iam::aws:policy/*ARNs which inherently use wildcards by design3. Security Group Inbound Fix (PR-AWS-CLD-SG-020)
IpPermissionsEgress(outbound) instead ofIpPermissions(inbound)IpProtocol == "-1"check for all-protocols4. IAM Publicly-Accessible Rules — 6 rules fixed
ecr_repository,lambda_function,s3_bucket,sqs_queue,secret_manager_secret, andsnspublicly-accessible rules fromdefault = falsetodefault = nullwith properinput.Roleguards5. Removed 3 Unfixable Test Cases
master-compliance-test.jsonValidation Results (4 rounds of testing)
Policy Modernization (pre-existing in this branch)
common.regoutility library withhas_property,array_contains,non_empty,resource_exists— synced to all 14 CSP subdirectoriesFiles Changed
Test Plan
opa check(OPA v0.63.0)