bandit-high.yml 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. name: Bandit High Severity Scan
  2. on:
  3. push:
  4. branches: [ main ]
  5. pull_request:
  6. branches: [ main ]
  7. permissions:
  8. contents: read
  9. jobs:
  10. bandit:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: Checkout code
  14. uses: actions/checkout@v7
  15. - name: Set up Python
  16. uses: actions/setup-python@v6.3.0
  17. with:
  18. python-version: '3.11'
  19. - name: Install Bandit
  20. run: pip install bandit
  21. - name: Run Bandit (fail only on high severity)
  22. run: bandit -r . -x tests,venv,__pycache__ -lll --exit-zero > bandit-report.txt && bandit -r . -x tests,venv,__pycache__ -lll --quiet
  23. - name: Fail if high severity found
  24. run: |
  25. if grep -q "Severity: High" bandit-report.txt; then
  26. echo "High severity issues found! Failing workflow." && exit 1
  27. else
  28. echo "No high severity issues found."
  29. fi
  30. - name: Upload Bandit report artifact
  31. uses: actions/upload-artifact@v7.0.1
  32. with:
  33. name: bandit-high-report
  34. path: bandit-report.txt