Skip to content

Commit 1a3db37

Browse files
Merge pull request #2552 from vamshi-stepsecurity/bug/wild-card-for-action
add more test cases
2 parents b713701 + b05907c commit 1a3db37

File tree

7 files changed

+57
-1
lines changed

7 files changed

+57
-1
lines changed

remediation/workflow/pin/pinactions_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ func TestPinActions(t *testing.T) {
3333
}
3434
]`))
3535

36+
httpmock.RegisterResponder("GET", "https://api.github.com/repos/evans/shield/commits/v1",
37+
httpmock.NewStringResponder(200, `a700eac5bf2a1c7a8cb6da0c13f93ed96fd53dbd`))
38+
39+
httpmock.RegisterResponder("GET", "https://api.github.com/repos/evans/shield/git/matching-refs/tags/v1.",
40+
httpmock.NewStringResponder(200,
41+
`[
42+
{
43+
"ref": "refs/tags/v1.0.3",
44+
"object": {
45+
"sha": "a700eac5bf2a1c7a8cb6da0c13f93ed96fd53dbd",
46+
"type": "commit"
47+
}
48+
}
49+
]`))
50+
3651
httpmock.RegisterResponder("GET", "https://api.github.com/repos/actions/checkout/commits/master",
3752
httpmock.NewStringResponder(200, `61b9e3751b92087fd0b06925ba6dd6314e06f089`))
3853

@@ -308,7 +323,7 @@ func TestPinActions(t *testing.T) {
308323
{fileName: "actionwithcomment.yml", wantUpdated: true, pinToImmutable: true},
309324
{fileName: "repeatedactionwithcomment.yml", wantUpdated: true, pinToImmutable: true},
310325
{fileName: "immutableaction-1.yml", wantUpdated: true, pinToImmutable: true},
311-
{fileName: "exemptaction.yml", wantUpdated: true, exemptedActions: []string{"actions/checkout", "rohith/*", "praveen/*", "aman-*/*", "*/seperate*"}, pinToImmutable: true},
326+
{fileName: "exemptaction.yml", wantUpdated: true, exemptedActions: []string{"actions/checkout", "rohith/*", "praveen/*", "aman-*/*", "*/seperate*", "starc/*"}, pinToImmutable: true},
312327
{fileName: "donotpintoimmutable.yml", wantUpdated: true, pinToImmutable: false},
313328
{fileName: "invertedcommas.yml", wantUpdated: true, pinToImmutable: false},
314329
{fileName: "pinusingmap.yml", wantUpdated: true, pinToImmutable: true},
@@ -330,6 +345,7 @@ func TestPinActions(t *testing.T) {
330345
actionCommitMap = map[string]string{
331346
"peter-evans-test/close-issue@v1": "a700eac5bf2a1c7a8cb6da0c13f93ed96fd53vam",
332347
"peter-check/[email protected]": "a700eac5bf2a1c7a8cb6da0c13f93ed96fd53tom",
348+
"evans/shield-test/@v1.2.5": "a700eac5bf2a1c7a8cb6da0c13f93ed96fd53cat",
333349
}
334350
}
335351

testfiles/pinactions/input/basic.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ jobs:
1111
steps:
1212
- name: Close Issue
1313
uses: peter-evans/close-issue@v1
14+
with:
15+
issue-number: 1
16+
comment: Auto-closing issue
17+
18+
- name: test case
19+
uses: evans/shield/@v1
1420
with:
1521
issue-number: 1
1622
comment: Auto-closing issue

testfiles/pinactions/input/exemptaction.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ jobs:
6262
- name: publish on version change 2
6363
id: publish_nuget
6464
uses: smith/seperate/from-version@v2
65+
with:
66+
PROJECT_FILE_PATH: Core/Core.csproj
67+
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}
68+
NUGET_SOURCE: https://nuget.pkg.github.com/OWNER/index.json
69+
70+
- name: publish on version change 2
71+
id: publish_nuget
72+
uses: starc/swing/from-version/@v2
6573
with:
6674
PROJECT_FILE_PATH: Core/Core.csproj
6775
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}

testfiles/pinactions/input/pinusingmap.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ jobs:
2323

2424
- name: Close Issue
2525
uses: peter-check/[email protected]
26+
with:
27+
issue-number: 1
28+
comment: Auto-closing issue
29+
30+
- name: test case
31+
uses: evans/shield-test/@v1.2.5
2632
with:
2733
issue-number: 1
2834
comment: Auto-closing issue

testfiles/pinactions/output/basic.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ jobs:
1111
steps:
1212
- name: Close Issue
1313
uses: peter-evans/close-issue@a700eac5bf2a1c7a8cb6da0c13f93ed96fd53dbe # v1.0.3
14+
with:
15+
issue-number: 1
16+
comment: Auto-closing issue
17+
18+
- name: test case
19+
uses: evans/shield/@a700eac5bf2a1c7a8cb6da0c13f93ed96fd53dbd # v1.0.3
1420
with:
1521
issue-number: 1
1622
comment: Auto-closing issue

testfiles/pinactions/output/exemptaction.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ jobs:
6262
- name: publish on version change 2
6363
id: publish_nuget
6464
uses: smith/seperate/from-version@v2
65+
with:
66+
PROJECT_FILE_PATH: Core/Core.csproj
67+
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}
68+
NUGET_SOURCE: https://nuget.pkg.github.com/OWNER/index.json
69+
70+
- name: publish on version change 2
71+
id: publish_nuget
72+
uses: starc/swing/from-version/@v2
6573
with:
6674
PROJECT_FILE_PATH: Core/Core.csproj
6775
NUGET_KEY: ${{ secrets.GITHUB_TOKEN }}

testfiles/pinactions/output/pinusingmap.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ jobs:
2323

2424
- name: Close Issue
2525
uses: peter-check/close-issue@a700eac5bf2a1c7a8cb6da0c13f93ed96fd53tom # v1.2.3
26+
with:
27+
issue-number: 1
28+
comment: Auto-closing issue
29+
30+
- name: test case
31+
uses: evans/shield-test/@a700eac5bf2a1c7a8cb6da0c13f93ed96fd53cat # v1.2.5
2632
with:
2733
issue-number: 1
2834
comment: Auto-closing issue

0 commit comments

Comments
 (0)