@@ -3,24 +3,19 @@ package pin
33import (
44 "context"
55 "fmt"
6+ "log"
67 "os"
78 "path/filepath"
89 "regexp"
910 "strings"
1011
1112 "github.com/google/go-github/v40/github"
12- "github.com/sirupsen/logrus"
1313 metadata "github.com/step-security/secure-repo/remediation/workflow/metadata"
1414 "golang.org/x/oauth2"
1515 "gopkg.in/yaml.v3"
1616)
1717
18- type StepSecurityAppLogger struct {
19- RequestID string `json:"request_id,omitempty"`
20- * logrus.Logger
21- }
22-
23- func PinActions (inputYaml string , exemptedActions []string , pinToImmutable bool , actionCommitMap map [string ]string , logger * StepSecurityAppLogger ) (string , bool , error ) {
18+ func PinActions (inputYaml string , exemptedActions []string , pinToImmutable bool , actionCommitMap map [string ]string ) (string , bool , error ) {
2419 workflow := metadata.Workflow {}
2520 updated := false
2621 err := yaml .Unmarshal ([]byte (inputYaml ), & workflow )
@@ -35,7 +30,7 @@ func PinActions(inputYaml string, exemptedActions []string, pinToImmutable bool,
3530 for _ , step := range job .Steps {
3631 if len (step .Uses ) > 0 {
3732 localUpdated := false
38- out , localUpdated , err = PinAction (step .Uses , out , exemptedActions , pinToImmutable , actionCommitMap , logger )
33+ out , localUpdated , err = PinAction (step .Uses , out , exemptedActions , pinToImmutable , actionCommitMap )
3934 if err != nil {
4035 return out , updated , err
4136 }
@@ -47,9 +42,9 @@ func PinActions(inputYaml string, exemptedActions []string, pinToImmutable bool,
4742 return out , updated , nil
4843}
4944
50- func PinAction (action , inputYaml string , exemptedActions []string , pinToImmutable bool , actionCommitMap map [string ]string , logger * StepSecurityAppLogger ) (string , bool , error ) {
51-
45+ func PinAction (action , inputYaml string , exemptedActions []string , pinToImmutable bool , actionCommitMap map [string ]string ) (string , bool , error ) {
5246 updated := false
47+
5348 if ! strings .Contains (action , "@" ) || strings .HasPrefix (action , "docker://" ) {
5449 return inputYaml , updated , nil // Cannot pin local actions and docker actions
5550 }
@@ -73,17 +68,9 @@ func PinAction(action, inputYaml string, exemptedActions []string, pinToImmutabl
7368 PAT := os .Getenv ("SECURE_REPO_PAT" )
7469 if PAT == "" {
7570 PAT = os .Getenv ("PAT" )
76- if logger != nil {
77- logger .Logf (logrus .InfoLevel , "SECURE_REPO_PAT is not set, using PAT" )
78- } else {
79- logrus .Info ("SECURE_REPO_PAT is not set, using PAT" )
80- }
71+ log .Println ("SECURE_REPO_PAT is not set, using PAT" )
8172 } else {
82- if logger != nil {
83- logger .Logf (logrus .InfoLevel , "SECURE_REPO_PAT is set" )
84- } else {
85- logrus .Info ("SECURE_REPO_PAT is set" )
86- }
73+ log .Println ("SECURE_REPO_PAT is set" )
8774 }
8875
8976 ctx := context .Background ()
@@ -287,3 +274,7 @@ func ActionExists(actionName string, patterns []string) bool {
287274 }
288275 return false
289276}
277+
278+ func UsingSecureRepoPAT () bool {
279+ return os .Getenv ("SECURE_REPO_PAT" ) != ""
280+ }
0 commit comments