feat(reporthandling): add Helm provenance fields to Source#168
Conversation
Signed-off-by: yugal07 <yashsadhwani544@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR extends the ChangesHelm Provenance Data Contract
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@matthyx Once this lands, raising the kubescape side PR. Let me know if any changes are needed. Thanks |
matthyx
left a comment
There was a problem hiding this comment.
No blocker-level issues from my side. The change is additive and looks safe as proposed.
Adds three optional fields to reporthandling.Source so downstream consumers can trace a rendered Helm resource
back to its chart template and values.yaml keys: HelmTemplateFile (chart-relative template path, e.g.
templates/deployment.yaml), HelmValuesPaths (the dotted .Values.* keys statically traced from the rendered
resource, e.g. ["image.tag","replicaCount"]), and HelmTemplateLine (1-based line in the source template, 0 when
unknown). All three are omitempty and purely additive - existing producers and JSON consumers are unaffected.
Why kubescape needs this: issue kubescape/kubescape#1772 - kubescape fix currently can't produce correct fixes
for Helm charts because Helm's render step drops all backward links from output YAML to the input template +
values key. Earlier attempts (#1215, #1551, #1620, #1628) tried to recover line mapping post-hoc via yqlib and
were unreliable enough that the mapping code was removed in #1995; today Helm-sourced findings either get skipped
or get yq patches applied at rendered-output line numbers against template files, which don't land where users
expect. The follow-up kubescape PR adds a helmprovenance package that walks each chart's templates (resolving
_helpers.tpl includes with a cycle guard) and statically extracts the .Values.* references - both .Values.foo.bar
and (index .Values "foo" "bar") forms - feeding them into these new Source fields during
LoadResourcesFromHelmCharts. The fix handler then routes Helm-sourced resources away from the yq pipeline and
prints actionable guidance pointing users at the specific values.yaml keys to edit, instead of silently skipping
them or corrupting templates. Keeping the schema change here, isolated and additive, lets the kubescape side land
cleanly once an opa-utils tag is cut.
Summary by CodeRabbit