Skip to content

Commit 405a4cd

Browse files
committed
refactor: Not using context, only SCI infos
Also decided to make te output prettier Corrected a log to make it have an actual level Refs: K9VULN-6211
1 parent 5ad9927 commit 405a4cd

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

kics.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
package kics
88

99
import (
10-
"context"
1110
"fmt"
1211
"path/filepath"
1312

@@ -17,15 +16,15 @@ import (
1716
"github.com/rs/zerolog/log"
1817
)
1918

20-
func ExecuteKICSScan(ctx context.Context, inputPaths []string, outputPath string, sciInfo model.SCIInfo) (scan.ScanMetadata, string, error) {
19+
func ExecuteKICSScan(inputPaths []string, outputPath string, sciInfo model.SCIInfo) (scan.ScanMetadata, string, error) {
2120
extraInfos := map[string]string{
2221
"org": fmt.Sprintf("%d", sciInfo.OrgId),
2322
"branch": sciInfo.RepositoryCommitInfo.Branch,
2423
"sha": sciInfo.RepositoryCommitInfo.CommitSHA,
2524
"repository": sciInfo.RepositoryCommitInfo.RepositoryUrl,
2625
}
2726

28-
params := scan.GetDefaultParameters(outputPath, ctx, extraInfos)
27+
params := scan.GetDefaultParameters(outputPath, extraInfos)
2928
params.Path = inputPaths
3029
params.OutputPath = outputPath
3130
params.SCIInfo = sciInfo

pkg/engine/inspector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func (c *Inspector) Inspect(
284284
if err != nil {
285285
log.Warn().Err(err).Msg("Failed to parse Terraform modules")
286286
}
287-
log.Log().Msgf("Found %d modules", len(parsedModules))
287+
log.Info().Msgf("Found %d modules", len(parsedModules))
288288

289289
// Step 2: Enrich modules with parsed variables
290290
rootDir := "." // or infer from files.RootDir, etc.

pkg/scan/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ type Client struct {
7171
ProBarBuilder *progress.PbBuilder
7272
}
7373

74-
func GetDefaultParameters(rootPath string, ctx context.Context, extraInfos map[string]string) *Parameters {
74+
func GetDefaultParameters(rootPath string, extraInfos map[string]string) *Parameters {
7575

7676
// check for config file and load in relevant params if present
77-
configParams, err := initializeConfig(rootPath, ctx, extraInfos)
77+
configParams, err := initializeConfig(rootPath, extraInfos)
7878
if err != nil {
7979
log.Err(err).Msgf("failed to initialize config %v", err)
8080
return nil

pkg/scan/pre_scan.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package scan
22

33
import (
4-
"context"
54
"os"
65
"path/filepath"
6+
"time"
77

88
consoleHelpers "github.com/Checkmarx/kics/internal/console/helpers"
99
"github.com/Checkmarx/kics/internal/constants"
@@ -37,8 +37,12 @@ func setupConfigFile(rootPath string) (bool, error) {
3737
return false, nil
3838
}
3939

40-
func initializeConfig(rootPath string, ctx context.Context, extraInfos map[string]string) (ConfigParameters, error) {
41-
infos := zerolog.Ctx(log.Logger.WithContext(ctx)).With()
40+
func initializeConfig(rootPath string, extraInfos map[string]string) (ConfigParameters, error) {
41+
baseLogger := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}).
42+
With().
43+
Timestamp().Logger()
44+
45+
infos := (&baseLogger).With()
4246
for k, v := range extraInfos {
4347
infos = infos.Str(k, v)
4448
}

0 commit comments

Comments
 (0)