| 12345678910111213141516171819202122232425262728293031323334353637 |
- name: Bandit High Severity Scan
- on:
- push:
- branches: [ main ]
- pull_request:
- branches: [ main ]
- permissions:
- contents: read
- jobs:
- bandit:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v7
- - name: Set up Python
- uses: actions/setup-python@v6.3.0
- with:
- python-version: '3.11'
- - name: Install Bandit
- run: pip install bandit
- - name: Run Bandit (fail only on high severity)
- run: bandit -r . -x tests,venv,__pycache__ -lll --exit-zero > bandit-report.txt && bandit -r . -x tests,venv,__pycache__ -lll --quiet
- - name: Fail if high severity found
- run: |
- if grep -q "Severity: High" bandit-report.txt; then
- echo "High severity issues found! Failing workflow." && exit 1
- else
- echo "No high severity issues found."
- fi
- - name: Upload Bandit report artifact
- uses: actions/upload-artifact@v7.0.1
- with:
- name: bandit-high-report
- path: bandit-report.txt
|