[StepSecurity] Apply security best practices#50
Conversation
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
WalkthroughThis update enhances the project's automation and security through the introduction of new GitHub Actions workflows for CodeQL analysis, dependency reviews, and supply-chain security assessment. It also implements a new Dependabot configuration for managing updates and integrates pre-commit hooks to improve code quality. These changes collectively promote safer coding practices and maintainability, ensuring the project is well-equipped to handle dependencies and potential vulnerabilities. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant GitHub
participant Dependabot
participant CodeQL
participant DependencyReview
participant Scorecards
User->>GitHub: Push code/PR
GitHub->>Dependabot: Check for dependency updates
GitHub->>CodeQL: Trigger CodeQL analysis
GitHub->>DependencyReview: Start dependency review
GitHub->>Scorecards: Run supply-chain security analysis
Dependabot->>GitHub: Propose dependency updates
CodeQL->>GitHub: Report vulnerabilities
DependencyReview->>GitHub: Flag vulnerable dependencies
Scorecards->>GitHub: Provide security assessment results
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
|
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. |
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- .github/dependabot.yml (1 hunks)
- .github/workflows/codeql.yml (1 hunks)
- .github/workflows/dependency-review.yml (1 hunks)
- .github/workflows/go.yml (2 hunks)
- .github/workflows/scorecards.yml (1 hunks)
- .pre-commit-config.yaml (1 hunks)
Additional comments not posted (19)
.github/dependabot.yml (2)
1-7: LGTM! Dependabot configuration for GitHub Actions is correct.The configuration for GitHub Actions is set up correctly to check for updates daily.
8-11: LGTM! Dependabot configuration for Go modules is correct.The configuration for Go modules is set up correctly to check for updates daily.
.pre-commit-config.yaml (3)
1-5: LGTM! Pre-commit hook configuration for gitleaks is correct.The configuration for gitleaks is set up correctly to detect secrets in the codebase.
6-9: LGTM! Pre-commit hook configuration for golangci-lint is correct.The configuration for golangci-lint is set up correctly to lint Go code.
10-14: LGTM! Pre-commit hook configuration for pre-commit-hooks is correct.The configuration for pre-commit-hooks is set up correctly to fix end-of-file issues and trailing whitespace.
.github/workflows/dependency-review.yml (3)
19-23: LGTM! Step for hardening the runner is correct.The step for hardening the runner is set up correctly using the
step-security/harden-runneraction.
24-25: LGTM! Step for checking out the repository is correct.The step for checking out the repository is set up correctly using the
actions/checkoutaction.
26-27: LGTM! Step for performing a dependency review is correct.The step for performing a dependency review is set up correctly using the
actions/dependency-review-action..github/workflows/go.yml (3)
7-9: Good practice: Least Privileged GitHub Actions Token Permissions.The addition of the
permissionssection withcontents: readfollows the principle of least privilege, enhancing the security of the workflow.
21-25: Security enhancement: Harden Runner step.The addition of the "Harden Runner" step with
egress-policy: auditimproves the security posture by monitoring outbound network traffic.
27-31: Update action versions: setup-go and checkout.The updates to the
setup-goandcheckoutactions ensure that the latest features and security fixes are incorporated..github/workflows/codeql.yml (4)
1-25: Good practice: Informative introduction and least privileged permissions.The introduction provides clear context for the workflow, and the
permissionssection withcontents: readfollows the principle of least privilege, enhancing security.
26-41: Well-defined job configuration and matrix strategy.The job configuration includes appropriate permissions and a matrix strategy for the Go language, aligning with best practices for CodeQL analysis.
42-59: Essential steps for secure CodeQL analysis setup.The steps for hardening the runner, checking out the repository, and initializing CodeQL are essential for a secure and effective CodeQL analysis workflow.
60-78: Comprehensive CodeQL analysis steps.The steps for autobuilding, performing CodeQL analysis, and optional build steps ensure a comprehensive analysis that can handle various build scenarios.
.github/workflows/scorecards.yml (4)
1-18: Good practice: Informative introduction and least privileged permissions.The introduction provides clear context for the workflow, and the
permissionssection withread-allfollows the principle of least privilege, enhancing security.
20-31: Well-defined job configuration and permissions.The job configuration includes appropriate permissions for security-events, id-token, contents, and actions, aligning with best practices for Scorecard analysis.
32-53: Essential steps for secure Scorecard analysis setup.The steps for hardening the runner, checking out the repository, and running the Scorecard analysis are essential for a secure and effective workflow.
54-76: Comprehensive result publishing and artifact uploading steps.The steps for publishing results and uploading artifacts to the code-scanning dashboard ensure that the results of the Scorecard analysis are accessible and can be reviewed for security insights.
Summary
This pull request is created by StepSecurity at the request of @james-d-elliott. Please merge the Pull Request to incorporate the requested changes. Please tag @james-d-elliott on your message if you have any questions related to the PR.
Security Fixes
Least Privileged GitHub Actions Token Permissions
The GITHUB_TOKEN is an automatically generated secret to make authenticated calls to the GitHub API. GitHub recommends setting minimum token permissions for the GITHUB_TOKEN.
Pinned Dependencies
GitHub Action tags and Docker tags are mutable. This poses a security risk. GitHub's Security Hardening guide recommends pinning actions to full length commit.
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.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
Summary by CodeRabbit
New Features
Improvements
Maintenance