Skip to content

[StepSecurity] ci: Harden GitHub Actions #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

step-security-bot
Copy link
Contributor

@step-security-bot step-security-bot commented Dec 16, 2024

Summary

This pull request is created by StepSecurity at the request of @reactive-firewall. Please merge the Pull Request to incorporate the requested changes. Please tag @reactive-firewall on your message if you have any questions related to the PR.

Security Fixes

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.

Feedback For bug reports, feature requests, and general feedback; please email [email protected]. To create such PRs, please visit https://app.stepsecurity.io/securerepo.

Co-authored-by: reactive-firewall [email protected]
Signed-off-by: StepSecurity Bot [email protected]

Summary by CodeRabbit

  • New Features

    • Enhanced error handling for linting processes, providing clearer error messages.
    • Introduced specific permissions for jobs to improve security.
  • Bug Fixes

    • Corrected typographical errors in workflow steps.
  • Chores

    • Updated action versions across multiple workflows for improved functionality and security.

Co-authored-by: reactive-firewall <[email protected]>
Signed-off-by: StepSecurity Bot <[email protected]>
Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request focuses on updating GitHub Actions workflow configurations across multiple files in the .github/workflows/ directory. The primary changes involve updating action versions from generic version tags to specific commit hashes, ensuring precise control over the actions used in various CI/CD workflows. These updates span workflows related to building, testing, documentation, security scanning, and linting, with no significant changes to the underlying workflow logic or structure.

Changes

File Changes
.github/workflows/CI-BUILD.yml Updated actions/checkout and actions/setup-python to specific commit hashes
.github/workflows/CI-DOCS.yml Updated actions/checkout, actions/setup-python, and actions/upload-artifact to specific commit hashes
.github/workflows/CI-MATs.yml Updated actions/checkout and actions/setup-python to specific commit hashes; fixed typo in step name
.github/workflows/Labeler.yml Updated actions/labeler to a specific commit hash
.github/workflows/Tests.yml Updated multiple actions including actions/checkout, actions/setup-python, codecov/codecov-action, actions/upload-artifact, and codecov/test-results-action
.github/workflows/bandit.yml Updated actions/checkout and reactive-firewall/python-bandit-scan to specific commit hashes
.github/workflows/codeql-analysis.yml Updated actions/checkout and GitHub CodeQL actions to specific commit hashes
.github/workflows/yaml-lint.yml Updated actions/checkout and ibiqlik/action-yamllint to specific commit hashes

Possibly related PRs

Suggested labels

documentation, linter

Poem

🐰 Workflow updates, precise and neat,
Commit hashes make our actions complete
Version control with rabbit-like care
Ensuring our pipelines run without a scare
CI/CD magic, smooth and bright! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. This feature will be included in our Pro Plan when released.


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

Copy link

deepsource-io bot commented Dec 16, 2024

Here's the code health analysis summary for commits 8041341..46cbfa8. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link
Contributor

@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

🧹 Nitpick comments (1)
.github/workflows/Tests.yml (1)

Line range hint 1-20: Consider adding timeout to the workflow.

While individual jobs have timeouts set, the workflow itself doesn't have a global timeout. This could be important for security and resource management.

Add a workflow-level timeout:

name: CI-TESTS
# Continuous Integration workflow for post-MATs additional testing, and validating of the project.
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8041341 and 46cbfa8.

📒 Files selected for processing (10)
  • .github/workflows/CI-BUILD.yml (2 hunks)
  • .github/workflows/CI-DOCS.yml (2 hunks)
  • .github/workflows/CI-MATs.yml (1 hunks)
  • .github/workflows/Labeler.yml (1 hunks)
  • .github/workflows/Tests.yml (13 hunks)
  • .github/workflows/bandit.yml (1 hunks)
  • .github/workflows/codeql-analysis.yml (3 hunks)
  • .github/workflows/makefile-lint.yml (1 hunks)
  • .github/workflows/markdown-lint.yml (1 hunks)
  • .github/workflows/yaml-lint.yml (2 hunks)
✅ Files skipped from review due to trivial changes (5)
  • .github/workflows/Labeler.yml
  • .github/workflows/bandit.yml
  • .github/workflows/CI-MATs.yml
  • .github/workflows/codeql-analysis.yml
  • .github/workflows/CI-BUILD.yml
🧰 Additional context used
📓 Path-based instructions (5)
.github/workflows/makefile-lint.yml (1)

