Skip to content

Commit f7e72df

Browse files
authored
Merge branch 'dev' into docker-curation-supprot
2 parents b4a4d26 + bdfcc88 commit f7e72df

File tree

77 files changed

+6595
-3236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+6595
-3236
lines changed

.github/actions/install-and-setup/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ runs:
1212
steps:
1313
# Install dependencies
1414
- name: Setup Go
15-
uses: actions/setup-go@v6
15+
uses: actions/setup-go@v5
1616
with:
17-
go-version: 1.24.x
17+
go-version: 1.25
1818
# - name: Setup Go with cache
1919
# uses: jfrog/.github/actions/install-go-with-cache@main
2020

@@ -39,7 +39,7 @@ runs:
3939
uses: actions/setup-java@v5
4040
with:
4141
java-version: "11"
42-
distribution: "adopt"
42+
distribution: "corretto"
4343
- name: Setup Gradle
4444
uses: gradle/actions/setup-gradle@v3
4545
with:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ concurrency:
2323
# Environment variables shared across all jobs.
2424
env:
2525
GOPROXY: direct
26-
GO_COMMON_TEST_ARGS: "-v github.com/jfrog/jfrog-cli-security --race --timeout 30m --jfrog.url=${{ secrets.PLATFORM_URL }} --jfrog.adminToken=${{ secrets.PLATFORM_ADMIN_TOKEN }} --test.containerRegistry=${{ secrets.CONTAINER_REGISTRY }}"
26+
GO_COMMON_TEST_ARGS: "-v github.com/jfrog/jfrog-cli-security --race --timeout 40m --jfrog.url=${{ secrets.PLATFORM_URL }} --jfrog.adminToken=${{ secrets.PLATFORM_ADMIN_TOKEN }} --test.containerRegistry=${{ secrets.CONTAINER_REGISTRY }}"
2727
GRADLE_OPTS: -Dorg.gradle.daemon=false
2828
CI: true
2929
JFROG_CLI_LOG_LEVEL: DEBUG

