feat(security): Add comprehensive security scanning infrastructure#97
Conversation
Add multi-layered security scanning to CI/CD pipeline: Python Security: - pip-audit for dependency vulnerability scanning - Bandit SAST via Ruff and standalone for SARIF output - Configuration in pyproject.toml JavaScript Security: - eslint-plugin-security for SAST rules - npm audit scripts for dependency scanning CI/CD Workflows: - security.yml: pip-audit, Bandit, npm audit scans - codeql.yml: GitHub CodeQL SAST for Python and JavaScript - docker-publish.yml: Added Dockle CIS benchmark scanning - ci.yml: Added dependency-review action for PR blocking Infrastructure: - Makefile targets: security, security-python, security-frontend - SECURITY.md policy with vulnerability reporting guidelines - Comprehensive plan in plan/01-active/SECURITY-SCANNING-PLAN.md All scans upload SARIF to GitHub Security tab for centralized vulnerability management.
Add multi-layered security scanning to CI/CD pipeline: Python Security: - pip-audit for dependency vulnerability scanning - Bandit SAST via Ruff and standalone for SARIF output - Configuration in pyproject.toml JavaScript Security: - eslint-plugin-security for SAST rules - npm audit scripts for dependency scanning CI/CD Workflows: - security.yml: pip-audit, Bandit, npm audit scans - codeql.yml: GitHub CodeQL SAST for Python and JavaScript - docker-publish.yml: Added Dockle CIS benchmark scanning - ci.yml: Added dependency-review action for PR blocking Infrastructure: - Makefile targets: security, security-python, security-frontend - SECURITY.md policy with vulnerability reporting guidelines - Comprehensive plan in plan/01-active/SECURITY-SCANNING-PLAN.md All scans upload SARIF to GitHub Security tab for centralized vulnerability management.
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
The PyCQA/bandit-action uses Python 3.8 and doesn't support pyproject.toml config properly. This change: - Adds bandit[sarif] extra for SARIF output format - Runs bandit directly with uv sync instead of the action - Uploads results to GitHub Security tab - Disables license-check in dependency-review (focus on vulns) - Uses fail-on-scopes: runtime to skip dev dependency checks
There was a problem hiding this comment.
Pull request overview
This PR establishes a comprehensive security scanning infrastructure for the Phentrieve project, adding multiple layers of automated security checks to the CI/CD pipeline. The implementation addresses gaps in Python/JavaScript dependency scanning, SAST analysis, container compliance checking, and PR-level vulnerability blocking.
Key Changes:
- Added Python security scanning with pip-audit and Bandit with SARIF output
- Integrated JavaScript security scanning using npm audit and eslint-plugin-security
- Implemented CodeQL SAST analysis for both Python and JavaScript codebases
- Added Dockle CIS benchmark compliance checking for Docker images
- Configured Dependency Review action to block PRs introducing vulnerable dependencies
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Added pip-audit and bandit with TOML/SARIF support to dev dependencies; configured Bandit exclusions and skipped checks |
frontend/package.json |
Added eslint-plugin-security dev dependency and npm audit scripts (audit, audit:prod, audit:fix) |
frontend/eslint.config.js |
Integrated eslint-plugin-security with recommended rules and tuned settings for common false positives |
SECURITY.md |
Created security policy documenting vulnerability reporting process, supported versions, and security measures |
Makefile |
Added security scanning targets: security, security-python, security-frontend, security-audit, security-report |
.github/workflows/security.yml |
New workflow for pip-audit, Bandit, and npm audit with SARIF uploads and security summary |
.github/workflows/docker-publish.yml |
Added Dockle CIS benchmark scanning for both API and frontend Docker images |
.github/workflows/codeql.yml |
New CodeQL SAST workflow scanning Python and JavaScript with extended security queries |
.github/workflows/ci.yml |
Added dependency-review action to block PRs with high-severity vulnerabilities in runtime dependencies |
plan/01-active/SECURITY-SCANNING-PLAN.md |
Comprehensive implementation plan documenting security scanning strategy, tools, and rollout phases |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ci-summary: | ||
| name: CI Summary | ||
| needs: [changes, python-ci, frontend-ci, docker-build-test] | ||
| needs: [changes, python-ci, frontend-ci, docker-build-test, dependency-review] |
There was a problem hiding this comment.
The ci-summary job unconditionally depends on dependency-review, but dependency-review only runs on pull requests (if: github.event_name == 'pull_request'). This will cause the summary job to be skipped on push events to main/develop branches. Add 'if: always()' to dependency-review in the needs array or make the dependency conditional.
| if [[ "${{ needs.dependency-review.result }}" == "failure" ]]; then | ||
| echo "❌ Dependency review found vulnerabilities" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
This check will fail when dependency-review is skipped (on non-PR events), as the result will be 'skipped' not 'success'. Add a condition to only check when the job actually ran: if [[ \"${{ needs.dependency-review.result }}\" == \"failure\" ]]; then
Address Copilot review feedback: - Add comment documenting that dependency-review only runs on PRs - Add step summary table for better visibility - Comment clarifies that 'skipped' state is expected on push events The existing check (result == "failure") correctly handles skipped jobs - it only fails on actual failures, not on skipped state.
Addressed Copilot Review FeedbackFixed in commit 65e17a5: Issue 1 (dependency-review conditional dependency):
Issue 2 (handling skipped state):
The workflow correctly handles both scenarios:
|
Summary
Changes
New Workflows
security.yml- pip-audit, Bandit, npm audit scanscodeql.yml- GitHub CodeQL SAST (Python + JavaScript)Updated Workflows
docker-publish.yml- Added Dockle CIS benchmark scanningci.yml- Added dependency-review action for PR blockingNew Files
SECURITY.md- Security policy with vulnerability reportingplan/01-active/SECURITY-SCANNING-PLAN.md- Implementation planDependencies
Makefile Targets
Test plan
make checkpasses