Skip to content

Commit

Permalink
Merge branch 'dev' into pass_defaultconfig_sarif
Browse files Browse the repository at this point in the history
  • Loading branch information
eranturgeman authored Feb 10, 2025
2 parents 723223d + afab55c commit 7fe3a4d
Show file tree
Hide file tree
Showing 12 changed files with 328 additions and 198 deletions.
3 changes: 3 additions & 0 deletions commands/curation/curationaudit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ func createCurationCmdAndRun(tt testCase) (cmdResults map[string]*CurationReport
// For tests, we use localhost http server (nuget have issues without setting insecureTls)
curationCmd.SetInsecureTls(true)
curationCmd.SetIgnoreConfigFile(tt.shouldIgnoreConfigFile)
curationCmd.AuditParams.SetInsecureTls(tt.allowInsecureTls)
cmdResults = map[string]*CurationReport{}
err = curationCmd.doCurateAudit(cmdResults)
return
Expand Down Expand Up @@ -557,6 +558,7 @@ type testCase struct {
expectedError string
tech techutils.Technology
createServerWithoutCreds bool
allowInsecureTls bool
}

func (tc testCase) getPathToTests() string {
Expand Down Expand Up @@ -827,6 +829,7 @@ func getTestCasesForDoCurationAudit() []testCase {
totalNumberOfPackages: 1,
},
},
allowInsecureTls: true,
},
}
return tests
Expand Down
8 changes: 4 additions & 4 deletions commands/git/audit/gitaudit.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

sourceAudit "github.com/jfrog/jfrog-cli-security/commands/audit"
"github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-cli-security/utils/gitutils"
"github.com/jfrog/jfrog-cli-security/utils/results"
"github.com/jfrog/jfrog-cli-security/utils/results/output"
"github.com/jfrog/jfrog-cli-security/utils/scm"
"github.com/jfrog/jfrog-cli-security/utils/xsc"
)

