Skip to content
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

fix(ci): prevents semgrep from failing on forks #3092

Merged
merged 4 commits into from
Nov 6, 2024

Conversation

jkan2
Copy link
Contributor

@jkan2 jkan2 commented Nov 5, 2024

Description

Similar to #3087 - prevents semgrep from error out on forks

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • Chores
    • Updated the workflow configuration for Semgrep to expand job execution conditions.
    • Maintained existing job structure and triggers for improved functionality.

Copy link
Contributor

coderabbitai bot commented Nov 5, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request modifies the Semgrep workflow configuration within the GitHub Actions setup. The primary change is the adjustment of the conditional statement governing job execution, allowing the job to run under additional circumstances when the repository is 'zeta-chain/node'. The workflow structure remains unchanged, retaining its defined triggers and steps for executing Semgrep, generating JSON findings, converting them to SARIF format, and uploading the results.

Changes

Files Change Summary
.github/workflows/semgrep.yml Updated job execution condition to include 'zeta-chain/node' repository.

Possibly related PRs

Suggested reviewers

  • lumtis
  • swift1337
  • gartnera
  • kingpinXD

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

@github-actions github-actions bot added the ci Changes to CI pipeline or github actions label Nov 5, 2024
@jkan2 jkan2 added no-changelog Skip changelog CI check and removed ci Changes to CI pipeline or github actions labels Nov 5, 2024
@jkan2 jkan2 changed the title prevents semgrep from failing when its coming from a fork fix(ci): prevents semgrep from failing on forks Nov 5, 2024
@github-actions github-actions bot added the ci Changes to CI pipeline or github actions label Nov 5, 2024
@jkan2 jkan2 marked this pull request as ready for review November 5, 2024 06:17
@jkan2 jkan2 requested a review from a team as a code owner November 5, 2024 06:17
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: 1

🧹 Outside diff range and nitpick comments (2)
.github/workflows/semgrep.yml (2)

Line range hint 20-39: Consider adding security measures for SEMGREP_APP_TOKEN.

While the workflow uses a secret for the Semgrep token, additional security measures could be beneficial when dealing with forks.

Recommendations:

  1. Add conditions to protect sensitive operations:
env:
  SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN && github.repository == 'zeta-chain/node' }}
  1. Consider implementing repository-specific conditions for SARIF uploads to ensure security findings are only uploaded for the main repository.
🧰 Tools
🪛 yamllint

[error] 19-19: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)


Add permissions configuration and fork handling for SARIF uploads

The workflow lacks necessary permissions configuration for SARIF uploads and fork handling controls. This could lead to failed security scans on forked repository PRs. Required changes:

  • Add permissions configuration with security-events: write
  • Add fork repository condition similar to other workflows: if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node'

Example implementation:

permissions:
  security-events: write

jobs:
  semgrep:
    # ... existing config ...
    if: (github.actor != 'dependabot[bot]' || github.repository == 'zeta-chain/node') && 
        (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'zeta-chain/node')
🔗 Analysis chain

Line range hint 31-39: Verify SARIF upload permissions in forked repositories.

The SARIF upload step might require specific permissions or fail silently in forked repositories.

Let's verify the GitHub token permissions and potential issues:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for similar workflows in the repository that handle forks
rg -l 'github/codeql-action/upload-sarif' .github/workflows/
# Look for permission configurations
rg -l 'permissions:.*write.*security-events' .github/workflows/

Length of output: 156


Script:

#!/bin/bash
# Check the complete workflow file content to analyze permissions and fork handling
cat .github/workflows/semgrep.yml

# Look for any conditional fork handling in workflows
rg "if.*github.event.pull_request.head.repo.full_name" .github/workflows/

Length of output: 1908

🧰 Tools
🪛 yamllint

[error] 19-19: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 44c377a and faf3c74.

📒 Files selected for processing (1)
  • .github/workflows/semgrep.yml (1 hunks)

.github/workflows/semgrep.yml Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.38%. Comparing base (ad73744) to head (ead743d).
Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3092   +/-   ##
========================================
  Coverage    63.38%   63.38%           
========================================
  Files          422      422           
  Lines        29915    29915           
========================================
  Hits         18963    18963           
  Misses       10111    10111           
  Partials       841      841           

@jkan2 jkan2 enabled auto-merge November 5, 2024 23:23
@jkan2 jkan2 disabled auto-merge November 5, 2024 23:24
@jkan2 jkan2 added this pull request to the merge queue Nov 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 5, 2024
kingpinXD

This comment was marked as resolved.

@jkan2 jkan2 added this pull request to the merge queue Nov 6, 2024
Merged via the queue into develop with commit 234dd87 Nov 6, 2024
39 checks passed
@jkan2 jkan2 deleted the jkan2/update-semgrep-workflow branch November 6, 2024 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Changes to CI pipeline or github actions no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants