Skip to content

[StepSecurity] Apply security best practices#50

Merged
james-d-elliott merged 1 commit into
go-crypt:masterfrom
step-security-bot:stepsecurity_remediation_1721526480
Jul 21, 2024
Merged

[StepSecurity] Apply security best practices#50
james-d-elliott merged 1 commit into
go-crypt:masterfrom
step-security-bot:stepsecurity_remediation_1721526480

Conversation

@step-security-bot
Copy link
Copy Markdown
Contributor

@step-security-bot step-security-bot commented Jul 21, 2024

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 sudo access.

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

    • Introduced automated security workflows for dependency review, CodeQL analysis, and supply-chain security checks.
    • Added pre-commit hooks for enhanced code quality and security checks.
  • Improvements

    • Enhanced dependency management with daily updates.
    • Security measures in workflows now include hardened runners and permission specifications.
  • Maintenance

    • Updated various GitHub Actions to their latest versions for improved functionality and security.

Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
@step-security-bot step-security-bot requested a review from a team as a code owner July 21, 2024 01:48
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 21, 2024

Walkthrough

This 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

Files Change Summary
.github/dependabot.yml Introduced Dependabot configuration for GitHub Actions and Go modules; daily update checks established.
.github/workflows/codeql.yml New workflow for CodeQL analysis triggered on pushes and PRs, focusing on Go language; includes security hardening.
.github/workflows/dependency-review.yml New workflow to scan for vulnerable dependencies in PRs, enhancing security before merging.
.github/workflows/go.yml Added permissions section and a "Harden Runner" step; updated actions for improved security and maintainability.
.github/workflows/scorecards.yml New workflow for OpenSSF Scorecard analysis; runs on scheduled and specific branch events, promoting supply-chain security.
.pre-commit-config.yaml New hooks added for gitleaks, golangci-lint, and common tasks, automating checks for quality and security.

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
Loading

🐰 "In the garden of code, where bunnies play,
New workflows hop in, brightening the way.
Dependencies updated, security tight,
A joyous parade of features in sight!
With lint and checks, our code blooms bright,
Hopping along, we code with delight!" 🌼


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-advanced-security
Copy link
Copy Markdown

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.

@james-d-elliott james-d-elliott merged commit 0e3520f into go-crypt:master Jul 21, 2024
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7a0dbbf and ec33493.

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-runner action.


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/checkout action.


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 permissions section with contents: read follows 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: audit improves the security posture by monitoring outbound network traffic.


27-31: Update action versions: setup-go and checkout.

The updates to the setup-go and checkout actions 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 permissions section with contents: read follows 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 permissions section with read-all follows 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.

@coderabbitai coderabbitai Bot mentioned this pull request Aug 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants