Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion remediation/workflow/pin/pinactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func PinAction(action, inputYaml string, exemptedActions []string, pinToImmutabl
// - "actions/checkout@v1"" - Matches (quote delimiter)
// - "actions/checkout@v1" - Matches (quote delimiter)
// - "actions/checkout@v1\n" - Matches (newline is considered whitespace \s)
actionRegex := regexp.MustCompile(`(` + regexp.QuoteMeta(action) + `)($|\s|"|')`)
actionRegex := regexp.MustCompile(`((?:["'])?` + regexp.QuoteMeta(action) + `(?:["'])?)($|\s|"|')`)
inputYaml = actionRegex.ReplaceAllString(inputYaml, pinnedAction+"$2")
yamlWithPreviousActionCommentsRemoved, wasModified := removePreviousActionComments(pinnedAction, inputYaml)
if wasModified {
Expand Down
1 change: 1 addition & 0 deletions remediation/workflow/pin/pinactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ func TestPinActions(t *testing.T) {
{fileName: "immutableaction-1.yml", wantUpdated: true, pinToImmutable: true},
{fileName: "exemptaction.yml", wantUpdated: true, exemptedActions: []string{"actions/checkout", "rohith/*"}, pinToImmutable: true},
{fileName: "donotpintoimmutable.yml", wantUpdated: true, pinToImmutable: false},
{fileName: "invertedcommas.yml", wantUpdated: true, pinToImmutable: false},
}
for _, tt := range tests {
input, err := ioutil.ReadFile(path.Join(inputDirectory, tt.fileName))
Expand Down
15 changes: 15 additions & 0 deletions testfiles/pinactions/input/invertedcommas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "close issue"

on:
push:

jobs:
closeissue:
runs-on: ubuntu-latest

steps:
- name: Close Issue
uses: "peter-evans/close-issue@v1"
with:
issue-number: 1
comment: Auto-closing issue
15 changes: 15 additions & 0 deletions testfiles/pinactions/output/invertedcommas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "close issue"

on:
push:

jobs:
closeissue:
runs-on: ubuntu-latest

steps:
- name: Close Issue
uses: peter-evans/close-issue@a700eac5bf2a1c7a8cb6da0c13f93ed96fd53dbe # v1.0.3
with:
issue-number: 1
comment: Auto-closing issue