-
Notifications
You must be signed in to change notification settings - Fork 246
fix: remove pull request target from cla - BED-7555 #197
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ name: "CLA Assistant" | |||||||||||||||||||||
| on: | ||||||||||||||||||||||
| issue_comment: | ||||||||||||||||||||||
| types: [created, edited] | ||||||||||||||||||||||
| pull_request_target: | ||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||
| types: [opened,closed,synchronize] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||
|
|
@@ -33,7 +33,7 @@ jobs: | |||||||||||||||||||||
| echo "org_members=$ALL_MEMBERS" >> $GITHUB_OUTPUT | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - name: "CLA Assistant" | ||||||||||||||||||||||
| if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' | ||||||||||||||||||||||
| if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request' | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n .github/workflows/cla.ymlRepository: SpecterOps/SharpHound Length of output: 2157 Scope The condition at line 36 can execute on regular issue comments matching the phrase, not just PR comments. When the Add Suggested condition hardening- if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request'
+ if: |
+ (
+ github.event_name == 'issue_comment' &&
+ github.event.issue.pull_request &&
+ (
+ github.event.comment.body == 'recheck' ||
+ github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA'
+ )
+ ) || github.event_name == 'pull_request'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| uses: contributor-assistant/github-action@v2.2.1 | ||||||||||||||||||||||
| env: | ||||||||||||||||||||||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ jobs: | |
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Run vulnerability scanner | ||
| uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1 | ||
| uses: aquasecurity/trivy-action@0.34.2 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n .github/workflows/vuln-scan.yml | head -30Repository: SpecterOps/SharpHound Length of output: 1009 🌐 Web query:
💡 Result: Pinning
|
||
| with: | ||
| scan-type: "repo" | ||
| scan-ref: "./" | ||
|
|
@@ -26,4 +26,4 @@ jobs: | |
| ignore-unfixed: true | ||
| env: | ||
| TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db | ||
| TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db | ||
| TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db,public.ecr.aws/aquasecurity/trivy-java-db | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
GitHub Actions pull_request event fork repository secrets availability💡 Result:
For workflows triggered by the
pull_requestevent where the PR comes from a fork:GITHUB_TOKEN. [1]GITHUB_TOKENis restricted (effectively read-only) for PRs from forks, even if you normally grant broader permissions. [2]If you need secrets for PR-related automation, GitHub provides
pull_request_target:pull_request_targetruns in the context of the base (target) repository, using the workflow from the base branch, and it can access repository secrets (and typically has elevated token permissions). This is why it can be used for things like labeling/commenting on PRs. [3]pull_request_targetworkflow unless you’ve designed the workflow to prevent “pwn request” style attacks. [3]Dependabot note: workflows triggered by Dependabot PRs are treated like fork PRs for these restrictions (read-only token, no secrets) when using events like
pull_request. [2]Sources: [1] GitHub Docs – Using secrets in GitHub Actions; [2] GitHub Changelog – Dependabot PR workflows run with read-only permissions / no secrets; [3] GitHub Well-Architected – Avoid
pull_request_target(privileged, secrets available).🏁 Script executed:
cat -n .github/workflows/cla.yml | head -50Repository: SpecterOps/SharpHound
Length of output: 2157
pull_requesttrigger breaks CLA checks for forked PRs—repository secrets unavailable.Switching to
pull_requestmeans PRs from forks won't receiveREAD_MEMBERS_SCOPE(Line 19) orREPO_SCOPE(Line 40) repository secrets. GitHub Actions explicitly excludes non-GITHUB_TOKENsecrets frompull_requestevents originating from forks as a security measure. This causes the CLA Assistant step to fail silently.To restore functionality while maintaining security:
Suggested fix
jobs: CLAssistant: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false runs-on: ubuntu-latestThis skips the CLA check for fork PRs (preventing secret errors) while allowing recheck via
issue_commentand running normally for base-repo PRs.🤖 Prompt for AI Agents