Skip to content

ci(security): enforce Trivy SARIF severity filter and suppress false positives - #342

Merged
Calvin-Cheng1 merged 1 commit into
mainfrom
ci/tune-security-scans
Oct 28, 2026
Merged

Calvin-Cheng1 merged 1 commit into
mainfrom
ci/tune-security-scans

Conversation

@aghassemlouei

Copy link
Copy Markdown
Member

Description

Tunes the repository security scanning configuration to eliminate false-positive alert noise in GitHub Code Scanning:

  • Enables limit-severities-for-sarif: true on aquasecurity/trivy-action in .github/workflows/ci.yml so trivy-results.sarif respects severity: 'CRITICAL,HIGH' instead of defaulting to all severities (LOW, MEDIUM, HIGH, CRITICAL).
  • Skips sample fixture directories (modules/net-lb-int/recipe-ilb-next-hop, modules/net-lb-app-int-cross-region/recipe-cross-reg-ilb-mig, modules/net-lb-app-int-cross-region/recipe-cross-reg-ilb-psc) via skip-dirs.
  • Adds .trivyignore.yaml (trivyignores: '.trivyignore.yaml') with path-scoped rules and documented rationales for architectural false positives (GCP-0007, GCP-0015, GCP-0043, GCP-0057).
  • Replaces bare hostname substring in checks in cli/tests/test_checks.py and cli/tests/test_repo.py with exact string and set comparisons so CodeQL py/incomplete-url-substring-sanitization does not flag unit test assertions.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Deployment & Compliance Impact

  • Applicable Regimes:
    • US Region Restricted (e.g., Access Policy constraint)
    • FedRAMP Moderate
    • FedRAMP High
    • DoD IL4
    • DoD IL5
    • General / All
  • NIST 800-53r5 Controls: RA-5 (Vulnerability Monitoring and Scanning), SA-11 (Developer Testing and Evaluation)

Checklist

Code Quality & Reusability

  • My code adheres to the Maximize Reusability principle. I have not redefined common elements and have reused existing base configurations and modules where possible.
  • I have checked that no existing module or configuration in modules/ or fast/stages-aw/ can be leveraged for this change.
  • My code follows the established naming conventions outlined in docs/naming-convention.md.

Documentation

  • I have updated the README.md of the modified module or blueprint.
  • I have added/updated documentation for inputs (variables) and outputs.

Security

  • My change adheres to GCP security best practices and the principle of least privilege.
  • I have ensured compliance with the targeted regime (FedRAMP Moderate, FedRAMP High, IL4, IL5, etc.).

Testing

  • I have tested my changes locally.
  • I have included details of my testing in this PR.

Testing Performed

  • Ran bash tools/lint.sh (Boilerplate, terraform fmt, tflint, check_documentation.py, check_links.py, check_names.py, ruff, validate_metadata.py, and version checks).
  • Ran bash tools/run_tests.sh (99 Python unit tests, 49 shell unit tests, 6 tflint runner tests, and 58 Python AST checks).
  • Ran CLI verification suite (ruff format --check, ruff check, pyright, and 160 pytest unit tests in cli/).

@aghassemlouei aghassemlouei added Dependencies - GitHub Actions Pull requests that update GitHub Actions workflows and actions Enhancement New feature or request Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Security Something is insecure or can be secured labels Oct 22, 2026
@github-actions github-actions Bot added the Scope - Fast Related to Fabric FAST deployment stages in the fast directory label Oct 22, 2026
@aghassemlouei
aghassemlouei marked this pull request as ready for review October 23, 2026 00:28
@aghassemlouei
aghassemlouei force-pushed the ci/tune-security-scans branch from c059f6f to db76235 Compare October 23, 2026 12:46
@aghassemlouei
aghassemlouei force-pushed the ci/tune-security-scans branch from db76235 to 64a783e Compare October 28, 2026 04:09

