Skip to content
Open
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: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.25.7

require (
github.com/CycloneDX/cyclonedx-go v0.9.3
github.com/go-git/go-git/v5 v5.16.5
github.com/go-git/go-git/v5 v5.18.0
github.com/golang/mock v1.6.0
github.com/google/go-github/v45 v45.2.0
github.com/jfrog/build-info-go v1.13.1-0.20260216093441-40a4dc563294
Expand Down Expand Up @@ -32,7 +32,7 @@ require (
github.com/chzyer/readline v1.5.1 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/cloudflare/circl v1.6.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/cyphar/filepath-securejoin v0.6.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand All @@ -43,7 +43,7 @@ require (
github.com/fsnotify/fsnotify v1.9.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.2 // indirect
github.com/go-git/go-billy/v5 v5.8.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuh
github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -77,10 +79,14 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66D
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM=
github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU=
github.com/go-git/go-billy/v5 v5.8.0 h1:I8hjc3LbBlXTtVuFNJuwYuMiHvQJDq1AT6u4DwDzZG0=
github.com/go-git/go-billy/v5 v5.8.0/go.mod h1:RpvI/rw4Vr5QA+Z60c6d6LXH0rYJo0uD5SqfmrrheCY=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
github.com/go-git/go-git/v5 v5.16.5 h1:mdkuqblwr57kVfXri5TTH+nMFLNUxIj9Z7F5ykFbw5s=
github.com/go-git/go-git/v5 v5.16.5/go.mod h1:QOMLpNf1qxuSY4StA/ArOdfFR2TrKEjJiye2kel2m+M=
github.com/go-git/go-git/v5 v5.18.0 h1:O831KI+0PR51hM2kep6T8k+w0/LIAD490gvqMCvL5hM=
github.com/go-git/go-git/v5 v5.18.0/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
Expand Down
12 changes: 10 additions & 2 deletions scanrepository/scanrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"errors"
"fmt"
"github.com/jfrog/frogbot/v2/packageupdaters"
"os"
"path/filepath"
"regexp"
"strings"

"github.com/jfrog/frogbot/v2/packageupdaters"

"github.com/go-git/go-git/v5"
biutils "github.com/jfrog/build-info-go/utils"

Expand Down Expand Up @@ -154,8 +155,15 @@ func (sr *ScanRepositoryCmd) scanAndFixBranch(repository *utils.Repository) (tot
totalFindings = getTotalFindingsFromScanResults(scanResults)
sr.uploadResultsToGithubDashboardsIfNeeded(repository, scanResults)

if repository.Params.Git.GitProvider == vcsutils.GitLab && repository.Params.Git.GitlabScanResultsOutputDir != "" {
log.Debug(fmt.Sprintf("Trying to save scan results to directory: %s", repository.Params.Git.GitlabScanResultsOutputDir))
if writeErr := utils.WriteScanResultsToDir(repository.Params.Git.GitlabScanResultsOutputDir, scanResults, sr.scanDetails.StartTime); writeErr != nil {
log.Warn(fmt.Sprintf("Failed to write scan results to directory: %s", writeErr.Error()))
}
}

if !repository.Params.FrogbotConfig.CreateAutoFixPr {
log.Info(fmt.Sprintf("This command is running in detection mode only. To enable automatic fixing of issues, set the '%s' flag under the repository's coniguration settings in Jfrog platform", createAutoFixPrConfigNameInProfile))
log.Info(fmt.Sprintf("This command is running in detection mode only. To enable automatic fixing of issues, set the '%s' flag under the repository's configuration settings in Jfrog platform", createAutoFixPrConfigNameInProfile))
return totalFindings, nil
}

Expand Down
9 changes: 5 additions & 4 deletions utils/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ const (
GitDependencyGraphSubmissionEnv = "JF_UPLOAD_SBOM_TO_VCS"

//#nosec G101 -- False positive - no hardcoded credentials.
GitTokenEnv = "JF_GIT_TOKEN"
GitBaseBranchEnv = "JF_GIT_BASE_BRANCH"
GitPullRequestIDEnv = "JF_GIT_PULL_REQUEST_ID"
GitApiEndpointEnv = "JF_GIT_API_ENDPOINT"
GitTokenEnv = "JF_GIT_TOKEN"
GitBaseBranchEnv = "JF_GIT_BASE_BRANCH"
GitPullRequestIDEnv = "JF_GIT_PULL_REQUEST_ID"
GitApiEndpointEnv = "JF_GIT_API_ENDPOINT"
GitlabScanResultsOutputDirEnv = "JF_SCAN_RESULTS_OUTPUT_DIR"

// Placeholders for templates
PackagePlaceHolder = "{IMPACTED_PACKAGE}"
Expand Down
16 changes: 10 additions & 6 deletions utils/getconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ func (jp *JFrogPlatform) setJfProjectKeyIfExists() (err error) {
type Git struct {
GitProvider vcsutils.VcsProvider
vcsclient.VcsInfo
RepoOwner string
RepoName string
Branches []string
PullRequestDetails vcsclient.PullRequestInfo
RepositoryCloneUrl string
UploadSbomToVcs *bool
RepoOwner string
RepoName string
Branches []string
PullRequestDetails vcsclient.PullRequestInfo
RepositoryCloneUrl string
UploadSbomToVcs *bool
GitlabScanResultsOutputDir string
}

func (g *Git) GetRepositoryHttpsCloneUrl(gitClient vcsclient.VcsClient) (string, error) {
Expand All @@ -95,6 +96,7 @@ func (g *Git) setDefaultsIfNeeded(gitParamsFromEnv *Git, commandName string) (er
g.VcsInfo = gitParamsFromEnv.VcsInfo
g.PullRequestDetails = gitParamsFromEnv.PullRequestDetails
g.RepoName = gitParamsFromEnv.RepoName
g.GitlabScanResultsOutputDir = gitParamsFromEnv.GitlabScanResultsOutputDir

if commandName == ScanPullRequest {
if gitParamsFromEnv.PullRequestDetails.ID == 0 {
Expand Down Expand Up @@ -425,6 +427,8 @@ func extractGitParamsFromEnvs() (*Git, error) {
gitEnvParams.PullRequestDetails = vcsclient.PullRequestInfo{ID: int64(convertedPrId)}
}

gitEnvParams.GitlabScanResultsOutputDir = getTrimmedEnv(GitlabScanResultsOutputDirEnv)

return gitEnvParams, nil
}

Expand Down
Loading