[StepSecurity] Apply security best practices#2236
[StepSecurity] Apply security best practices#2236step-security-bot wants to merge 1 commit intoroboflow:developfrom
Conversation
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2236 +/- ##
=======================================
Coverage 78% 78%
=======================================
Files 66 66
Lines 8345 8345
=======================================
Hits 6473 6473
Misses 1872 1872 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR applies supply-chain security best practices across the repository’s tooling by hardening GitHub Actions runners, adding security/scanning workflows, and extending automated secret/dependency checks.
Changes:
- Add Harden-Runner to existing GitHub Actions workflows to audit outbound network calls.
- Introduce new security workflows: CodeQL scanning, OpenSSF Scorecard, and Dependency Review.
- Add gitleaks to pre-commit and expand Dependabot updates to cover example
requirements.txtfiles.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| .pre-commit-config.yaml | Adds gitleaks hook to pre-commit to detect secrets early. |
| .github/dependabot.yml | Adds Dependabot pip update entries for multiple example directories. |
| .github/workflows/scorecards.yml | New workflow to run OpenSSF Scorecard analysis and upload SARIF. |
| .github/workflows/codeql.yml | New workflow to run CodeQL on Python for develop PRs/pushes + schedule. |
| .github/workflows/dependency-review.yml | New workflow to run dependency review on pull requests. |
| .github/workflows/build-package.yml | Adds Harden-Runner to build workflow. |
| .github/workflows/ci-build-docs.yml | Adds Harden-Runner to docs build CI workflow. |
| .github/workflows/ci-check-links.yml | Adds Harden-Runner to link-check workflow. |
| .github/workflows/ci-tests.yml | Adds Harden-Runner to test workflow (including guardian job). |
| .github/workflows/clear-cache.yml | Adds Harden-Runner to cache cleanup workflow. |
| .github/workflows/pr-conflict-labeler.yml | Adds Harden-Runner to conflict labeler workflow. |
| .github/workflows/publish-docs.yml | Adds Harden-Runner to docs publish workflow. |
| .github/workflows/publish-pre-release.yml | Adds Harden-Runner to pre-release publish workflow. |
| .github/workflows/publish-release.yml | Adds Harden-Runner to release publish workflow. |
| .github/workflows/publish-testpypi.yml | Adds Harden-Runner to TestPyPI publish workflow. |
| egress-policy: audit | ||
|
|
||
| - name: "Checkout code" | ||
| uses: actions/checkout@v4 |
There was a problem hiding this comment.
This workflow uses actions/checkout@v4 (floating tag). Elsewhere in the repo actions/checkout is pinned to a commit SHA; consider pinning here as well to reduce supply-chain risk and keep workflow security posture consistent.
| uses: actions/checkout@v4 | |
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| uses: actions/checkout@v4 | ||
| - name: 'Dependency Review' | ||
| uses: actions/dependency-review-action@v4 |
There was a problem hiding this comment.
Both actions/checkout@v4 and actions/dependency-review-action@v4 are referenced via moving tags. If the goal is supply-chain hardening, consider pinning these actions to commit SHAs (similar to how other workflows pin actions/checkout).
| uses: actions/checkout@v4 | |
| - name: 'Dependency Review' | |
| uses: actions/dependency-review-action@v4 | |
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
| - name: 'Dependency Review' | |
| uses: actions/dependency-review-action@c9c05d8de6f8d8f982f050f4c6eaa0c1def81b1a # v4.3.5 |
| egress-policy: audit | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 |
There was a problem hiding this comment.
This workflow uses actions/checkout@v4 (floating tag). Since other workflows in this repo pin actions/checkout to a commit SHA, consider pinning it here too for consistency and better supply-chain security.
| uses: actions/checkout@v4 | |
| uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| interval: daily | ||
|
|
||
| - package-ecosystem: pip | ||
| directory: /examples/heatmap_and_track | ||
| schedule: | ||
| interval: daily | ||
|
|
||
| - package-ecosystem: pip | ||
| directory: /examples/speed_estimation | ||
| schedule: | ||
| interval: daily | ||
|
|
||
| - package-ecosystem: pip | ||
| directory: /examples/time_in_zone | ||
| schedule: | ||
| interval: daily | ||
|
|
||
| - package-ecosystem: pip | ||
| directory: /examples/tracking | ||
| schedule: | ||
| interval: daily | ||
|
|
||
| - package-ecosystem: pip | ||
| directory: /examples/traffic_analysis | ||
| schedule: | ||
| interval: daily |
There was a problem hiding this comment.
The new example pip Dependabot entries don’t specify target-branch: "develop" (and don’t set the commit-message prefix) like the existing root pip/github-actions entries. This will make Dependabot PRs for these example requirements target the repo default branch and use a different commit message format; consider adding the same target-branch and commit-message settings to all the new example entries for consistency and to avoid updates landing on the wrong branch.
| interval: daily | |
| - package-ecosystem: pip | |
| directory: /examples/heatmap_and_track | |
| schedule: | |
| interval: daily | |
| - package-ecosystem: pip | |
| directory: /examples/speed_estimation | |
| schedule: | |
| interval: daily | |
| - package-ecosystem: pip | |
| directory: /examples/time_in_zone | |
| schedule: | |
| interval: daily | |
| - package-ecosystem: pip | |
| directory: /examples/tracking | |
| schedule: | |
| interval: daily | |
| - package-ecosystem: pip | |
| directory: /examples/traffic_analysis | |
| schedule: | |
| interval: daily | |
| interval: daily | |
| commit-message: | |
| prefix: ⬆️ | |
| target-branch: "develop" | |
| - package-ecosystem: pip | |
| directory: /examples/heatmap_and_track | |
| schedule: | |
| interval: daily | |
| commit-message: | |
| prefix: ⬆️ | |
| target-branch: "develop" | |
| - package-ecosystem: pip | |
| directory: /examples/speed_estimation | |
| schedule: | |
| interval: daily | |
| commit-message: | |
| prefix: ⬆️ | |
| target-branch: "develop" | |
| - package-ecosystem: pip | |
| directory: /examples/time_in_zone | |
| schedule: | |
| interval: daily | |
| commit-message: | |
| prefix: ⬆️ | |
| target-branch: "develop" | |
| - package-ecosystem: pip | |
| directory: /examples/tracking | |
| schedule: | |
| interval: daily | |
| commit-message: | |
| prefix: ⬆️ | |
| target-branch: "develop" | |
| - package-ecosystem: pip | |
| directory: /examples/traffic_analysis | |
| schedule: | |
| interval: daily | |
| commit-message: | |
| prefix: ⬆️ | |
| target-branch: "develop" |
| egress-policy: audit | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 |
There was a problem hiding this comment.
actions/checkout is referenced via a moving version tag here, while other workflows in this repo pin actions/checkout to a specific commit SHA. For supply-chain hardening and consistency, consider switching this to the same pinned SHA used elsewhere (and keep the version comment).
| uses: actions/checkout@v6 | |
| uses: actions/checkout@<SAME_PINNED_COMMIT_SHA_USED_ELSEWHERE_IN_REPO> # v6 |
Summary
This pull request is created by StepSecurity at the request of @Borda. Please merge the Pull Request to incorporate the requested changes. Please tag @Borda on your message if you have any questions related to the PR.
Security Fixes
Harden Runner
Harden-Runner is an open-source security agent for the GitHub-hosted runner to prevent software supply chain attacks. It prevents exfiltration of credentials, detects tampering of source code during build, and enables running jobs without
sudoaccess. See how popular open-source projects use Harden-Runner here.Harden runner usage
You can find link to view insights and policy recommendation in the build log
Please refer to documentation to find more details.
Keeping your actions up to date with Dependabot
With Dependabot version updates, when Dependabot identifies an outdated dependency, it raises a pull request to update the manifest to the latest version of the dependency. This is recommended by GitHub as well as The Open Source Security Foundation (OpenSSF).
Detect Vulnerabilities with SAST Workflow
Static Code Analysis (also known as Source Code Analysis) is usually performed as part of a Code Review (also known as clear-box testing) and is carried out at the Implementation phase of a Security Development Lifecycle (SDL). Static Code Analysis commonly refers to the running of Static Code Analysis tools that attempt to highlight possible vulnerabilities within ‘static’ (non-running) source code by using techniques such as Taint Analysis and Data Flow Analysis.
Add Dependency Review Workflow
The Dependency Review Workflow enforces dependency reviews on your pull requests. The action scans for vulnerable versions of dependencies introduced by package version changes in pull requests, and warns you about the associated security vulnerabilities. This gives you better visibility of what's changing in a pull request, and helps prevent vulnerabilities being added to your repository.
Add OpenSSF Scorecard Workflow
OpenSSF Scorecard is an automated tool that assesses a number of important heuristics ("checks") associated with software security and assigns each check a score of 0-10. You can use these scores to understand specific areas to improve in order to strengthen the security posture of your project.
Scorecard workflow also allows maintainers to display a Scorecard badge on their repository to show off their hard work.
Maintain Code Quality with Pre-Commit
Pre-commit is a framework for managing and maintaining multi-language pre-commit hooks. Hooks can be any scripts, code, or binaries that run at any stage of the git workflow. Pre-commit hooks are useful for enforcing code quality, code formatting, and detecting security vulnerabilities.
Feedback
For bug reports, feature requests, and general feedback; please email support@stepsecurity.io. To create such PRs, please visit https://app.stepsecurity.io/securerepo.
Signed-off-by: StepSecurity Bot bot@stepsecurity.io