Skip to content

Commit

Permalink
Adding error logs report to Coralogix (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
eranturgeman authored Apr 10, 2024
1 parent 1098871 commit 1da24db
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 30 deletions.
12 changes: 9 additions & 3 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ package main
import (
"errors"
"fmt"
"os"

"github.com/jfrog/frogbot/v2/scanpullrequest"
"github.com/jfrog/frogbot/v2/scanrepository"
"github.com/jfrog/frogbot/v2/utils"
"github.com/jfrog/frogbot/v2/utils/outputwriter"
"github.com/jfrog/froggit-go/vcsclient"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/utils/usage"
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"os"

securityutils "github.com/jfrog/jfrog-cli-security/utils"
clitool "github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -102,7 +104,11 @@ func Exec(command FrogbotCommand, commandName string) (err error) {
// Wait for usage reporting to finish.
waitForUsageResponse()

if err == nil {
if err != nil && usage.ShouldReportUsage() {
if reportError := securityutils.ReportError(frogbotDetails.ServerDetails, err, "frogbot"); reportError != nil {
log.Debug(reportError)
}
} else {
log.Info(fmt.Sprintf("Frogbot %q command finished successfully", commandName))
}
return err
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ require (

// replace github.com/jfrog/froggit-go => github.com/jfrog/froggit-go master

// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 dev
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240408074156-13680c04f22e

// replace github.com/jfrog/jfrog-cli-security => github.com/jfrog/jfrog-cli-security dev
replace github.com/jfrog/jfrog-cli-security => github.com/jfrog/jfrog-cli-security v1.0.6-0.20240410071835-35f62009cd4e

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go dev
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240409191434-4e96d77edd64

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go dev
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go dev
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -898,12 +898,12 @@ github.com/jfrog/gofrog v1.6.3 h1:F7He0+75HcgCe6SGTSHLFCBDxiE2Ja0tekvvcktW6wc=
github.com/jfrog/gofrog v1.6.3/go.mod h1:SZ1EPJUruxrVGndOzHd+LTiwWYKMlHqhKD+eu+v5Hqg=
github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY=
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
github.com/jfrog/jfrog-cli-core/v2 v2.50.0 h1:QmjSIktMKAbNH7OGY+eVZKx9husqgMANSI5kB8MlvlA=
github.com/jfrog/jfrog-cli-core/v2 v2.50.0/go.mod h1:95AsjwlMLNWU0v71/3dS715e1RAQfvPO47RRHz2xKh8=
github.com/jfrog/jfrog-cli-security v1.0.5 h1:tBJWiSTiBYpFB5LlHTUeBZ1wYdnrsG0ILNcHGKCiPgc=
github.com/jfrog/jfrog-cli-security v1.0.5/go.mod h1:ipG+b3qQqF0M8SFKkZ7DlMUsgMpdL+iIHc40j9JEs3E=
github.com/jfrog/jfrog-client-go v1.39.0 h1:GZ1qbpUDzYz8ZEycYicDkbVMN2H0VSCuz8mUNTyf7tc=
github.com/jfrog/jfrog-client-go v1.39.0/go.mod h1:tUyEmxznphh0nwAGo6xz9Sps7RRW/TBMxIJZteo+j2k=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240408074156-13680c04f22e h1:PjCzGWHyJqK4j1MP3osPDDAW6KBXMJlBypOxKtp/ZKo=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240408074156-13680c04f22e/go.mod h1:qXAP68g+DlyX2wk5znNbQdK2CcEHfOLOfYXPzdlnkxI=
github.com/jfrog/jfrog-cli-security v1.0.6-0.20240410071835-35f62009cd4e h1:yCLVnw5XW1o293wOu4RJlawSkf5HrsiT1DTLO3W/ceg=
github.com/jfrog/jfrog-cli-security v1.0.6-0.20240410071835-35f62009cd4e/go.mod h1:6eJBg54tzN7bBRe+vbM9QWxBAdZACvcWVgt1aQRpewo=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240409191434-4e96d77edd64 h1:q0GV0IdhYdTqEkNykRwNZP0qNEE8j9dWfY9uKovDPzM=
github.com/jfrog/jfrog-client-go v1.28.1-0.20240409191434-4e96d77edd64/go.mod h1:tUyEmxznphh0nwAGo6xz9Sps7RRW/TBMxIJZteo+j2k=
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA=
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
Expand Down
4 changes: 2 additions & 2 deletions integrationutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
repoName = "integration"
issuesBranch = "issues-branch"
mainBranch = "main"
expectedNumberOfIssues = 11
expectedNumberOfIssues = 10
)

type IntegrationTestDetails struct {
Expand Down Expand Up @@ -229,7 +229,7 @@ func validateGitHubComments(t *testing.T, ctx context.Context, client *vcsclient

reviewComments, err := client.ListPullRequestReviewComments(ctx, testDetails.RepoOwner, testDetails.RepoName, prID)
assert.NoError(t, err)
assert.GreaterOrEqual(t, len(reviewComments), 10)
assert.GreaterOrEqual(t, len(reviewComments), 9)
}

func validateAzureComments(t *testing.T, comments []vcsclient.CommentInfo) {
Expand Down
4 changes: 1 addition & 3 deletions scanrepository/scanrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ func (cfp *ScanRepositoryCmd) scanAndFixBranch(repository *utils.Repository) (er
}
err = errors.Join(err, restoreBaseDir(), fileutils.RemoveTempDir(clonedRepoDir))
}()
if err = cfp.scanDetails.CreateMultiScanIdForScans(); err != nil {
return err
}

for i := range repository.Projects {
cfp.scanDetails.Project = &repository.Projects[i]
cfp.projectTech = []coreutils.Technology{}
Expand Down
12 changes: 0 additions & 12 deletions utils/scandetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/jfrog/froggit-go/vcsclient"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-security/commands/audit"
"github.com/jfrog/jfrog-cli-security/utils"
xrayutils "github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-client-go/utils/log"
"github.com/jfrog/jfrog-client-go/xray/services"
Expand Down Expand Up @@ -186,14 +185,3 @@ func GetFullPathWorkingDirs(workingDirs []string, baseWd string) []string {
}
return fullPathWds
}

func (sc *ScanDetails) CreateMultiScanIdForScans() error {
xrayManager, err := xrayutils.CreateXrayServiceManager(sc.ServerDetails)
if err != nil {
return err
}
if err = utils.SendXscGitInfoRequestIfEnabled(sc.XrayGraphScanParams, xrayManager); err != nil {
return err
}
return nil
}

0 comments on commit 1da24db

Please sign in to comment.