Skip to content

Commit e846bff

Browse files
committed
Malicious code scanner
1 parent ab83514 commit e846bff

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

commands/maliciousscan/maliciousscan.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,11 @@ func (cmd *MaliciousScanCommand) Run() (err error) {
109109
return fmt.Errorf("failed to download Analyzer Manager: %w", err)
110110
}
111111

112-
isRecursiveScan := len(cmd.workingDirs) == 0
113112
workingDirs, err := coreutils.GetFullPathsWorkingDirs(cmd.workingDirs)
114113
if err != nil {
115114
return err
116115
}
117-
logScanPaths(workingDirs, isRecursiveScan)
116+
logScanPaths(workingDirs)
118117

119118
cmdResults := results.NewCommandResults(utils.SourceCode)
120119
cmdResults.SetXrayVersion(xrayVersion)
@@ -123,7 +122,7 @@ func (cmd *MaliciousScanCommand) Run() (err error) {
123122
IncludeVulnerabilities: true,
124123
})
125124

126-
populateScanTargets(cmdResults, workingDirs, isRecursiveScan)
125+
populateScanTargets(cmdResults, workingDirs)
127126

128127
scannerOptions := []jas.JasScannerOption{
129128
jas.WithEnvVars(
@@ -225,22 +224,18 @@ func (cmd *MaliciousScanCommand) Run() (err error) {
225224
return nil
226225
}
227226

228-
func logScanPaths(workingDirs []string, isRecursiveScan bool) {
227+
func logScanPaths(workingDirs []string) {
229228
if len(workingDirs) == 0 {
230229
return
231230
}
232231
if len(workingDirs) == 1 {
233-
if isRecursiveScan {
234-
log.Info("Detecting recursively targets for scan in path:", workingDirs[0])
235-
} else {
236-
log.Info("Scanning path:", workingDirs[0])
237-
}
232+
log.Info("Scanning path:", workingDirs[0])
238233
return
239234
}
240235
log.Info("Scanning paths:", strings.Join(workingDirs, ", "))
241236
}
242237

243-
func populateScanTargets(cmdResults *results.SecurityCommandResults, workingDirs []string, isRecursiveScan bool) {
238+
func populateScanTargets(cmdResults *results.SecurityCommandResults, workingDirs []string) {
244239
for _, requestedDirectory := range workingDirs {
245240
if !fileutils.IsPathExists(requestedDirectory, false) {
246241
log.Warn("The working directory", requestedDirectory, "doesn't exist. Skipping scan...")

jas/maliciouscode/maliciouscodescanner.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ import (
1414
)
1515

1616
const (
17+
maliciousScanCommand = "mal"
18+
1719
MaliciousScannerType MaliciousScanType = "malicious-scan" // #nosec
18-
maliciousScanCommand = "mal"
1920
)
2021

2122
type MaliciousScanType string

0 commit comments

Comments
 (0)