Skip to content

Commit

Permalink
Merge pull request #2044 from Devils-Knight/updateSecure
Browse files Browse the repository at this point in the history
Update SecureWorkflow function to Handle Empty File input
  • Loading branch information
ashishkurmi authored Mar 29, 2023
2 parents 4af0234 + ff05a33 commit 03f4760
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions remediation/workflow/permissions/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ func AddWorkflowLevelPermissions(inputYaml string, addProjectComment bool) (stri
line := 0
column := 0
topNode := t.Content
if len(topNode) == 0 {
return inputYaml, fmt.Errorf("Workflow file provided is Empty")
}
for _, n := range topNode[0].Content {
if n.Value == "jobs" && n.Tag == "!!str" {
line = n.Line
Expand Down
1 change: 1 addition & 0 deletions remediation/workflow/secureworkflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func TestSecureWorkflow(t *testing.T) {
{fileName: "nopin.yml", wantPinnedActions: false, wantAddedHardenRunner: true, wantAddedPermissions: true},
{fileName: "allperms.yml", wantPinnedActions: false, wantAddedHardenRunner: false, wantAddedPermissions: true},
{fileName: "multiplejobperms.yml", wantPinnedActions: false, wantAddedHardenRunner: false, wantAddedPermissions: true},
{fileName: "error.yml", wantPinnedActions: false, wantAddedHardenRunner: false, wantAddedPermissions: false},
}
for _, test := range tests {
input, err := ioutil.ReadFile(path.Join(inputDirectory, test.fileName))
Expand Down
Empty file.
Empty file.

0 comments on commit 03f4760

Please sign in to comment.