Include Helm chart CRD manifests in scan coverage#167
Draft
whitemerch wants to merge 1 commit into
Draft
Conversation
…hrough the Helm resolver pipeline.
|
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.
Motivation
Helm charts can ship CustomResourceDefinitions under
crds/, but the scanner did not analyze them. The Helm dry-run client omitted CRDs from rendered output (IncludeCRDs = false), and those files were also excluded from the filesystem walk after a successful chart render.Changes
Helm resolver
Enable
IncludeCRDsso CRD manifests are part of the rendered output. Stamp YAML CRD files withKICS_HELM_IDmarkers for line mapping, include CRD files in source mapping (including subcharts), and map rendered CRD splits back to their originals when Helm omits inline markers. Multi-document CRD files are handled by attributing sourceless splits to the last known source when they look like a real manifest, and by picking the Nth stamped marker for the Nth document from the same file.JSON CRDs
JSON CRD files are included in scan output but are not stamped (YAML comments would corrupt JSON); findings are reported with degraded line attribution.
Author Checklist
QA Instruction
go test ./pkg/resolver/helm/...make build && ./bin/datadog-iac-scanner scan -p test/fixtures/test_helm_with_crds -t Kubernetes -o /tmp/helm-crd-out— CRD resources fromcrds/should appear in SARIF; no duplicate raw-template findings fromtemplates/.test/fixtures/test_helm_subchartand confirm the subchart CRD undercharts/subchart/crds/is resolved.Impact
Affects CLI scans of repositories that include Helm charts with
crds/. YAML CRDs gain full scan coverage and line mapping; JSON CRDs are scanned with degraded line precision. No changes to rule definitions or SARIF schema.Additional Notes
I submit this contribution under the Apache-2.0 License.