Skip to content

Commit 96ab517

Browse files
authored
Merge branch 'dev' into XRAY-129870-python-hyphens-fix
2 parents 376699e + bdfcc88 commit 96ab517

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"
@@ -158,38 +159,38 @@ var commandFlags = map[string][]string{
158159
XrCurl: {ServerId},
159160
OfflineUpdate: {LicenseId, From, To, Version, Target, Stream, Periodic},
160161
XrScan: {
161-
url, user, password, accessToken, ServerId, SpecFlag, Threads, scanRecursive, scanRegexp, scanAnt,
162+
Url, user, password, accessToken, ServerId, SpecFlag, Threads, scanRecursive, scanRegexp, scanAnt,
162163
scanProjectKey, Watches, RepoPath, Licenses, Sbom, OutputFormat, Fail, ExtendedTable, BypassArchiveLimits, MinSeverity, FixableOnly, ScanVuln, InsecureTls,
163164
},
164165
Enrich: {
165-
url, user, password, accessToken, ServerId, Threads, InsecureTls,
166+
Url, user, password, accessToken, ServerId, Threads, InsecureTls,
166167
},
167168
BuildScan: {
168-
url, user, password, accessToken, ServerId, scanProjectKey, BuildVuln, OutputFormat, Fail, ExtendedTable, Rescan, InsecureTls, TriggerScanRetries,
169+
Url, user, password, accessToken, ServerId, scanProjectKey, BuildVuln, OutputFormat, Fail, ExtendedTable, Rescan, InsecureTls, TriggerScanRetries,
169170
},
170171
DockerScan: {
171-
url, xrayUrl, user, password, accessToken, ServerId, scanProjectKey, Watches, RepoPath, Licenses, Sbom, OutputFormat, Fail, ExtendedTable, BypassArchiveLimits, MinSeverity, FixableOnly, ScanVuln, SecretValidation, InsecureTls,
172+
Url, XrayUrl, user, password, accessToken, ServerId, scanProjectKey, Watches, RepoPath, Licenses, Sbom, OutputFormat, Fail, ExtendedTable, BypassArchiveLimits, MinSeverity, FixableOnly, ScanVuln, SecretValidation, InsecureTls,
172173
},
173174
Audit: {
174-
url, xrayUrl, user, password, accessToken, ServerId, InsecureTls, scanProjectKey, Watches, RepoPath, Sbom, Licenses, OutputFormat, ExcludeTestDeps,
175+
Url, XrayUrl, user, password, accessToken, ServerId, InsecureTls, scanProjectKey, Watches, RepoPath, Sbom, Licenses, OutputFormat, ExcludeTestDeps,
175176
useWrapperAudit, DepType, RequirementsFile, Fail, ExtendedTable, WorkingDirs, ExclusionsAudit, Mvn, Gradle, Npm,
176177
Pnpm, Yarn, Go, Swift, Cocoapods, Nuget, Pip, Pipenv, Poetry, MinSeverity, FixableOnly, ThirdPartyContextualAnalysis, Threads,
177178
Sca, Iac, Sast, Secrets, WithoutCA, ScanVuln, SecretValidation, OutputDir, SkipAutoInstall, AllowPartialResults, MaxTreeDepth,
178-
StaticSca, XrayLibPluginBinaryCustomPath, AnalyzerManagerCustomPath, AddSastRules,
179+
StaticSca, XrayLibPluginBinaryCustomPath, AnalyzerManagerCustomPath, UploadRtRepoPath,
179180
},
180181
UploadCdx: {
181182
UploadRepoPath, uploadProjectKey,
182183
},
183184
GitAudit: {
184185
// Connection params
185-
url, xrayUrl, user, password, accessToken, ServerId, InsecureTls,
186+
Url, XrayUrl, user, password, accessToken, ServerId, InsecureTls,
186187
// Violations params
187188
scanProjectKey, Watches, ScanVuln, Fail,
188189
// Scan params
189190
Threads, ExclusionsAudit,
190-
Sca, Iac, Sast, Secrets, WithoutCA, SecretValidation,
191+
Sca, Iac, Sast, Secrets, WithoutCA, SecretValidation, Sbom,
191192
// Output params
192-
Licenses, OutputFormat, ExtendedTable, OutputDir,
193+
Licenses, OutputFormat, ExtendedTable, OutputDir, UploadRtRepoPath,
193194
// Scan Logic params
194195
StaticSca, XrayLibPluginBinaryCustomPath, AnalyzerManagerCustomPath, AddSastRules,
195196
},
@@ -201,31 +202,31 @@ var commandFlags = map[string][]string{
201202
},
202203
// TODO: Deprecated commands (remove at next CLI major version)
203204
AuditMvn: {
204-
url, user, password, accessToken, ServerId, InsecureTls, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable, useWrapperAudit,
205+
Url, user, password, accessToken, ServerId, InsecureTls, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable, useWrapperAudit,
205206
},
206207
AuditGradle: {
207-
url, user, password, accessToken, ServerId, ExcludeTestDeps, ExclusionsAudit, useWrapperAudit, scanProjectKey, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
208+
Url, user, password, accessToken, ServerId, ExcludeTestDeps, ExclusionsAudit, useWrapperAudit, scanProjectKey, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
208209
},
209210
AuditNpm: {
210-
url, user, password, accessToken, ServerId, DepType, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
211+
Url, user, password, accessToken, ServerId, DepType, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
211212
},
212213
AuditGo: {
213-
url, user, password, accessToken, ServerId, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
214+
Url, user, password, accessToken, ServerId, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
214215
},
215216
AuditPip: {
216-
url, user, password, accessToken, ServerId, RequirementsFile, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
217+
Url, user, password, accessToken, ServerId, RequirementsFile, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, Fail, ExtendedTable,
217218
},
218219
AuditPipenv: {
219-
url, user, password, accessToken, ServerId, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, ExtendedTable,
220+
Url, user, password, accessToken, ServerId, scanProjectKey, ExclusionsAudit, Watches, RepoPath, Licenses, OutputFormat, ExtendedTable,
220221
},
221222
}
222223

