@@ -3,19 +3,24 @@ package pin
33import (
44 "context"
55 "fmt"
6- "log"
76 "os"
87 "path/filepath"
98 "regexp"
109 "strings"
1110
1211 "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- func PinActions (inputYaml string , exemptedActions []string , pinToImmutable bool , actionCommitMap map [string ]string ) (string , bool , error ) {
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 ) {
1924 workflow := metadata.Workflow {}
2025 updated := false
2126 err := yaml .Unmarshal ([]byte (inputYaml ), & workflow )
@@ -30,7 +35,7 @@ func PinActions(inputYaml string, exemptedActions []string, pinToImmutable bool,
3035 for _ , step := range job .Steps {
3136 if len (step .Uses ) > 0 {
3237 localUpdated := false
33- out , localUpdated , err = PinAction (step .Uses , out , exemptedActions , pinToImmutable , actionCommitMap )
38+ out , localUpdated , err = PinAction (step .Uses , out , exemptedActions , pinToImmutable , actionCommitMap , logger )
3439 if err != nil {
3540 return out , updated , err
3641 }
@@ -42,7 +47,7 @@ func PinActions(inputYaml string, exemptedActions []string, pinToImmutable bool,
4247 return out , updated , nil
4348}
4449
45- func PinAction (action , inputYaml string , exemptedActions []string , pinToImmutable bool , actionCommitMap map [string ]string ) (string , bool , error ) {
50+ func PinAction (action , inputYaml string , exemptedActions []string , pinToImmutable bool , actionCommitMap map [string ]string , logger * StepSecurityAppLogger ) (string , bool , error ) {
4651
4752 updated := false
4853 if ! strings .Contains (action , "@" ) || strings .HasPrefix (action , "docker://" ) {
@@ -68,9 +73,17 @@ func PinAction(action, inputYaml string, exemptedActions []string, pinToImmutabl
6873 PAT := os .Getenv ("SECURE_REPO_PAT" )
6974 if PAT == "" {
7075 PAT = os .Getenv ("PAT" )
71- log .Println ("SECURE_REPO_PAT is not set, using 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+ }
7281 } else {
73- log .Println ("SECURE_REPO_PAT is set" )
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+ }
7487 }
7588
7689 ctx := context .Background ()
0 commit comments