artifactory_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestDependencyResolutionFromArtifactory(t *testing.T) {
119119
for _, testCase := range testCases {
120120
t.Run(testCase.projectType.String(), func(t *testing.T) {
121121
if testCase.skipMsg != "" {
122-
securityTestUtils.SkipTestIfDurationNotPassed(t, "22-10-2025", 30, testCase.skipMsg)
122+
securityTestUtils.SkipTestIfDurationNotPassed(t, "22-11-2025", 30, testCase.skipMsg)
123123
}
124124
testSingleTechDependencyResolution(t, testCase.testProjectPath, testCase.resolveRepoName, testCase.cacheRepoName, testCase.projectType)
125125
})

audit_test.go

Lines changed: 97 additions & 67 deletions
Large diffs are not rendered by default.

cli/docs/flags.go

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ const (
6464
const (
6565
// Base flags keys
6666
ServerId = "server-id"
67-
url = "url"
68-
xrayUrl = "xray-url"
67+
Url = "url"
68+
XrayUrl = "xray-url"
6969
user = "user"
7070
password = "password"
7171
accessToken = "access-token"
@@ -105,6 +105,7 @@ const (
105105
Watches = "watches"
106106
RepoPath = "repo-path"
107107
UploadRepoPath = "rt-" + RepoPath
108+
UploadRtRepoPath = "upload-" + UploadRepoPath
108109
Licenses = "licenses"
109110
Sbom = "sbom"
110111
Fail = "fail"
@@ -159,38 +160,38 @@ var commandFlags = map[string][]string{
159160
XrCurl: {ServerId},
160161
OfflineUpdate: {LicenseId, From, To, Version, Target, Stream, Periodic},
161162
XrScan: {
162-
url, user, password, accessToken, ServerId, SpecFlag, Threads, scanRecursive, scanRegexp, scanAnt,
163+
Url, user, password, accessToken, ServerId, SpecFlag, Threads, scanRecursive, scanRegexp, scanAnt,
163164
scanProjectKey, Watches, RepoPath, Licenses, Sbom, OutputFormat, Fail, ExtendedTable, BypassArchiveLimits, MinSeverity, FixableOnly, ScanVuln, InsecureTls,
164165
},
165166
Enrich: {
166-
url, user, password, accessToken, ServerId, Threads, InsecureTls,
167+
Url, user, password, accessToken, ServerId, Threads, InsecureTls,
167168
},
168169
BuildScan: {
169-
url, user, password, accessToken, ServerId, scanProjectKey, BuildVuln, OutputFormat, Fail, ExtendedTable, Rescan, InsecureTls, TriggerScanRetries,
170+
Url, user, password, accessToken, ServerId, scanProjectKey, BuildVuln, OutputFormat, Fail, ExtendedTable, Rescan, InsecureTls, TriggerScanRetries,
170171
},
171172
DockerScan: {
172-
url, xrayUrl, user, password, accessToken, ServerId, scanProjectKey, Watches, RepoPath, Licenses, Sbom, OutputFormat, Fail, ExtendedTable, BypassArchiveLimits, MinSeverity, FixableOnly, ScanVuln, SecretValidation, InsecureTls,
173+
Url, XrayUrl, user, password, accessToken, ServerId, scanProjectKey, Watches, RepoPath, Licenses, Sbom, OutputFormat, Fail, ExtendedTable, BypassArchiveLimits, MinSeverity, FixableOnly, ScanVuln, SecretValidation, InsecureTls,
173174
},
174175
Audit: {
175-
url, xrayUrl, user, password, accessToken, ServerId, InsecureTls, scanProjectKey, Watches, RepoPath, Sbom, Licenses, OutputFormat, ExcludeTestDeps,
176+
Url, XrayUrl, user, password, accessToken, ServerId, InsecureTls, scanProjectKey, Watches, RepoPath, Sbom, Licenses, OutputFormat, ExcludeTestDeps,
176177
useWrapperAudit, DepType, RequirementsFile, Fail, ExtendedTable, WorkingDirs, ExclusionsAudit, Mvn, Gradle, Npm,
177178
Pnpm, Yarn, Go, Swift, Cocoapods, Nuget, Pip, Pipenv, Poetry, MinSeverity, FixableOnly, ThirdPartyContextualAnalysis, Threads,
178179
Sca, Iac, Sast, Secrets, WithoutCA, ScanVuln, SecretValidation, OutputDir, SkipAutoInstall, AllowPartialResults, MaxTreeDepth,
179-
StaticSca, XrayLibPluginBinaryCustomPath, AnalyzerManagerCustomPath, AddSastRules,
180+
StaticSca, XrayLibPluginBinaryCustomPath, AnalyzerManagerCustomPath, UploadRtRepoPath,
180181
},
181182
UploadCdx: {
182183
UploadRepoPath, uploadProjectKey,
183184
},
184185
GitAudit: {
185186
// Connection params
186-
url, xrayUrl, user, password, accessToken, ServerId, InsecureTls,
187+
Url, XrayUrl, user, password, accessToken, ServerId, InsecureTls,
187188
// Violations params
188189
scanProjectKey, Watches, ScanVuln, Fail,
189190
// Scan params
190191
Threads, ExclusionsAudit,
191-
Sca, Iac, Sast, Secrets, WithoutCA, SecretValidation,
192+
Sca, Iac, Sast, Secrets, WithoutCA, SecretValidation, Sbom,
192193
// Output params
193-
Licenses, OutputFormat, ExtendedTable, OutputDir,
194+
Licenses, OutputFormat, ExtendedTable, OutputDir, UploadRtRepoPath,
194195
// Scan Logic params
195196
StaticSca, XrayLibPluginBinaryCustomPath, AnalyzerManagerCustomPath, AddSastRules,
196197
},
@@ -202,31 +203,31 @@ var commandFlags = map[string][]string{
202203
},
203204
// TODO: Deprecated commands (remove at next CLI major version)
204205
AuditMvn: {
205-
url, user, password, accessToken, ServerId, InsecureTls, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable, useWrapperAudit,
206+
Url, user, password, accessToken, ServerId, InsecureTls, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable, useWrapperAudit,
206207
},
207208
AuditGradle: {
208-
url, user, password, accessToken, ServerId, ExcludeTestDeps, ExclusionsAudit, useWrapperAudit, scanProjectKey, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
209+
Url, user, password, accessToken, ServerId, ExcludeTestDeps, ExclusionsAudit, useWrapperAudit, scanProjectKey, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
209210
},
210211
AuditNpm: {
211-
url, user, password, accessToken, ServerId, DepType, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
212+
Url, user, password, accessToken, ServerId, DepType, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
212213
},
213214
AuditGo: {
214-
url, user, password, accessToken, ServerId, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
215+
Url, user, password, accessToken, ServerId, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
215216
},
216217
AuditPip: {
217-
url, user, password, accessToken, ServerId, RequirementsFile, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
218+
Url, user, password, accessToken, ServerId, RequirementsFile, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
218219
},
219220
AuditPipenv: {
220-
url, user, password, accessToken, ServerId, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, ExtendedTable,
221+
Url, user, password, accessToken, ServerId, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, ExtendedTable,
221222
},
222223
}
223224

224225
// Security Flag keys mapped to their corresponding components.Flag definition.
225226
var flagsMap = map[string]components.Flag{
226227
// Common commands flags
227228
ServerId: components.NewStringFlag(ServerId, "Server ID configured using the config command."),
228-
url: components.NewStringFlag(url, "JFrog URL."),
229-
xrayUrl: components.NewStringFlag(xrayUrl, "JFrog Xray URL."),
229+
Url: components.NewStringFlag(Url, "JFrog URL."),
230+
XrayUrl: components.NewStringFlag(XrayUrl, "JFrog Xray URL."),
230231
user: components.NewStringFlag(user, "JFrog username."),
231232
password: components.NewStringFlag(password, "JFrog password."),
232233
accessToken: components.NewStringFlag(accessToken, "JFrog access token."),
@@ -261,7 +262,7 @@ var flagsMap = map[string]components.Flag{
261262
MinSeverity: components.NewStringFlag(MinSeverity, "Set the minimum severity of issues to display. Acceptable values: Low, Medium, High, or Critical."),
262263
FixableOnly: components.NewBoolFlag(FixableOnly, "Set to true if you wish to display issues that have a fix version only."),
263264
Rescan: components.NewBoolFlag(Rescan, "Set to true when scanning an already successfully scanned build, for example after adding an ignore rule."),
264-
TriggerScanRetries: components.NewStringFlag(TriggerScanRetries, "Number of retries for triggering the build scan in Xray in case of failure.", components.WithIntDefaultValue(12)), // 5 seconds * 12 = 1 minute
265+
TriggerScanRetries: components.NewStringFlag(TriggerScanRetries, "Defines how many times Xray retries triggering the build scan after a failure.", components.WithIntDefaultValue(12)), // 5 seconds * 12 = 1 minute
265266
BuildVuln: components.NewBoolFlag(Vuln, "Set to true if you'd like to receive all vulnerabilities, regardless of the policy configured in Xray. Ignored if provided 'format' is 'sarif'."),
266267
ScanVuln: components.NewBoolFlag(Vuln, "Set to true if you'd like to receive all vulnerabilities, regardless of the policy configured in Xray."),
267268
InsecureTls: components.NewBoolFlag(InsecureTls, "Set to true to skip TLS certificates verification."),
@@ -274,6 +275,7 @@ var flagsMap = map[string]components.Flag{
274275
WorkingDirs: components.NewStringFlag(WorkingDirs, "A comma-separated(,) list of relative working directories, to determine the audit targets locations. If flag isn't provided, a recursive scan is triggered from the root directory of the project."),
275276
OutputDir: components.NewStringFlag(OutputDir, "Target directory to save partial results to.", components.SetHiddenStrFlag()),
276277
UploadRepoPath: components.NewStringFlag(UploadRepoPath, "Artifactory repository name or path to upload the cyclonedx file to. If no name or path are provided, a local generic repository will be created which will automatically be indexed by Xray.", components.WithStrDefaultValue("import-cdx-scan-results")),
278+
UploadRtRepoPath: components.NewStringFlag(UploadRtRepoPath, fmt.Sprintf("Artifactory repository name or path to upload the scan results to. If no name or path are provided, a local generic repository will be created which will automatically be indexed by Xray. only relevant when using --%s", StaticSca), components.WithStrDefaultValue("cli-scan-results")),
277279
SkipAutoInstall: components.NewBoolFlag(SkipAutoInstall, "Set to true to skip auto-install of dependencies in un-built modules. Currently supported for Yarn and NPM only.", components.SetHiddenBoolFlag()),
278280
AllowPartialResults: components.NewBoolFlag(AllowPartialResults, "Set to true to allow partial results and continuance of the scan in case of certain errors.", components.SetHiddenBoolFlag()),
279281
ExclusionsAudit: components.NewStringFlag(
@@ -319,9 +321,10 @@ var flagsMap = map[string]components.Flag{
319321
DockerImageName: components.NewStringFlag(DockerImageName, "[Docker] Defines the Docker image name to audit. Format: 'repo/path/image:tag'. For example: 'curation-docker/dweomer/nginx-auth-ldap:1.13.5' or 'repo/image:tag'. If no tag is provided, 'latest' is used."),
320322

321323
// Git flags
322-
InputFile: components.NewStringFlag(InputFile, "Path to an input file in YAML format contains multiple git providers. With this option, all other scm flags will be ignored and only git servers mentioned in the file will be examined.."),
323-
ScmType: components.NewStringFlag(ScmType, fmt.Sprintf("SCM type. Possible values are: %s.", contributors.NewScmType().GetValidScmTypeString()), components.SetMandatory()),
324-
ScmApiUrl: components.NewStringFlag(ScmApiUrl, "SCM API URL. For example: 'https://api.github.com'.", components.SetMandatory()),
324+
InputFile: components.NewStringFlag(InputFile, "Path to an input file in YAML format contains multiple git providers. With this option, all other scm flags will be ignored and only git servers mentioned in the file will be examined.."),
325+
ScmType: components.NewStringFlag(ScmType, fmt.Sprintf("SCM type. Possible values are: %s.", contributors.NewScmType().GetValidScmTypeString()), components.SetMandatory()),
326+
ScmApiUrl: components.NewStringFlag(ScmApiUrl, "SCM API URL. For example: 'https://api.github.com'.", components.SetMandatory()),
327+
// jfrog-ignore: false positive, not hardcoded credentials
325328
Token: components.NewStringFlag(Token, fmt.Sprintf("SCM API token. In the absence of a flag, tokens should be passed in the %s environment variable, or in the corresponding environment variables '%s'.", contributors.GenericGitTokenEnvVar, contributors.NewScmType().GetOptionalScmTypeTokenEnvVars()), components.SetMandatory()),
326329
Owner: components.NewStringFlag(Owner, "The format of the owner key depends on the Git provider: On GitHub and GitLab, the owner is typically an individual or an organization, On Bitbucket, the owner can also be a project. In the case of a private instance on Bitbucket, the individual or organization name should be prefixed with '~'.", components.SetMandatory()),
327330
RepoName: components.NewStringFlag(RepoName, "List of semicolon-separated(;) repositories names to analyze, If not provided all repositories related to the provided owner will be analyzed."),

cli/gitcommands.go

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/jfrog/jfrog-cli-security/commands/git/contributors"
1717
"github.com/jfrog/jfrog-cli-security/utils/xsc"
1818
"github.com/jfrog/jfrog-client-go/utils/errorutils"
19+
"github.com/jfrog/jfrog-client-go/utils/log"
1920
)
2021

2122
func getGitNameSpaceCommands() []components.Command {
@@ -41,9 +42,11 @@ func getGitNameSpaceCommands() []components.Command {
4142
}
4243

4344
func GitAuditCmd(c *components.Context) error {
45+
log.Info("####### Starting jf git audit Scan #######")
46+
log.Info(getCommandUsedFlagsString(c, flags.GetCommandFlags(flags.GitAudit)))
4447
gitAuditCmd := audit.NewGitAuditCommand()
4548
// Set connection params
46-
serverDetails, err := createServerDetailsWithConfigOffer(c)
49+
serverDetails, err := CreateServerDetailsFromFlags(c)
4750
if err != nil {
4851
return err
4952
}
@@ -53,11 +56,17 @@ func GitAuditCmd(c *components.Context) error {
5356
}
5457
gitAuditCmd.SetServerDetails(serverDetails).SetXrayVersion(xrayVersion).SetXscVersion(xscVersion)
5558
// Set violations params
56-
if err = validateConnectionAndViolationContextInputs(c, serverDetails); err != nil {
59+
format, err := outputFormat.GetOutputFormat(c.GetStringFlagValue(flags.OutputFormat))
60+
if err != nil {
5761
return err
5862
}
59-
if c.IsFlagSet(flags.Watches) {
60-
gitAuditCmd.SetWatches(splitByCommaAndTrim(c.GetStringFlagValue(flags.Watches)))
63+
if err = validateConnectionAndViolationContextInputs(c, serverDetails, format); err != nil {
64+
return err
65+
}
66+
if watches, err := getWatches(c); err != nil {
67+
return err
68+
} else {
69+
gitAuditCmd.SetWatches(watches)
6170
}
6271
gitAuditCmd.SetProjectKey(getProject(c)).SetIncludeVulnerabilities(c.GetBoolFlagValue(flags.Vuln))
6372
// Set Scan params
@@ -66,28 +75,32 @@ func GitAuditCmd(c *components.Context) error {
6675
} else if len(subScans) > 0 {
6776
gitAuditCmd.SetScansToPerform(subScans)
6877
}
78+
gitAuditCmd.SetIncludeSbom(shouldIncludeSbom(c, format))
6979
if threads, err := pluginsCommon.GetThreadsCount(c); err != nil {
7080
return err
7181
} else {
7282
gitAuditCmd.SetThreads(threads)
7383
}
7484
gitAuditCmd.SetExclusions(pluginsCommon.GetStringsArrFlagValue(c, flags.Exclusions))
7585
// Set output params
76-
format, err := outputFormat.GetOutputFormat(c.GetStringFlagValue(flags.OutputFormat))
77-
if err != nil {
78-
return err
79-
}
8086
gitAuditCmd.SetOutputFormat(format).SetIncludeLicenses(c.GetBoolFlagValue(flags.Licenses)).SetFailBuild(c.GetBoolFlagValue(flags.Fail))
8187
scansOutputDir, err := getAndValidateOutputDirExistsIfProvided(c)
8288
if err != nil {
8389
return err
8490
}
8591
gitAuditCmd.SetOutputDir(scansOutputDir).SetExtendedTable(c.GetBoolFlagValue(flags.ExtendedTable))
8692
// Set the dynamic logic for SBOM generation and SCA scan strategy
87-
sbomGenerator, scaScanStrategy := getScanDynamicLogic(c)
93+
sbomGenerator, scaScanStrategy, violationGenerator, uploadResults, err := getScanDynamicLogic(c, xrayVersion)
94+
if err != nil {
95+
return err
96+
}
8897
gitAuditCmd.SetSbomGenerator(sbomGenerator).SetScaScanStrategy(scaScanStrategy)
98+
gitAuditCmd.SetViolationGenerator(violationGenerator)
99+
gitAuditCmd.SetUploadCdxResults(uploadResults).SetRtResultRepository(c.GetStringFlagValue(flags.UploadRtRepoPath))
89100
// Run the command with progress bar if needed, Reporting error if Xsc service is enabled
90-
return reportErrorIfExists(xrayVersion, xscVersion, serverDetails, gitAuditCmd.GetProjectKey(), progressbar.ExecWithProgress(gitAuditCmd))
101+
err = reportErrorIfExists(xrayVersion, xscVersion, serverDetails, gitAuditCmd.GetProjectKey(), progressbar.ExecWithProgress(gitAuditCmd))
102+
log.Info("####### jf git audit Scan Finished #######")
103+
return err
91104
}
92105

93106
func GetCountContributorsParams(c *components.Context) (*contributors.CountContributorsParams, error) {

0 commit comments

Comments
 (0)