Skip to content

Publish Scan Results to Gitlab Dashboards#1268

Open
orto17 wants to merge 15 commits intojfrog:v3_erfrom
orto17:publish-results-gitlab
Open

Publish Scan Results to Gitlab Dashboards#1268
orto17 wants to merge 15 commits intojfrog:v3_erfrom
orto17:publish-results-gitlab

Conversation

@orto17
Copy link
Copy Markdown
Contributor

@orto17 orto17 commented Apr 12, 2026

  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • This pull request is on the dev branch.
  • I used gofmt for formatting the code before submitting the pull request.
  • Update documentation about new features / new supported technologies

Frogbot can now write scan output to a directory when it runs against GitLab, using the JF_SCAN_RESULTS_OUTPUT_DIR environment variable. The directory gets cyclonedx.json (SBOM) and gl-dependency-scanning-report.json in GitLab’s dependency-scanning format, so pipelines can publish them to GitLab’s security UI. This runs alongside the existing repository scan flow (detection and auto-fix behavior are unchanged when enabled).

image image image image

@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@orto17 orto17 changed the title save results in gitlab format Publish Scan Results to Gitlab Dashboards Apr 12, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Apr 12, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label May 7, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label May 7, 2026
Copy link
Copy Markdown
Contributor

@attiasas attiasas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! check out my comments

Comment on lines +158 to +163
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()))
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe export to helper func? similar to uploadResultsToGithubDashboardsIfNeeded?

Comment thread utils/utils.go
return err
}

func WriteScanResultsToDir(outputDir string, scanResults *results.SecurityCommandResults, startTime time.Time) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func WriteScanResultsToDir(outputDir string, scanResults *results.SecurityCommandResults, startTime time.Time) error {
func WriteScanResultsToGitlabDir(outputDir string, scanResults *results.SecurityCommandResults, startTime time.Time) error {

maybe give it more detailed name, this may be confusing to future devs,

Comment thread utils/utils.go
Comment on lines +505 to +514
path := filepath.Join(outputDir, cyclonedxOutputFilename)
f, err := os.Create(path)
if err != nil {
return fmt.Errorf("create file: %w", err)
}
defer func() { _ = f.Close() }()
encoder := cyclonedx.NewBOMEncoder(f, cyclonedx.BOMFileFormatJSON)
if err = encoder.Encode(&bom); err != nil {
return fmt.Errorf("encode CycloneDX: %w", err)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
path := filepath.Join(outputDir, cyclonedxOutputFilename)
f, err := os.Create(path)
if err != nil {
return fmt.Errorf("create file: %w", err)
}
defer func() { _ = f.Close() }()
encoder := cyclonedx.NewBOMEncoder(f, cyclonedx.BOMFileFormatJSON)
if err = encoder.Encode(&bom); err != nil {
return fmt.Errorf("encode CycloneDX: %w", err)
}
err = utils.SaveCdxContentToFile(filepath.Join(outputDir, cyclonedxOutputFilename), bom)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants