Skip to content

Add support for handling of snippet code#672

Merged
attiasas merged 34 commits intojfrog:devfrom
talz:feature/snippet-code-decoration
Mar 4, 2026
Merged

Add support for handling of snippet code#672
attiasas merged 34 commits intojfrog:devfrom
talz:feature/snippet-code-decoration

Conversation

@talz
Copy link

@talz talz commented Feb 12, 2026

Add support for snippet-based code component detection

Summary

Adds a new hidden --snippet CLI flag (and JFROG_XRAY_SNIPPET_SCAN_ENABLE environment variable) that enables snippet-based component detection during audit and git-audit commands. When enabled, the Xray-Lib plugin performs source-level snippet matching to detect license-bearing code fragments (e.g., copied open-source C code), reports them as "snippet" components in the CycloneDX BOM, and surfaces license violations in the results.

Changes

CLI & Flag wiring

  • New hidden --snippet boolean flag added to audit and git audit commands.
  • Validation ensures snippet detection is only enabled when SCA or SBOM scanning is requested.
  • Flag can also be set via the JFROG_XRAY_SNIPPET_SCAN_ENABLE env var.

Audit command & results context

  • IncludeSnippetDetection field added to AuditCommand and ResultContext, threaded through CreateAuditResultsContext.
  • Snippet detection option forwarded to the XrayLibBomGenerator as a plugin environment variable.

Xray-Lib plugin

  • CreateScannerPluginClient now accepts and passes env vars to the plugin subprocess.
  • Default plugin version bumped from 0.0.3-52 to 0.0.3-55.

Result processing

  • New ExternalReferences field on Location (SimpleJSON format) to surface reference URLs from CycloneDX external references.
  • CdxEvidencesToLocations now extracts line numbers and external references from CycloneDX evidence/occurrences.
  • Dedicated handling for "snippet" components in impact-path building (isSnippetComponent, buildSnippetImpactPaths), which treats snippet parent→sub-component relationships differently from regular dependency trees.

Technology support

  • Added Cpp technology with github package type.
  • ToXrayComponentId updated to handle the github package type (colon-separated names).

Test utilities

  • Renamed CreateTestPolicyAndWatchCreateSecurityTestPolicyAndWatch for clarity.
  • Watch/policy creation helpers now accept a policyType parameter (Security or License).
  • New CreateTestLicensePolicy and generic CreateXrayPolicy helpers.

Tests & test data

  • New integration test TestAuditNewScaSnippetDetection verifying license violations are found with snippet detection enabled and absent without it.
  • Added C/JS snippet detection test data files; moved existing SAST test file into sast/ subdirectory.

Testing

  • New integration test TestAuditNewScaSnippetDetection covers the end-to-end flow: creates a license policy/watch, runs audit without snippet detection (expects zero results), then runs with --snippet (expects 4 license violations).
  • Existing TestCreateResultsContext unit test extended with snippet detection cases.
  • Existing integration tests updated for the refactored test utility signatures.

Checklist

  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....
  • All static analysis checks passed.
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • Updated the Contributing page / ReadMe page / CI Workflow files if needed.
  • All changes are detailed at the description. If not already covered at JFrog Documentation, new documentation have been added.

@attiasas attiasas added new feature Automatically generated release notes safe to test Approve running integration tests on a pull request labels Feb 15, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Feb 15, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Feb 15, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Feb 15, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Feb 17, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Feb 17, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 1, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@attiasas attiasas added ignore for release Automatically generated release notes safe to test Approve running integration tests on a pull request and removed new feature Automatically generated release notes labels Mar 3, 2026
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Mar 3, 2026
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

👍 Frogbot scanned this pull request and did not find any new security issues.


@attiasas attiasas requested a review from a team March 3, 2026 14:55
Copy link
Collaborator

@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.

LGTM

@attiasas attiasas merged commit 4d451a0 into jfrog:dev Mar 4, 2026
71 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore for release Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants