Skip to content

Commit 38df01f

Browse files
add exemptedActions & pinToImmutable as optional params
1 parent a1871e2 commit 38df01f

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
128128
inputYaml = httpRequest.Body
129129
}
130130

131-
fixResponse, err := workflow.SecureWorkflow(httpRequest.QueryStringParameters, nil, false, inputYaml, dynamoDbSvc)
131+
fixResponse, err := workflow.SecureWorkflow(httpRequest.QueryStringParameters, inputYaml, dynamoDbSvc)
132132

133133
if err != nil {
134134
response = events.APIGatewayProxyResponse{

remediation/workflow/secureworkflow.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@ const (
1313
HardenRunnerActionName = "Harden Runner"
1414
)
1515

16-
func SecureWorkflow(queryStringParams map[string]string, exemptedActions []string, pinToImmutable bool, inputYaml string, svc dynamodbiface.DynamoDBAPI) (*permissions.SecureWorkflowReponse, error) {
16+
func SecureWorkflow(queryStringParams map[string]string, inputYaml string, svc dynamodbiface.DynamoDBAPI, params ...interface{}) (*permissions.SecureWorkflowReponse, error) {
1717
pinActions, addHardenRunner, addPermissions, addProjectComment := true, true, true, true
1818
pinnedActions, addedHardenRunner, addedPermissions := false, false, false
1919
ignoreMissingKBs := false
20+
exemptedActions, pinToImmutable := []string{}, false
21+
if len(params) > 0 {
22+
if v, ok := params[0].([]string); ok {
23+
exemptedActions = v
24+
}
25+
}
26+
if len(params) > 1 {
27+
if v, ok := params[1].(bool); ok {
28+
pinToImmutable = v
29+
}
30+
}
2031

2132
if queryStringParams["pinActions"] == "false" {
2233
pinActions = false

remediation/workflow/secureworkflow_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func TestSecureWorkflow(t *testing.T) {
148148
}
149149
queryParams["addProjectComment"] = "false"
150150

151-
output, err := SecureWorkflow(queryParams, nil, false, string(input), &mockDynamoDBClient{})
151+
output, err := SecureWorkflow(queryParams, string(input), &mockDynamoDBClient{})
152152

153153
if err != nil {
154154
t.Errorf("Error not expected")

0 commit comments

Comments
 (0)