Expand Down Expand Up @@ -46,7 +46,7 @@ func (gaCmd *GitAuditCommand) Run() (err error) {
// Detect git info
gitInfo, err := DetectGitInfo(gaCmd.repositoryLocalPath)
if err != nil {
return fmt.Errorf("failed to get git context: %v", err)
return fmt.Errorf("failed to get source control context: %v", err)
}
if gitInfo == nil {
// No Error but no git info = project working tree is dirty
Expand All @@ -65,11 +65,11 @@ func (gaCmd *GitAuditCommand) Run() (err error) {
}

func DetectGitInfo(wd string) (gitInfo *services.XscGitInfoContext, err error) {
gitManager, err := gitutils.NewGitManager(wd)
scmManager, err := scm.DetectScmInProject(wd)
if err != nil {
return
}
return gitManager.GetGitContext()
return scmManager.GetSourceControlContext()
}

func toAuditParams(params GitAuditParams) *sourceAudit.AuditParams {
Expand Down
7 changes: 4 additions & 3 deletions git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
securityTests "github.com/jfrog/jfrog-cli-security/tests"
securityTestUtils "github.com/jfrog/jfrog-cli-security/tests/utils"
"github.com/jfrog/jfrog-cli-security/tests/utils/integration"
securityUtils "github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-cli-security/utils/results"
"github.com/jfrog/jfrog-cli-security/utils/validations"
"github.com/jfrog/jfrog-cli-security/utils/xray/scangraph"
Expand Down Expand Up @@ -102,7 +103,7 @@ func TestGitAuditViolationsWithIgnoreRule(t *testing.T) {
auditCommandTestParams{Format: string(format.SimpleJson), WithLicense: true, WithVuln: true},
xrayVersion, xscVersion, "",
validations.ValidationParams{
Total: &validations.TotalCount{Licenses: 3, Violations: 16, Vulnerabilities: 16},
Total: &validations.TotalCount{Licenses: 3, Violations: 12, Vulnerabilities: 12},
// Check that we have at least one violation for each scan type. (IAC is not supported yet)
Violations: &validations.ViolationCount{ValidateScan: &validations.ScanCount{Sca: 1, Sast: 1, Secrets: 1}},
},
Expand Down Expand Up @@ -153,15 +154,15 @@ func TestGitAuditJasViolationsProjectKeySimpleJson(t *testing.T) {
auditCommandTestParams{Format: string(format.SimpleJson), ProjectKey: *securityTests.JfrogTestProjectKey},
xrayVersion, xscVersion, results.NewFailBuildError().Error(),
validations.ValidationParams{
Total: &validations.TotalCount{Violations: 16},
Total: &validations.TotalCount{Violations: 12},
// Check that we have at least one violation for each scan type. (IAC is not supported yet)
Violations: &validations.ViolationCount{ValidateScan: &validations.ScanCount{Sca: 1, Sast: 1, Secrets: 1}},
},
)
}

func TestXrayAuditJasSkipNotApplicableCvesViolations(t *testing.T) {
xrayVersion, xscVersion, testCleanUp := integration.InitGitTest(t, services.MinXrayVersionGitRepoKey)
xrayVersion, xscVersion, testCleanUp := integration.InitGitTest(t, securityUtils.GitRepoKeyAnalyticsMinVersion)
defer testCleanUp()

projectPath := filepath.Join(filepath.FromSlash(securityTests.GetTestResourcesPath()), "git", "projects", "issues")
Expand Down
59 changes: 28 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,53 @@ go 1.23.4

require (
github.com/beevik/etree v1.4.0
github.com/go-git/go-git/v5 v5.13.0
github.com/go-git/go-git/v5 v5.13.2
github.com/google/go-github/v56 v56.0.0
github.com/gookit/color v1.5.4
github.com/jfrog/build-info-go v1.10.8
github.com/jfrog/build-info-go v1.10.9
github.com/jfrog/froggit-go v1.16.2
github.com/jfrog/gofrog v1.7.6
github.com/jfrog/jfrog-apps-config v1.0.1
github.com/jfrog/jfrog-cli-artifactory v0.1.11
github.com/jfrog/jfrog-cli-core/v2 v2.57.7
github.com/jfrog/jfrog-client-go v1.49.1
github.com/jfrog/jfrog-cli-artifactory v0.1.12
github.com/jfrog/jfrog-cli-core/v2 v2.58.0
github.com/jfrog/jfrog-client-go v1.50.0
github.com/magiconair/properties v1.8.9
github.com/owenrumney/go-sarif/v2 v2.3.0
github.com/stretchr/testify v1.10.0
github.com/urfave/cli v1.22.16
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
golang.org/x/sync v0.10.0
golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c
golang.org/x/sync v0.11.0
golang.org/x/text v0.21.0
gopkg.in/yaml.v3 v3.0.1
)

require (
dario.cat/mergo v1.0.0 // indirect
dario.cat/mergo v1.0.1 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/CycloneDX/cyclonedx-go v0.9.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v1.1.3 // indirect
github.com/CycloneDX/cyclonedx-go v0.9.2 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.1.5 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/c-bata/go-prompt v0.2.5 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cloudflare/circl v1.4.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/cloudflare/circl v1.6.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/forPelevin/gomoji v1.2.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gfleury/go-bitbucket-v1 v0.0.0-20230825095122-9bc1711434ab // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.0 // indirect
github.com/go-git/go-git/v5 v5.13.0 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 // indirect
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
Expand All @@ -63,8 +62,8 @@ require (
github.com/jedib0t/go-pretty/v6 v6.6.5 // indirect
github.com/jfrog/archiver/v3 v3.6.1 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
github.com/ktrysmt/go-bitbucket v0.9.80 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
Expand All @@ -77,8 +76,8 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/term v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
Expand All @@ -87,7 +86,7 @@ require (
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand All @@ -99,22 +98,20 @@ require (
github.com/xanzy/go-gitlab v0.110.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/mod v0.23.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.29.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250126110945-81abbdde452f
// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go dev

replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250128111343-44586261061e

Expand Down
Loading

0 comments on commit 7fe3a4d

Please sign in to comment.