-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(misconf): include map key in manifest snippet for diagnostics #9681
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
feat(misconf): include map key in manifest snippet for diagnostics #9681
Conversation
📊 API Changes DetectedSemver impact: |
54515f9 to
b02712b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves YAML manifest diagnostics by ensuring map node snippets start at the map key line and by handling line ranges correctly when maps/slices end with null nodes.
- Include map key line in snippets for map nodes by adjusting StartLine.
- Correct EndLine calculation for maps and slices that end with a null node.
- Refactor parsing to use ManifestFromYAML/NewManifest and propagate FilePath; update tests and goldens accordingly.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/iac/scanners/kubernetes/parser/parser.go | Refactors parsing to use ManifestFromYAML; tracks per-document line offset. |
| pkg/iac/scanners/kubernetes/parser/manifest_node.go | Renames Path to FilePath; adds newManifestNodeFromYaml; adjusts map handling to start at key’s line; handles null nodes. |
| pkg/iac/scanners/kubernetes/parser/manifest.go | Introduces ManifestFromYAML; updates Manifest structure and NewManifest behavior; improves error wrapping. |
| pkg/iac/scanners/kubernetes/parser/manifest_test.go | Adds YAML test covering nulls and map key start line; updates tests to use ManifestFromYAML and FilePath metadata. |
| integration/testdata/*.golden | Updates expected diagnostics to include map keys and corrected line ranges. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
dab80da to
306eec9
Compare
Signed-off-by: nikpivkin <[email protected]>
Signed-off-by: nikpivkin <[email protected]>
Signed-off-by: nikpivkin <[email protected]>
Signed-off-by: nikpivkin <[email protected]>
306eec9 to
003e7ae
Compare
Signed-off-by: nikpivkin <[email protected]>
|
Was there any associated GitHub issue or discussion for it? |
…quasecurity#9681) Signed-off-by: nikpivkin <[email protected]>
Description
This PR updates
ManifestNodeparsing to correctly capture the start line of map nodes using the key's line. Previously, snippets for map nodes would start at the first value, omitting the key itself, which could make diagnostic messages and snippet highlighting less accurate.Example before:
For this YAML snippet:
The snippet in diagnostics showed only the value:
This does not give any indication that the value belongs to
metadata. The user only sees the line name:hello-host-portswithout knowing its level or context.Example after:
Now the snippet correctly includes the key, and the range references the
metadatamap:This provides more precise context for misconfigurations in YAML manifests and improves the clarity of diagnostic messages.
Additional improvement:
EndLineis now correctly calculated for maps and slices that end with a null node.Related issues:
Related PRs
Checklist