Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/docs/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
GitCountContributors = "count-contributors"
Enrich = "sbom-enrich"
UploadCdx = "upload-cdx"
MaliciousScan = "malicious-scan"

// TODO: Deprecated commands (remove at next CLI major version)
AuditMvn = "audit-maven"
Expand Down Expand Up @@ -129,6 +130,7 @@ const (
ScanVuln = scanPrefix + Vuln
SecretValidation = "validate-secrets"
StaticSca = "static-sca"
malProjectKey = Project
scanProjectKey = scanPrefix + Project
uploadProjectKey = UploadCdx + "-" + Project

Expand Down Expand Up @@ -175,6 +177,9 @@ var commandFlags = map[string][]string{
Enrich: {
Url, XrayUrl, user, password, accessToken, ServerId, Threads, InsecureTls,
},
MaliciousScan: {
Url, XrayUrl, user, password, accessToken, ServerId, Threads, InsecureTls, OutputFormat, MinSeverity, AnalyzerManagerCustomPath, WorkingDirs, malProjectKey,
},
BuildScan: {
Url, XrayUrl, user, password, accessToken, ServerId, scanProjectKey, BuildVuln, OutputFormat, Fail, ExtendedTable, Rescan, InsecureTls, TriggerScanRetries,
},
Expand Down Expand Up @@ -256,6 +261,7 @@ var flagsMap = map[string]components.Flag{
scanRegexp: components.NewBoolFlag(RegexpFlag, "Set to true to use a regular expression instead of wildcards expression to collect files to scan."),
scanAnt: components.NewBoolFlag(AntFlag, "Set to true to use an ant pattern instead of wildcards expression to collect files to scan."),
scanProjectKey: components.NewStringFlag(Project, "JFrog project key, to enable Xray to determine security violations accordingly. The command accepts this option only if the --repo-path and --watches options are not provided. If none of the three options are provided, the command will show all known vulnerabilities."),
malProjectKey: components.NewStringFlag(Project, "JFrog project key"),
uploadProjectKey: components.NewStringFlag(Project, "JFrog project key to upload the file to."),
Watches: components.NewStringFlag(Watches, "Comma-separated list of Xray watches to determine violations. Supported violations are CVEs, operational risk, and Licenses. Incompatible with --project and --repo-path."),
RepoPath: components.NewStringFlag(RepoPath, "Artifactory repository path, to enable Xray to determine violations accordingly. The command accepts this option only if the --project and --watches options are not provided. If none of the three options are provided, the command will show all known vulnerabilities."),
Expand Down
13 changes: 13 additions & 0 deletions cli/docs/maliciousscan/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package maliciousscan

import (
"github.com/jfrog/jfrog-cli-core/v2/plugins/components"
)

func GetDescription() string {
return "[Beta] Scan malicious models (pickle files, etc.) located in the working directory."
}

func GetArguments() []components.Argument {
return []components.Argument{}
}
48 changes: 48 additions & 0 deletions cli/scancommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
flags "github.com/jfrog/jfrog-cli-security/cli/docs"
auditSpecificDocs "github.com/jfrog/jfrog-cli-security/cli/docs/auditspecific"
enrichDocs "github.com/jfrog/jfrog-cli-security/cli/docs/enrich"
maliciousScanDocs "github.com/jfrog/jfrog-cli-security/cli/docs/maliciousscan"
mcpDocs "github.com/jfrog/jfrog-cli-security/cli/docs/mcp"
auditDocs "github.com/jfrog/jfrog-cli-security/cli/docs/scan/audit"
buildScanDocs "github.com/jfrog/jfrog-cli-security/cli/docs/scan/buildscan"
Expand All @@ -40,6 +41,7 @@ import (

"github.com/jfrog/jfrog-cli-security/commands/audit"
"github.com/jfrog/jfrog-cli-security/commands/curation"
"github.com/jfrog/jfrog-cli-security/commands/maliciousscan"
"github.com/jfrog/jfrog-cli-security/commands/scan"
"github.com/jfrog/jfrog-cli-security/commands/upload"

Expand Down Expand Up @@ -72,6 +74,15 @@ func getAuditAndScansCommands() []components.Command {
Category: securityCategory,
Action: EnrichCmd,
},
{
Name: "malicious-scan",
Aliases: []string{"ms"},
Flags: flags.GetCommandFlags(flags.MaliciousScan),
Description: maliciousScanDocs.GetDescription(),
Arguments: maliciousScanDocs.GetArguments(),
Category: securityCategory,
Action: MaliciousScanCmd,
},
{
Name: "build-scan",
Aliases: []string{"bs"},
Expand Down Expand Up @@ -230,6 +241,43 @@ func EnrichCmd(c *components.Context) error {
return commandsCommon.Exec(EnrichCmd)
}

func MaliciousScanCmd(c *components.Context) error {
serverDetails, err := CreateServerDetailsFromFlags(c)
if err != nil {
return err
}
if err = validateConnectionInputs(serverDetails); err != nil {
return err
}
format, err := outputFormat.GetOutputFormat(c.GetStringFlagValue(flags.OutputFormat))
if err != nil {
return err
}
threads, err := pluginsCommon.GetThreadsCount(c)
if err != nil {
return err
}
minSeverity, err := getMinimumSeverity(c)
if err != nil {
return err
}
workingDirs := []string{}
if c.GetStringFlagValue(flags.WorkingDirs) != "" {
workingDirs = splitByCommaAndTrim(c.GetStringFlagValue(flags.WorkingDirs))
}
maliciousScanCmd := maliciousscan.NewMaliciousScanCommand().
SetServerDetails(serverDetails).
SetWorkingDirs(workingDirs).
SetThreads(threads).
SetOutputFormat(format).
SetMinSeverityFilter(minSeverity).
SetProject(getProject(c))
if c.IsFlagSet(flags.AnalyzerManagerCustomPath) {
maliciousScanCmd.SetCustomAnalyzerManagerPath(c.GetStringFlagValue(flags.AnalyzerManagerCustomPath))
}
return commandsCommon.Exec(maliciousScanCmd)
}

func ScanCmd(c *components.Context) error {
if len(c.Arguments) == 0 && !c.IsFlagSet(flags.SpecFlag) {
return pluginsCommon.PrintHelpAndReturnError("providing either a <source pattern> argument or the 'spec' option is mandatory", c)
Expand Down
Loading
Loading