Closed
Conversation
b2b19e8 to
cc8ec40
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enriches reported violations with the enclosing function/method name and exports that context in SARIF, allowing SARIF consumers to associate findings with functions without re-parsing source.
Changes:
- Add
method_nameto the RustViolationmodel and thread it through the DDSA JS↔Rust conversion layer. - Auto-detect enclosing function/method names in the DDSA JS runtime via
ddsa.getEnclosingFunctionName(node)and auto-populateViolation.methodNameduring construction (with an explicitwithMethodNameoverride). - Emit
method_nameinto SARIF as alogicalLocationwith kind"function"when present.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/static-analysis-kernel/src/model/violation.rs | Adds method_name to the core violation model. |
| crates/static-analysis-kernel/src/analysis/ddsa_lib/runtime.rs | Adds runtime tests ensuring method_name is auto-populated/overridable. |
| crates/static-analysis-kernel/src/analysis/ddsa_lib/js/violation.rs | Extends V8 conversion to read/write methodName from JS violations. |
| crates/static-analysis-kernel/src/analysis/ddsa_lib/js/violation.js | Auto-populates methodName during construction and adds withMethodName. |
| crates/static-analysis-kernel/src/analysis/ddsa_lib/js/ddsa.js | Introduces getEnclosingFunctionName helper to walk the tree-sitter AST upward. |
| crates/cli/src/sarif/sarif_utils.rs | Emits logicalLocations in SARIF when method_name is present. |
| crates/cli/src/rule_utils.rs | Updates violation construction to include method_name: None. |
| crates/cli/src/file_utils.rs | Updates violation construction in tests to include method_name: None. |
| crates/cli/src/csv.rs | Updates violation construction in tests to include method_name: None. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
What problem are you trying to solve?
SARIF results currently contain no information about which function or method a violation belongs to. Consumers of the SARIF output (e.g. Datadog's static analysis backend) cannot associate a violation with its enclosing function without re-parsing the source file themselves.
What is your solution?
Alternatives considered
Post-processing the violations on the Rust side using tree-sitter's descendant_for_point_range after JS execution. Discarded in favor of the JS-side approach since the TreeSitterNode is already available at violation creation time and the detection naturally belongs there.
What the reviewer should know