-
Notifications
You must be signed in to change notification settings - Fork 2
[NEW PRIMITIVE] sarif_diff_by_commits β SARIF-to-git-diff correlation tool
#236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5c087f0
Initial plan
Copilot 05eedb8
feat: add sarif_diff_by_commits tool for SARIF-to-git-diff correlation
Copilot 5d30961
feat: add client integration test for sarif_diff_by_commits
Copilot e502fea
Apply lint/format & rebuild server/dist/
data-douser be5096d
[UPDATE PRIMITIVE] `sarif_diff_by_commits` β refRange validation, filβ¦
Copilot cbe5f6a
Extend client tests -> sarif_diff_by_commits tool
data-douser 700d4be
fix: address unresolved PR review comments
data-douser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...ests/primitives/tools/sarif_diff_by_commits/file_level_classification/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Integration Test: sarif_diff_by_commits - file_level_classification | ||
|
|
||
| ## Purpose | ||
|
|
||
| Validates that the `sarif_diff_by_commits` tool correctly partitions | ||
| SARIF results into "new" vs "pre-existing" based on file-level overlap | ||
| with a git diff. Uses `HEAD..HEAD` (empty diff) so all results are | ||
| classified as pre-existing. | ||
|
|
||
| ## Inputs | ||
|
|
||
| - `results.sarif`: SARIF with 3 results across 2 rules in 3 files | ||
| - `refRange`: `HEAD..HEAD` (produces an empty diff) | ||
| - `granularity`: `file` | ||
|
|
||
| ## Expected Behavior | ||
|
|
||
| Returns structured output with all 3 results in `preExistingResults` | ||
| and 0 results in `newResults`, since the empty diff has no changed files. |
5 changes: 5 additions & 0 deletions
5
...mitives/tools/sarif_diff_by_commits/file_level_classification/after/monitoring-state.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "toolName": "sarif_diff_by_commits", | ||
| "success": true, | ||
| "description": "Successfully classified all results as pre-existing with empty diff" | ||
| } |
107 changes: 107 additions & 0 deletions
107
...ests/primitives/tools/sarif_diff_by_commits/file_level_classification/after/results.sarif
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| { | ||
| "version": "2.1.0", | ||
| "$schema": "https://json.schemastore.org/sarif-2.1.0.json", | ||
| "runs": [ | ||
| { | ||
| "tool": { | ||
| "driver": { | ||
| "name": "CodeQL", | ||
| "version": "2.20.4", | ||
| "rules": [ | ||
| { | ||
| "id": "js/sql-injection", | ||
| "name": "js/sql-injection", | ||
| "shortDescription": { | ||
| "text": "Database query built from user-controlled sources" | ||
| }, | ||
| "properties": { | ||
| "tags": ["security"], | ||
| "kind": "path-problem", | ||
| "precision": "high", | ||
| "security-severity": "8.8" | ||
| } | ||
| }, | ||
| { | ||
| "id": "js/xss", | ||
| "name": "js/xss", | ||
| "shortDescription": { | ||
| "text": "Cross-site scripting" | ||
| }, | ||
| "properties": { | ||
| "tags": ["security"], | ||
| "kind": "path-problem", | ||
| "precision": "high", | ||
| "security-severity": "6.1" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "results": [ | ||
| { | ||
| "ruleId": "js/sql-injection", | ||
| "ruleIndex": 0, | ||
| "message": { | ||
| "text": "SQL injection from user input." | ||
| }, | ||
| "locations": [ | ||
| { | ||
| "physicalLocation": { | ||
| "artifactLocation": { | ||
| "uri": "src/db.js" | ||
| }, | ||
| "region": { | ||
| "startLine": 42, | ||
| "startColumn": 5, | ||
| "endColumn": 38 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "ruleId": "js/sql-injection", | ||
| "ruleIndex": 0, | ||
| "message": { | ||
| "text": "SQL injection from request body." | ||
| }, | ||
| "locations": [ | ||
| { | ||
| "physicalLocation": { | ||
| "artifactLocation": { | ||
| "uri": "src/api.js" | ||
| }, | ||
| "region": { | ||
| "startLine": 15, | ||
| "startColumn": 3, | ||
| "endColumn": 40 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "ruleId": "js/xss", | ||
| "ruleIndex": 1, | ||
| "message": { | ||
| "text": "XSS vulnerability." | ||
| }, | ||
| "locations": [ | ||
| { | ||
| "physicalLocation": { | ||
| "artifactLocation": { | ||
| "uri": "src/views.js" | ||
| }, | ||
| "region": { | ||
| "startLine": 30, | ||
| "startColumn": 10, | ||
| "endColumn": 50 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
5 changes: 5 additions & 0 deletions
5
...itives/tools/sarif_diff_by_commits/file_level_classification/before/monitoring-state.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "toolName": "sarif_diff_by_commits", | ||
| "expectedSuccess": true, | ||
| "description": "Test sarif_diff_by_commits classifies all results as pre-existing with empty diff" | ||
| } |
107 changes: 107 additions & 0 deletions
107
...sts/primitives/tools/sarif_diff_by_commits/file_level_classification/before/results.sarif
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| { | ||
| "version": "2.1.0", | ||
| "$schema": "https://json.schemastore.org/sarif-2.1.0.json", | ||
| "runs": [ | ||
| { | ||
| "tool": { | ||
| "driver": { | ||
| "name": "CodeQL", | ||
| "version": "2.20.4", | ||
| "rules": [ | ||
| { | ||
| "id": "js/sql-injection", | ||
| "name": "js/sql-injection", | ||
| "shortDescription": { | ||
| "text": "Database query built from user-controlled sources" | ||
| }, | ||
| "properties": { | ||
| "tags": ["security"], | ||
| "kind": "path-problem", | ||
| "precision": "high", | ||
| "security-severity": "8.8" | ||
| } | ||
| }, | ||
| { | ||
| "id": "js/xss", | ||
| "name": "js/xss", | ||
| "shortDescription": { | ||
| "text": "Cross-site scripting" | ||
| }, | ||
| "properties": { | ||
| "tags": ["security"], | ||
| "kind": "path-problem", | ||
| "precision": "high", | ||
| "security-severity": "6.1" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "results": [ | ||
| { | ||
| "ruleId": "js/sql-injection", | ||
| "ruleIndex": 0, | ||
| "message": { | ||
| "text": "SQL injection from user input." | ||
| }, | ||
| "locations": [ | ||
| { | ||
| "physicalLocation": { | ||
| "artifactLocation": { | ||
| "uri": "src/db.js" | ||
| }, | ||
| "region": { | ||
| "startLine": 42, | ||
| "startColumn": 5, | ||
| "endColumn": 38 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "ruleId": "js/sql-injection", | ||
| "ruleIndex": 0, | ||
| "message": { | ||
| "text": "SQL injection from request body." | ||
| }, | ||
| "locations": [ | ||
| { | ||
| "physicalLocation": { | ||
| "artifactLocation": { | ||
| "uri": "src/api.js" | ||
| }, | ||
| "region": { | ||
| "startLine": 15, | ||
| "startColumn": 3, | ||
| "endColumn": 40 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "ruleId": "js/xss", | ||
| "ruleIndex": 1, | ||
| "message": { | ||
| "text": "XSS vulnerability." | ||
| }, | ||
| "locations": [ | ||
| { | ||
| "physicalLocation": { | ||
| "artifactLocation": { | ||
| "uri": "src/views.js" | ||
| }, | ||
| "region": { | ||
| "startLine": 30, | ||
| "startColumn": 10, | ||
| "endColumn": 50 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
17 changes: 17 additions & 0 deletions
17
...n-tests/primitives/tools/sarif_diff_by_commits/file_level_classification/test-config.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "toolName": "sarif_diff_by_commits", | ||
| "arguments": { | ||
| "refRange": "HEAD..HEAD", | ||
| "granularity": "file" | ||
| }, | ||
| "assertions": { | ||
| "responseContains": [ | ||
| "\"granularity\": \"file\"", | ||
| "\"preExistingResults\"", | ||
| "\"newResults\"", | ||
| "\"totalPreExisting\": 3", | ||
| "\"totalNew\": 0", | ||
| "\"totalResults\": 3" | ||
| ] | ||
| } | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.