Pattern .github/**: * When the project is hosted on GitHub: All GitHub-specific configurations, templates, and tools should be found in the '.github' directory tree.

  • 'actionlint' erroneously generates false positives when dealing with GitHub's ${{ ... }} syntax in conditionals.
  • 'actionlint' erroneously generates incorrect solutions when suggesting the removal of valid ${{ ... }} syntax.
.github/workflows/markdown-lint.yml (1)

Pattern .github/**: * When the project is hosted on GitHub: All GitHub-specific configurations, templates, and tools should be found in the '.github' directory tree.

  • 'actionlint' erroneously generates false positives when dealing with GitHub's ${{ ... }} syntax in conditionals.
  • 'actionlint' erroneously generates incorrect solutions when suggesting the removal of valid ${{ ... }} syntax.
.github/workflows/CI-DOCS.yml (1)

Pattern .github/**: * When the project is hosted on GitHub: All GitHub-specific configurations, templates, and tools should be found in the '.github' directory tree.

  • 'actionlint' erroneously generates false positives when dealing with GitHub's ${{ ... }} syntax in conditionals.
  • 'actionlint' erroneously generates incorrect solutions when suggesting the removal of valid ${{ ... }} syntax.
.github/workflows/yaml-lint.yml (1)

Pattern .github/**: * When the project is hosted on GitHub: All GitHub-specific configurations, templates, and tools should be found in the '.github' directory tree.

  • 'actionlint' erroneously generates false positives when dealing with GitHub's ${{ ... }} syntax in conditionals.
  • 'actionlint' erroneously generates incorrect solutions when suggesting the removal of valid ${{ ... }} syntax.
.github/workflows/Tests.yml (1)

Pattern .github/**: * When the project is hosted on GitHub: All GitHub-specific configurations, templates, and tools should be found in the '.github' directory tree.

  • 'actionlint' erroneously generates false positives when dealing with GitHub's ${{ ... }} syntax in conditionals.
  • 'actionlint' erroneously generates incorrect solutions when suggesting the removal of valid ${{ ... }} syntax.
🔇 Additional comments (10)
.github/workflows/yaml-lint.yml (2)

Line range hint 9-11: LGTM: Proper permissions configuration

The empty permissions block at workflow level with specific read/write permissions at job level follows the principle of least privilege.


23-23: LGTM: Actions properly pinned to commit hashes

All actions are correctly pinned to their full-length commit hashes with version comments:

Also applies to: 27-27, 51-51

.github/workflows/markdown-lint.yml (3)

Line range hint 9-15: LGTM: Proper permissions configuration

The empty permissions block at workflow level with specific read/write permissions at job level follows the principle of least privilege.


21-21: LGTM: Action properly pinned to commit hash

The checkout action is correctly pinned to its full-length commit hash with version comment:


Line range hint 26-39: LGTM: Improved error handling with detailed messages

Good improvement in error handling:

  • Clear error messages with file and line information
  • Proper exit codes for installation failures
  • Separate validation for npm and yamllint
.github/workflows/CI-DOCS.yml (2)

Line range hint 11-11: LGTM: Comprehensive permissions and environment configuration

Excellent security configuration:

  • Empty permissions block at workflow level
  • Detailed job-level permissions following principle of least privilege
  • Environment conditions properly set based on branch/tag context

Also applies to: 23-29


46-46: LGTM: Actions properly pinned to commit hashes

All actions are correctly pinned to their full-length commit hashes with version comments:

Also applies to: 48-48, 74-74

.github/workflows/makefile-lint.yml (1)

35-35: LGTM: Action pinned to specific commit hash.

The actions/checkout action has been correctly pinned to commit hash 11bd71901bbe5b1630ceea73d27597364c9af683 (v4.2.2), which aligns with security best practices.

.github/workflows/Tests.yml (2)

88-90: LGTM: Actions consistently pinned to specific commit hashes.

All GitHub Actions have been correctly pinned to specific commit hashes:

  • actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 (v4.2.2)
  • actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b (v5.3.0)
  • codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e (v5.1.1)
  • actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 (v4.4.3)
  • codecov/test-results-action@9739113ad922ea0a9abb4b2c0f8bf6a4aa8ef820 (v1.0.1)

This consistent approach across all jobs enhances security by preventing supply chain attacks through mutable tags.

Also applies to: 120-120, 130-130, 173-175, 226-228, 270-270, 280-280, 295-295, 345-347, 370-370, 380-380, 421-423, 474-476


Line range hint 28-31: LGTM: Secure default permissions.

The workflow follows the principle of least privilege by setting default permissions to none and explicitly declaring required permissions for each job.

@reactive-firewall reactive-firewall self-assigned this Dec 16, 2024
@reactive-firewall reactive-firewall merged commit 9ceacca into reactive-firewall-org:master Dec 16, 2024
60 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Tooling GitHub Anything Meta Testing Something can be verified
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants