@@ -11,6 +11,11 @@ import (
1111 "github.com/aws/aws-lambda-go/lambda"
1212 "github.com/aws/aws-sdk-go/aws/session"
1313 "github.com/aws/aws-sdk-go/service/dynamodb"
14+ "github.com/step-security/secure-workflows/remediation/dependabot"
15+ "github.com/step-security/secure-workflows/remediation/docker"
16+ "github.com/step-security/secure-workflows/remediation/secrets"
17+ "github.com/step-security/secure-workflows/remediation/workflow"
18+ "github.com/step-security/secure-workflows/remediation/workflow/permissions"
1419)
1520
1621type Handler struct {
@@ -42,7 +47,7 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
4247 if strings .Contains (httpRequest .RawPath , "/secrets" ) {
4348 if httpRequest .RequestContext .HTTP .Method == "GET" {
4449 authHeader := httpRequest .Headers ["authorization" ]
45- githubWorkflowSecrets , err := GetSecrets (httpRequest .QueryStringParameters , authHeader , dynamoDbSvc )
50+ githubWorkflowSecrets , err := secrets . GetSecrets (httpRequest .QueryStringParameters , authHeader , dynamoDbSvc )
4651 if err != nil {
4752 response = events.APIGatewayProxyResponse {
4853 StatusCode : http .StatusInternalServerError ,
@@ -58,7 +63,7 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
5863
5964 } else if httpRequest .RequestContext .HTTP .Method == "PUT" {
6065 authHeader := httpRequest .Headers ["authorization" ]
61- githubWorkflowSecrets , err := InitSecrets (httpRequest .Body , authHeader , dynamoDbSvc )
66+ githubWorkflowSecrets , err := secrets . InitSecrets (httpRequest .Body , authHeader , dynamoDbSvc )
6267 if err != nil {
6368 response = events.APIGatewayProxyResponse {
6469 StatusCode : http .StatusInternalServerError ,
@@ -73,7 +78,7 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
7378 }
7479
7580 } else if httpRequest .RequestContext .HTTP .Method == "POST" {
76- err := SetSecrets (httpRequest .Body , dynamoDbSvc )
81+ err := secrets . SetSecrets (httpRequest .Body , dynamoDbSvc )
7782 if err != nil {
7883 response = events.APIGatewayProxyResponse {
7984 StatusCode : http .StatusInternalServerError ,
@@ -86,7 +91,7 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
8691 }
8792 } else if httpRequest .RequestContext .HTTP .Method == "DELETE" {
8893 authHeader := httpRequest .Headers ["authorization" ]
89- err := DeleteSecrets (authHeader , dynamoDbSvc )
94+ err := secrets . DeleteSecrets (authHeader , dynamoDbSvc )
9095 if err != nil {
9196 response = events.APIGatewayProxyResponse {
9297 StatusCode : http .StatusInternalServerError ,
@@ -107,9 +112,9 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
107112 // if owner is set, assuming that repo, path are also set
108113 // get the workflow using API
109114 if _ , ok := queryStringParams ["owner" ]; ok {
110- inputYaml , err = GetGitHubWorkflowContents (httpRequest .QueryStringParameters )
115+ inputYaml , err = workflow . GetGitHubWorkflowContents (httpRequest .QueryStringParameters )
111116 if err != nil {
112- fixResponse := & SecureWorkflowReponse {WorkflowFetchError : true , HasErrors : true }
117+ fixResponse := & permissions. SecureWorkflowReponse {WorkflowFetchError : true , HasErrors : true }
113118 output , _ := json .Marshal (fixResponse )
114119 response = events.APIGatewayProxyResponse {
115120 StatusCode : http .StatusOK ,
@@ -123,7 +128,7 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
123128 inputYaml = httpRequest .Body
124129 }
125130
126- fixResponse , err := SecureWorkflow (httpRequest .QueryStringParameters , inputYaml , dynamoDbSvc )
131+ fixResponse , err := workflow . SecureWorkflow (httpRequest .QueryStringParameters , inputYaml , dynamoDbSvc )
127132
128133 if err != nil {
129134 response = events.APIGatewayProxyResponse {
@@ -148,9 +153,9 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
148153 // if owner is set, assuming that repo, path are also set
149154 // get the dockerfile using API
150155 if _ , ok := queryStringParams ["owner" ]; ok {
151- dockerFile , err = GetGitHubWorkflowContents (httpRequest .QueryStringParameters )
156+ dockerFile , err = workflow . GetGitHubWorkflowContents (httpRequest .QueryStringParameters )
152157 if err != nil {
153- fixResponse := & SecureDockerfileResponse {DockerfileFetchError : true }
158+ fixResponse := & docker. SecureDockerfileResponse {DockerfileFetchError : true }
154159 output , _ := json .Marshal (fixResponse )
155160 response = events.APIGatewayProxyResponse {
156161 StatusCode : http .StatusOK ,
@@ -164,7 +169,7 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
164169 dockerFile = httpRequest .Body
165170 }
166171
167- fixResponse , err := SecureDockerFile (dockerFile )
172+ fixResponse , err := docker . SecureDockerFile (dockerFile )
168173 if err != nil {
169174 response = events.APIGatewayProxyResponse {
170175 StatusCode : http .StatusInternalServerError ,
@@ -186,7 +191,7 @@ func (h Handler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
186191 updateDependabotConfigRequest := ""
187192 updateDependabotConfigRequest = httpRequest .Body
188193
189- fixResponse , err := UpdateDependabotConfig (updateDependabotConfigRequest )
194+ fixResponse , err := dependabot . UpdateDependabotConfig (updateDependabotConfigRequest )
190195 if err != nil {
191196 response = events.APIGatewayProxyResponse {
192197 StatusCode : http .StatusInternalServerError ,
0 commit comments