223224
// Security Flag keys mapped to their corresponding components.Flag definition.
224225
var flagsMap = map[string]components.Flag{
225226
// Common commands flags
226227
ServerId: components.NewStringFlag(ServerId, "Server ID configured using the config command."),
227-
url: components.NewStringFlag(url, "JFrog URL."),
228-
xrayUrl: components.NewStringFlag(xrayUrl, "JFrog Xray URL."),
228+
Url: components.NewStringFlag(Url, "JFrog URL."),
229+
XrayUrl: components.NewStringFlag(XrayUrl, "JFrog Xray URL."),
229230
user: components.NewStringFlag(user, "JFrog username."),
230231
password: components.NewStringFlag(password, "JFrog password."),
231232
accessToken: components.NewStringFlag(accessToken, "JFrog access token."),
@@ -260,7 +261,7 @@ var flagsMap = map[string]components.Flag{
260261
MinSeverity: components.NewStringFlag(MinSeverity, "Set the minimum severity of issues to display. Acceptable values: Low, Medium, High, or Critical."),
261262
FixableOnly: components.NewBoolFlag(FixableOnly, "Set to true if you wish to display issues that have a fix version only."),
262263
Rescan: components.NewBoolFlag(Rescan, "Set to true when scanning an already successfully scanned build, for example after adding an ignore rule."),
263-
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
264+
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
264265
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'."),
265266
ScanVuln: components.NewBoolFlag(Vuln, "Set to true if you'd like to receive all vulnerabilities, regardless of the policy configured in Xray."),
266267
InsecureTls: components.NewBoolFlag(InsecureTls, "Set to true to skip TLS certificates verification."),
@@ -273,6 +274,7 @@ var flagsMap = map[string]components.Flag{
273274
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."),
274275
OutputDir: components.NewStringFlag(OutputDir, "Target directory to save partial results to.", components.SetHiddenStrFlag()),
275276
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")),
277+
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")),
276278
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()),
277279
AllowPartialResults: components.NewBoolFlag(AllowPartialResults, "Set to true to allow partial results and continuance of the scan in case of certain errors.", components.SetHiddenBoolFlag()),
278280
ExclusionsAudit: components.NewStringFlag(
@@ -315,9 +317,10 @@ var flagsMap = map[string]components.Flag{
315317
AddSastRules: components.NewStringFlag(AddSastRules, "Incorporate any additional SAST rules (in JSON format, with absolute path) into this local scan."),
316318

317319
// Git flags
318-
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.."),
319-
ScmType: components.NewStringFlag(ScmType, fmt.Sprintf("SCM type. Possible values are: %s.", contributors.NewScmType().GetValidScmTypeString()), components.SetMandatory()),
320-
ScmApiUrl: components.NewStringFlag(ScmApiUrl, "SCM API URL. For example: 'https://api.github.com'.", components.SetMandatory()),
320+
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.."),
321+
ScmType: components.NewStringFlag(ScmType, fmt.Sprintf("SCM type. Possible values are: %s.", contributors.NewScmType().GetValidScmTypeString()), components.SetMandatory()),
322+
ScmApiUrl: components.NewStringFlag(ScmApiUrl, "SCM API URL. For example: 'https://api.github.com'.", components.SetMandatory()),
323+
// jfrog-ignore: false positive, not hardcoded credentials
321324
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()),
322325
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()),
323326
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)