-
Notifications
You must be signed in to change notification settings - Fork 2
Security: pin GitHub Actions to SHA hashes #25
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
base: master
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ jobs: | |
| - name: Check GitHub Issue type | ||
| if: env.JIRA_CREATE_COMMENT_AUTO == 'true' | ||
| id: github_issue_type | ||
| uses: actions/github-script@v2.0.0 | ||
| uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # v2.0.0 | ||
| with: | ||
| result-encoding: string | ||
| script: | | ||
|
|
@@ -33,7 +33,7 @@ jobs: | |
| - name: Check if GitHub Issue has JIRA_ISSUE_LABEL | ||
| if: env.JIRA_CREATE_COMMENT_AUTO == 'true' | ||
| id: github_issue_has_jira_issue_label | ||
| uses: actions/github-script@v2.0.0 | ||
| uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # v2.0.0 | ||
| env: | ||
| JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} | ||
| with: | ||
|
|
@@ -56,7 +56,7 @@ jobs: | |
| - name: Jira Login | ||
| if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' | ||
| id: login | ||
| uses: atlassian/gajira-login@v2.0.0 | ||
| uses: atlassian/gajira-login@90a599561baaf8c05b080645ed73db7391c246ed # v2.0.0 | ||
|
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. 🔴 HIGH RISK The 'if' condition for this step relies on environment variables defined at the step level (e.g., env.GITHUB_ISSUE_TYPE). In GitHub Actions, 'if' conditionals are evaluated before the step-level environment is set up, meaning these variables will be undefined and the step will be skipped. Access the previous steps' outputs directly using the 'steps' context instead (e.g., 'steps.github_issue_type.outputs.result'). |
||
| env: | ||
| GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} | ||
| GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} | ||
|
|
@@ -67,7 +67,7 @@ jobs: | |
| - name: Extract Jira number | ||
| if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' | ||
| id: extract_jira_number | ||
| uses: actions/github-script@v2.0.0 | ||
| uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # v2.0.0 | ||
|
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. 🟡 MEDIUM RISK Suggestion: Add a check to ensure the regex match is successful before accessing the capture group. Currently, if the issue title does not match the expected pattern, 'match()' will return null and the workflow will fail with a TypeError when accessing index [1]. |
||
| env: | ||
| GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} | ||
| GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} | ||
|
|
@@ -82,7 +82,7 @@ jobs: | |
| - name: Jira Add comment on issue | ||
| if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' | ||
| id: add_comment_jira_issue | ||
| uses: atlassian/gajira-comment@v2.0.2 | ||
| uses: atlassian/gajira-comment@8ec356b5df49f1325653db7ee2da2b59a1d78203 # v2.0.2 | ||
| env: | ||
| GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} | ||
| GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} | ||
|
|
||
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.
🔴 HIGH RISK
This script block contains a high-risk code injection vulnerability by directly interpolating GitHub context values using
${{ }}. Pass context data (like labels or titles) through the 'env' block and access them via 'process.env' instead. Additionally, 'actions/github-script@v2' is deprecated as it relies on the end-of-life Node 12 runtime; consider upgrading to v7 (SHA 60a0d83039c74a4aee543508d2ff4a7df0bd5ad0) to ensure compatibility with modern runners.