Add support for handling of snippet code#672
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Add support for snippet-based code component detection
Summary
Adds a new hidden
--snippetCLI flag (andJFROG_XRAY_SNIPPET_SCAN_ENABLEenvironment 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
--snippetboolean flag added toauditandgit auditcommands.JFROG_XRAY_SNIPPET_SCAN_ENABLEenv var.Audit command & results context
IncludeSnippetDetectionfield added toAuditCommandandResultContext, threaded throughCreateAuditResultsContext.XrayLibBomGeneratoras a plugin environment variable.Xray-Lib plugin
CreateScannerPluginClientnow accepts and passes env vars to the plugin subprocess.0.0.3-52to0.0.3-55.Result processing
ExternalReferencesfield onLocation(SimpleJSON format) to surface reference URLs from CycloneDX external references.CdxEvidencesToLocationsnow extracts line numbers and external references from CycloneDX evidence/occurrences.isSnippetComponent,buildSnippetImpactPaths), which treats snippet parent→sub-component relationships differently from regular dependency trees.Technology support
Cpptechnology withgithubpackage type.ToXrayComponentIdupdated to handle thegithubpackage type (colon-separated names).Test utilities
CreateTestPolicyAndWatch→CreateSecurityTestPolicyAndWatchfor clarity.policyTypeparameter (Security or License).CreateTestLicensePolicyand genericCreateXrayPolicyhelpers.Tests & test data
TestAuditNewScaSnippetDetectionverifying license violations are found with snippet detection enabled and absent without it.sast/subdirectory.Testing
TestAuditNewScaSnippetDetectioncovers 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).TestCreateResultsContextunit test extended with snippet detection cases.Checklist
devbranch.go vet ./....go fmt ./....