← Back to Pull requests

[security] Make bandit scanner compatible with local build and submodule folders #8838

Closed
unknown closed this pull request without merging on Oct 08, 2026 17:06 UTC
View on GitHub
unknown unknown commented on Oct 07, 2026 20:45 UTC
Author

Motivation

Progress on https://github.com/ROCm/TheRock/issues/8272

This allows developers to run the bandit (https://bandit.readthedocs.io/en/latest/) scanner for python security issues locally. I'm separately looking through the remaining issues it reports and figuring out how to address them.

Technical Details

I decided to drop test from exclude_dirs (as that may also match test_tools/) and switched to more tightly-scoped assert_used: skips: rules. This revealed a few high severity issues in tests which are fixed here too.
The extra bandit.ini file is needed when running locally to prevent bandit from auto-discovering ambiguous bandit.ini files in submodules and build outputs (great design...). This isn't mentioned anywhere on https://bandit.readthedocs.io/en/latest/config.html though :/. Specifically this file https://github.com/ROCm/libhipcxx/blob/amd-develop/.bandit appears in multiple directories and running without --ini results in:

    (.venv) λ bandit --configfile build_tools/scan_tools/bandit.yml --severity-level low --recursive .
    [main]  ERROR   Multiple .bandit files found - scan separately or choose one with --ini
            .\build\artifacts\libhipcxx_test_generic\math-libs\libhipcxx\build\libhipcxx\.bandit, .\build\artifacts-unsplit\libhipcxx_test_gfx1100\math-libs\libhipcxx\build\libhipcxx\.bandit, .\build\dist\rocm\libhipcxx\.bandit, .\build\math-libs\libhipcxx\build\libhipcxx\.bandit, .\math-libs\libhipcxx\.bandit
    

Test Plan

From a source checkout with build directories, virtual environments, submodules initialized, etc.:

    bandit --ini build_tools/scan_tools/bandit.ini --configfile build_tools/scan_tools/bandit.yml --severity-level low --recursive .
    
    Code scanned:
            Total lines of code: 109408
            Total lines skipped (#nosec): 0
    
    Run metrics:
            Total issues (by severity):
                    Undefined: 0
                    Low: 63
                    Medium: 56
                    High: 0
            Total issues (by confidence):
                    Undefined: 0
                    Low: 1
                    Medium: 59
                    High: 59
    Files skipped (0):
    

  • On this PR: https://github.com/ROCm/TheRock/actions/runs/37684403089/job/113008644150?pr=8838 (passed, the same findings that I see locally)
  • Submission Checklist

  • Look over the contributing guidelines at https://github.com/ROCm/TheRock/blob/main/CONTRIBUTING.md.
  • Diff: 327 lines (+245 / -82) across 4 files Reviewer: geomin12 Review duration: 1221m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.65) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.65 · 327 lines diff across 4 files
    0.65
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.347
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.065
    Real PR Conversation Timeline
    1 comments
    "Review active on #8838"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.2% (HIGH) · Higher = larger blast radius
    65.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.8% · Safe to merge
    25.8%
    Repository