@@ -15,6 +15,7 @@ import (
15
15
"github.com/SAP/jenkins-library/pkg/maven"
16
16
"github.com/SAP/jenkins-library/pkg/piperutils"
17
17
"github.com/SAP/jenkins-library/pkg/telemetry"
18
+ "github.com/google/shlex"
18
19
"github.com/pkg/errors"
19
20
)
20
21
@@ -139,6 +140,13 @@ func runCodeqlExecuteScan(config *codeqlExecuteScanOptions, telemetryData *telem
139
140
}
140
141
reports = append (reports , scanReports ... )
141
142
143
+ if len (config .CustomCommand ) > 0 {
144
+ err = runCustomCommand (utils , config .CustomCommand )
145
+ if err != nil {
146
+ return reports , err
147
+ }
148
+ }
149
+
142
150
repoInfo , err := codeql .GetRepoInfo (config .Repository , config .AnalyzedRef , config .CommitID ,
143
151
config .TargetGithubRepoURL , config .TargetGithubBranchName )
144
152
if err != nil {
@@ -394,6 +402,24 @@ func uploadProjectToGitHub(config *codeqlExecuteScanOptions, repoInfo *codeql.Re
394
402
return nil
395
403
}
396
404
405
+ func runCustomCommand (utils codeqlExecuteScanUtils , command string ) error {
406
+ log .Entry ().Infof ("custom command will be run: %s" , command )
407
+ cmd , err := shlex .Split (command )
408
+ if err != nil {
409
+ log .Entry ().WithError (err ).Errorf ("failed to parse custom command %s" , command )
410
+ return err
411
+ }
412
+ log .Entry ().Infof ("Parsed command '%s' with %d arguments: ['%s']" , cmd [0 ], len (cmd [1 :]), strings .Join (cmd [1 :], "', '" ))
413
+
414
+ err = utils .RunExecutable (cmd [0 ], cmd [1 :]... )
415
+ if err != nil {
416
+ log .Entry ().WithError (err ).Errorf ("failed to run command %s" , command )
417
+ return err
418
+ }
419
+ log .Entry ().Info ("Success." )
420
+ return nil
421
+ }
422
+
397
423
func checkForCompliance (scanResults []codeql.CodeqlFindings , config * codeqlExecuteScanOptions , repoInfo * codeql.RepoInfo ) error {
398
424
for _ , scanResult := range scanResults {
399
425
if scanResult .ClassificationName == codeql .AuditAll {
0 commit comments