-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkics.go
49 lines (42 loc) · 1.42 KB
/
kics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
*
* This product includes software developed at Datadog (https://www.datadoghq.com) Copyright 2024 Datadog, Inc.
*/
package kics
import (
"path/filepath"
"github.com/Checkmarx/kics/internal/console"
"github.com/Checkmarx/kics/pkg/model"
"github.com/Checkmarx/kics/pkg/scan"
"github.com/rs/zerolog/log"
)
func ExecuteKICSScan(inputPaths []string, outputPath string, sciInfo model.SCIInfo) (scan.ScanMetadata, string) {
params := scan.GetDefaultParameters(outputPath)
params.Path = inputPaths
params.OutputPath = outputPath
params.SCIInfo = sciInfo
metadata, err := console.ExecuteScan(params)
if err != nil {
log.Fatal().Str(
"branch", sciInfo.RepositoryCommitInfo.Branch,
).Str(
"sha", sciInfo.RepositoryCommitInfo.CommitSHA,
).Str(
"repository", sciInfo.RepositoryCommitInfo.RepositoryUrl,
).Msgf("failed to execute scan: %v", err)
return scan.ScanMetadata{}, ""
}
log.Info().Str(
"branch", sciInfo.RepositoryCommitInfo.Branch,
).Str(
"sha", sciInfo.RepositoryCommitInfo.CommitSHA,
).Str(
"repository", sciInfo.RepositoryCommitInfo.RepositoryUrl,
).Msgf(
"Scan completed successfully with metadata: %v", metadata,
)
log.Printf("Scan completed successfully with metadata: %v", metadata)
resultsFile := filepath.Join(outputPath, params.OutputName)
return metadata, resultsFile
}