-
Notifications
You must be signed in to change notification settings - Fork 10
Security: pin GitHub Actions to SHA hashes #77
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 |
|---|---|---|
|
|
@@ -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 incorrectly references 'env.GITHUB_ISSUE_TYPE' and 'env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL'. These variables are not defined in the job's global environment and therefore aren't available to the conditional evaluator. Update the 'if' conditions for the 'Jira Login', 'Extract Jira number', and 'Jira Add comment on issue' steps to use 'steps.github_issue_type.outputs.result' and 'steps.github_issue_has_jira_issue_label.outputs.result' instead. |
||
| 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 The script does not handle cases where the Jira issue key is not found in the title, which will lead to a 'TypeError: Cannot read property '1' of null'. Modify the 'Extract Jira number' script to safely check if the regex match exists before attempting to access the captured group. |
||
| 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 }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ jobs: | |
| - name: Jira Login | ||
| if: env.JIRA_CREATE_ISSUE_AUTO == 'true' | ||
| id: login | ||
| uses: atlassian/gajira-login@v2.0.0 | ||
| uses: atlassian/gajira-login@90a599561baaf8c05b080645ed73db7391c246ed # v2.0.0 | ||
| env: | ||
| JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} | ||
| JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} | ||
|
|
@@ -27,7 +27,7 @@ jobs: | |
| - name: Jira Create issue | ||
| if: env.JIRA_CREATE_ISSUE_AUTO == 'true' | ||
| id: create_jira_issue | ||
| uses: atlassian/gajira-create@v2.0.1 | ||
| uses: atlassian/gajira-create@c0a9c69ac9d6aa063fed57201e55336ada860183 # v2.0.1 | ||
|
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 'summary' input is vulnerable to YAML syntax errors if the issue title contains double quotes. Pass the issue title safely by using a YAML block scalar (>) or by passing it via an environment variable accessed through 'process.env' within the script. |
||
| with: | ||
| project: ${{ secrets.JIRA_PROJECT }} | ||
| issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} | ||
|
|
@@ -53,7 +53,7 @@ jobs: | |
|
|
||
| - name: Update GitHub issue | ||
| if: env.JIRA_CREATE_ISSUE_AUTO == 'true' | ||
| uses: actions/github-script@v2.0.0 | ||
| uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # v2.0.0 | ||
| env: | ||
| JIRA_ISSUE_NUMBER: ${{ steps.create_jira_issue.outputs.issue }} | ||
| GITHUB_ORIGINAL_TITLE: ${{ github.event.issue.title }} | ||
|
|
@@ -78,7 +78,7 @@ jobs: | |
|
|
||
| - name: Add comment after sync | ||
| if: env.JIRA_CREATE_ISSUE_AUTO == 'true' | ||
| uses: actions/github-script@v2.0.0 | ||
| uses: actions/github-script@6e5ee1dc1cb3740e5e5e76ad668e3f526edbfe45 # v2.0.0 | ||
| with: | ||
| github-token: ${{secrets.GITHUB_TOKEN}} | ||
| script: | | ||
|
|
||
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.
🟡 MEDIUM RISK
Suggestion: While pinning actions to a SHA hash is a security best practice, you are pinning to legacy versions (v2.0.0) that use the deprecated Node 12 runtime. Additionally, using direct interpolation like
${{ toJson(...) }}inside thescriptproperty is risky. It is recommended to upgrade to a modern version (like v7) and pass dynamic data through environment variables instead.