Skip to content

Commit

Permalink
Revert "Fix sentence and remove existing action comments (#2067)"
Browse files Browse the repository at this point in the history
This reverts commit 830739d.
  • Loading branch information
varunsh-coder committed Apr 13, 2023
1 parent 830739d commit eadfcec
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@ebacdc22ef6c2cfb85ee5ded8f2e640f4c776dd5
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout repository
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kbanalysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@ebacdc22ef6c2cfb85ee5ded8f2e640f4c776dd5
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@d0651293c4a5a52e711f25b41b05b2212f385d28
with:
Expand Down
2 changes: 1 addition & 1 deletion remediation/workflow/hardenrunner/addaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func addAction(inputYaml, jobName, action string) (string, error) {
output = append(output, spaces+fmt.Sprintf("- name: %s", HardenRunnerActionName))
output = append(output, spaces+fmt.Sprintf(" uses: %s", action))
output = append(output, spaces+" with:")
output = append(output, spaces+" egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs")
output = append(output, spaces+" egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs")
output = append(output, "")

for i := jobNode.Line - 1; i < len(inputLines); i++ {
Expand Down
7 changes: 0 additions & 7 deletions remediation/workflow/pin/pinactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ func PinAction(action, inputYaml string) (string, bool) {
pinnedAction := fmt.Sprintf("%s@%s # %s", leftOfAt[0], commitSHA, tagOrBranch)
updated = !strings.EqualFold(action, pinnedAction)
inputYaml = strings.ReplaceAll(inputYaml, action, pinnedAction)
stringParts := strings.SplitN(inputYaml, pinnedAction, 2)
if len(stringParts) > 1 {
trimmedString := strings.SplitN(stringParts[1], "\n", 2)
if len(trimmedString) > 1 {
inputYaml = stringParts[0] + pinnedAction + "\n" + trimmedString[1]
}
}
return inputYaml, updated
}

Expand Down
1 change: 0 additions & 1 deletion remediation/workflow/pin/pinactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ func TestPinActions(t *testing.T) {
{fileName: "basic.yml", wantUpdated: true},
{fileName: "dockeraction.yml", wantUpdated: true},
{fileName: "multipleactions.yml", wantUpdated: true},
{fileName: "actionwithcomment.yml", wantUpdated: true},
}
for _, tt := range tests {
input, err := ioutil.ReadFile(path.Join(inputDirectory, tt.fileName))
Expand Down
2 changes: 1 addition & 1 deletion testfiles/addaction/input/alreadypresent_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- run: ls -R
4 changes: 2 additions & 2 deletions testfiles/addaction/output/2jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- run: ls -R
list-directory1:
Expand All @@ -17,6 +17,6 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- run: ls -R
2 changes: 1 addition & 1 deletion testfiles/addaction/output/action-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Close Issue
uses: peter-evans/close-issue@v1
Expand Down
2 changes: 1 addition & 1 deletion testfiles/addaction/output/alreadypresent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- run: ls -R
2 changes: 1 addition & 1 deletion testfiles/addaction/output/alreadypresent_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- run: ls -R
29 changes: 0 additions & 29 deletions testfiles/pinactions/input/actionwithcomment.yml

This file was deleted.

29 changes: 0 additions & 29 deletions testfiles/pinactions/output/actionwithcomment.yml

This file was deleted.

2 changes: 1 addition & 1 deletion testfiles/secureworkflow/output/allscenarios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@ebacdc22ef6c2cfb85ee5ded8f2e640f4c776dd5 # v2.0.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@544eadc6bf3d226fd7a7a9f0dc5b5bf7ca0675b9 # v1.2.0
- uses: github/super-linter@34b2f8032d759425f6b42ea2e52231b33ae05401 # v3.17.1
Expand Down
2 changes: 1 addition & 1 deletion testfiles/secureworkflow/output/missingaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@ebacdc22ef6c2cfb85ee5ded8f2e640f4c776dd5 # v2.0.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/missingaction@v2
- uses: github/super-linter@34b2f8032d759425f6b42ea2e52231b33ae05401 # v3.17.1
Expand Down
2 changes: 1 addition & 1 deletion testfiles/secureworkflow/output/noperms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@ebacdc22ef6c2cfb85ee5ded8f2e640f4c776dd5 # v2.0.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@544eadc6bf3d226fd7a7a9f0dc5b5bf7ca0675b9 # v1.2.0
- uses: github/super-linter@34b2f8032d759425f6b42ea2e52231b33ae05401 # v3.17.1
Expand Down
2 changes: 1 addition & 1 deletion testfiles/secureworkflow/output/nopin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after a couple of runs
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@v1
- uses: github/super-linter@v3
Expand Down

0 comments on commit eadfcec

Please sign in to comment.