@Calvin-Cheng1 Calvin-Cheng1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions here:

  1. .github/workflows/ci.yml (line 52)

    • Issue: skip-dirs lists modules/net-lb-app-int-cross-region/recipe-cross-reg-ilb-mig and modules/net-lb-app-int-cross-region/recipe-cross-reg-ilb-psc, neither of which exists in this repository (those directory names are from a newer upstream CFF revision). The only recipe directory under modules/net-lb-app-int-cross-region/ in this repository is modules/net-lb-app-int-cross-region/recipe-cross-reg-int-app-lb-vm-dns.
    • Fix: Replace the two non-existent directory paths with modules/net-lb-app-int-cross-region/recipe-cross-reg-int-app-lb-vm-dns:
      skip-dirs: 'modules/net-lb-int/recipe-ilb-next-hop,modules/net-lb-app-int-cross-region/recipe-cross-reg-int-app-lb-vm-dns'
  2. .github/workflows/ci.yml (lines 41–58)

    • Issue: aquasecurity/trivy-action defaults exit-code to '0'. Without exit-code: '1', the Run Trivy vulnerability scanner in repo mode step always exits 0 even if un-suppressed CRITICAL or HIGH vulnerabilities, secrets, or misconfigurations are introduced, and only uploads the SARIF file to GitHub Code Scanning.
    • Fix: Add exit-code: '1' to the Trivy step so the Security Scans CI job fails when un-ignored CRITICAL or HIGH findings exist (with .trivyignore.yaml and skip-dirs in place, Trivy v0.76.1 reports 0 CRITICAL/HIGH findings on this branch, so the job will pass), and add if: always() to the Upload Trivy scan results to GitHub Security tab step so the SARIF report is still uploaded when Trivy exits non-zero:
            - name: Run Trivy vulnerability scanner in repo mode
              uses: aquasecurity/trivy-action@8f28faec26515256b6d22074d1d2a8986f4cbd87
              with:
                scan-type: 'fs'
                scanners: 'vuln,secret,misconfig'
                ignore-unfixed: true
                format: 'sarif'
                output: 'trivy-results.sarif'
                severity: 'CRITICAL,HIGH'
                limit-severities-for-sarif: true
                exit-code: '1'
                trivyignores: '.trivyignore.yaml'
                skip-dirs: 'modules/net-lb-int/recipe-ilb-next-hop,modules/net-lb-app-int-cross-region/recipe-cross-reg-int-app-lb-vm-dns'
      
            - name: Upload Trivy scan results to GitHub Security tab
              if: always()
              uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d
              with:
                sarif_file: 'trivy-results.sarif'
  3. .trivyignore.yaml (lines 46–75)

    • Issue: Minor accuracy notes on two of the suppression rationales when verified against Trivy v0.76.1:
      • GCP-0057 / AVD-GCP-0057 (modules/gke-cluster-standard/main.tf and modules/gke-cluster-standard-se/main.tf): Trivy's GKE adapter (pkg/iac/adapters/terraform/google/gke/adapt.go) does not inspect workload_identity_config (workload_pool = "${var.project_id}.svc.id.goog"). Instead, GCP-0057 (builtin.google.gke.google0057) flags google_container_cluster.cluster.node_config (lines 61 and 64) because node_config.workload_metadata_config.mode is unset ("UNSPECIFIED") on the cluster's inline node_config block, which is only used for the temporary default node pool (remove_default_node_pool = var.default_nodepool.remove_pool, defaulting to true) while actual workload node pools are managed via modules/gke-nodepool.
      • GCP-0043 / AVD-GCP-0043 (modules/compute-vm/main.tf): In Trivy v0.76.1, GCP-0043 only fires when can_ip_forward evaluates to true. Across the repo, the only static caller triggering GCP-0043 on modules/compute-vm/main.tf:161 is modules/net-lb-int/recipe-ilb-next-hop/gateways.tf (module.gw["b"] and module.gw["c"]), which is already excluded by skip-dirs: 'modules/net-lb-int/recipe-ilb-next-hop' (while NVA/NGFW callers in fast/stages-aw/2-networking-* use for_each maps that default to {}). Keeping GCP-0043 in .trivyignore.yaml as a safeguard is fine, or the comment can note that it protects NVA/NGFW gateway callers when instantiated.
    • Fix: Update the statement descriptions for GCP-0057/AVD-GCP-0057 (and optionally GCP-0043/AVD-GCP-0043) in .trivyignore.yaml to match Trivy's actual check evaluation.

@aghassemlouei

Copy link
Copy Markdown
Member Author

Addressed in 897065b against @Calvin-Cheng1.

  1. Updated skip-dirs in .github/workflows/ci.yml to modules/net-lb-int/recipe-ilb-next-hop,modules/net-lb-app-int-cross-region/recipe-cross-reg-int-app-lb-vm-dns.
  2. Added exit-code: '1' to the Trivy scan step and if: always() to the SARIF upload step in .github/workflows/ci.yml.
  3. Updated the statement descriptions for GCP-0043, AVD-GCP-0043, GCP-0057, and AVD-GCP-0057 in .trivyignore.yaml to reflect how Trivy v0.76.1 evaluates each rule.

Appreciate the review!

@Calvin-Cheng1
Calvin-Cheng1 merged commit 345616a into main Oct 28, 2026
22 checks passed
@Calvin-Cheng1
Calvin-Cheng1 deleted the ci/tune-security-scans branch October 28, 2026 17:08
@aghassemlouei aghassemlouei mentioned this pull request Oct 31, 2026
digitalresistor added a commit to digitalresistor/stellar-engine that referenced this pull request Nov 3, 2026
The rebase onto the Trivy severity filter from google#342 left two skip-dirs
keys in the Trivy step of the ci.yml workflow. GitHub Actions rejects a
workflow with a duplicate key, so the step lists the recipe directories
from google#342 and the vendored tests/fixtures/ directory in one skip-dirs
input.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dependencies - GitHub Actions Pull requests that update GitHub Actions workflows and actions Enhancement New feature or request Level of Effort - Low Quick, well-defined tasks with no unknowns; takes a few hours up to one day to complete Priority - Medium Standard features and non-blocking bugs; important for the current milestone but not urgent Scope - Fast Related to Fabric FAST deployment stages in the fast directory Security Something is insecure or can be secured

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants