Skip to content

fix(shield): wrap response_actions rules in cluster.rbac.create guard#2604

Closed
EdwardArchive wants to merge 1 commit intosysdiglabs:mainfrom
EdwardArchive:fix/shield-clusterrole-rbac-create-2603
Closed

fix(shield): wrap response_actions rules in cluster.rbac.create guard#2604
EdwardArchive wants to merge 1 commit intosysdiglabs:mainfrom
EdwardArchive:fix/shield-clusterrole-rbac-create-2603

Conversation

@EdwardArchive
Copy link
Copy Markdown
Contributor

The outer {{- if .Values.cluster.rbac.create }} in templates/cluster/clusterrole.yaml closed before the seven response_actions.* rule blocks, so disabling RBAC creation while any response action was enabled left orphaned - apiGroups: sequences. Helm then aborted with cannot unmarshal !!seq into releaseutil.SimpleHead.

Move the closing {{- end }} to the end of the file (matching the pattern in templates/host/clusterrole.yaml) so the entire ClusterRole, including response_actions rules, is suppressed when cluster.rbac.create is false.

Adds a regression unittest and bumps the chart to 1.36.1.

Refs #2603

What this PR does / why we need it:

Checklist

  • Title of the PR starts with type and scope, (e.g. feat(agent,node-analyzer,sysdig-deploy):)
  • Chart Version bumped for the respective charts
  • Variables are documented in the README.md (or README.tpl in some charts)
  • Check GithubAction checks (like lint) to avoid merge-check stoppers
  • All test files are added in the tests folder of their respective chart and have a "_test" suffix

The outer `{{- if .Values.cluster.rbac.create }}` in
templates/cluster/clusterrole.yaml closed before the seven
response_actions.* rule blocks, so disabling RBAC creation while any
response action was enabled left orphaned `- apiGroups:` sequences.
Helm then aborted with `cannot unmarshal !!seq into
releaseutil.SimpleHead`.

Move the closing `{{- end }}` to the end of the file (matching the
pattern in templates/host/clusterrole.yaml) so the entire ClusterRole,
including response_actions rules, is suppressed when
cluster.rbac.create is false.

Adds a regression unittest and bumps the chart to 1.36.1.

Refs sysdiglabs#2603
@EdwardArchive EdwardArchive requested a review from a team as a code owner April 29, 2026 07:41
@github-actions
Copy link
Copy Markdown
Contributor

Hi @EdwardArchive. Thanks for your PR.

After inspecting your changes someone with write access to this repo needs
to approve and run the workflow.

francesco-furlan added a commit that referenced this pull request Apr 29, 2026
The seven `response_actions.*` rule blocks in
`templates/cluster/clusterrole.yaml` lived outside the outer
`{{ if .Values.cluster.rbac.create }} ... {{ end }}` wrapper. With
`cluster.rbac.create: false`, the document head (apiVersion / kind /
metadata / rules:) was correctly suppressed but the per-action rule
snippets still rendered, producing a top-level YAML array that Helm
could not parse:

    Error: YAML parse error on shield/templates/cluster/clusterrole.yaml:
    error unmarshaling JSON: while decoding JSON:
    json: cannot unmarshal array into Go value of type util.SimpleHead

Move the closing `{{ end }}` past the response_actions blocks so the
entire ClusterRole template (including those rules) is suppressed when
`cluster.rbac.create` is false, matching the pattern already used in
`templates/host/clusterrole.yaml`. Bumps the chart to 1.36.1 and adds
regression unittests covering the failure mode.

Reported and originally fixed by @EdwardArchive in #2604; this commit
folds the same change into the broader response_actions RBAC fix on
this branch.

Closes #2603

Co-Authored-By: Edward Kim <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
francesco-furlan added a commit that referenced this pull request Apr 29, 2026
The seven `response_actions.*` rule blocks in
`templates/cluster/clusterrole.yaml` lived outside the outer
`{{ if .Values.cluster.rbac.create }} ... {{ end }}` wrapper. With
`cluster.rbac.create: false`, the document head (apiVersion / kind /
metadata / rules:) was correctly suppressed but the per-action rule
snippets still rendered, producing a top-level YAML array that Helm
could not parse:

    Error: YAML parse error on shield/templates/cluster/clusterrole.yaml:
    error unmarshaling JSON: while decoding JSON:
    json: cannot unmarshal array into Go value of type util.SimpleHead

Move the closing `{{ end }}` past the response_actions blocks so the
entire ClusterRole template (including those rules) is suppressed when
`cluster.rbac.create` is false, matching the pattern already used in
`templates/host/clusterrole.yaml`. Bumps the chart to 1.36.1 and adds
regression unittests covering the failure mode.

Reported and originally fixed by @EdwardArchive in #2604; this commit
folds the same change into the broader response_actions RBAC fix on
this branch.

Closes #2603

Co-Authored-By: Edward Kim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant