Skip to content

feat: GOMEMLIMIT at 80% of memory limit for node-agent + kubevuln#827

Merged
matthyx merged 23 commits intomainfrom
feature/gomemlimit-80pct
Apr 29, 2026
Merged

feat: GOMEMLIMIT at 80% of memory limit for node-agent + kubevuln#827
matthyx merged 23 commits intomainfrom
feature/gomemlimit-80pct

Conversation

@slashben
Copy link
Copy Markdown
Contributor

@slashben slashben commented Apr 28, 2026

Memory-reduction rollout (NAUT-1283)

Reduces node-agent + kubevuln scan peak RSS by 30.7% on gitlab-ee
(1,621 MB → 1,123 MB), fitting a 1.5 GB cgroup with 377 MB margin.

Measured deltas (gitlab-ee, 113,836 files; kernel peak RSS via /usr/bin/time -v)

Variant Peak RSS Δ vs main+all-cats
main + all catalogers 1,621 MB baseline
main + file-cats off 1,419 MB −202 MB
selective + file-cats off 1,184 MB −437 MB
combined + file-cats off 1,123 MB −498 MB (−30.7%)

Initiative status

  • Initiative 1 — disable file catalogers (this PR for node-agent / kubevuln)
  • Initiative 2 — binary-cataloger prefilter (in kubescape/syft v1.32.0-ks.2)
  • Initiative 3 — selective indexing (in kubescape/syft v1.32.0-ks.2)
  • Initiative 4 — parallelism = 1 (already in place: node-agent uses workerpool.New(1); kubevuln scanConcurrency defaults to 1)
  • Initiative 5 — GOMEMLIMIT at 80% of cgroup (this PR for helm-charts)

Cross-repo PRs

  • helm-charts: kubescape/helm-charts#PENDING_HELM
  • node-agent: kubescape/node-agent#PENDING_NA
  • kubevuln: kubescape/kubevuln#PENDING_KV

Audit

Pre-merge audit confirmed no production-path consumer reads
sbom.Files[*].Digests or sbom.Files[*].Metadata in node-agent,
kubevuln, or kubescape/storage. The two storage consumers
(containerprofile_processor.go:172, applicationprofile_processor.go:67)
only read f.Location.RealPath, which the directory walker still
populates regardless of file-cataloger disable. Selective indexing also
keeps 99.9% of the file-path coverage on gitlab-ee
(113,265 of 113,382 paths).

Reference: shared-designs-and-docs/syft-memory-improvement/2026-04-28-rollout-design.md

Summary by CodeRabbit

  • New Features

    • Configurable Go runtime memory limit percentage for kubevuln and node-agent (default 0.8); GOMEMLIMIT is now derived via chart logic.
    • SBOM scanner sidecar made optional and configurable in autoscaler mode; SBOM-related memory rules updated.
  • Documentation

    • Updated autoscaler docs with memory tuning, GOMEMLIMIT behavior, and SBOM sidecar guidance.
  • Tests

    • Added snapshot scenarios covering autoscaler mode with/without SBOM scanner.
  • Chores

    • Updated container image tags for operator, kubevuln, and node-agent.
    • CI workflow adjusted for direct scanning and SARIF handling.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Warning

Rate limit exceeded

@matthyx has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 51 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aefe41ef-6c59-41f9-bfd1-516d55280d32

📥 Commits

Reviewing files that changed from the base of the PR and between 7e38dc5 and df2152a.

⛔ Files ignored due to path filters (1)
  • charts/kubescape-operator/tests/__snapshot__/snapshot_test.yaml.snap is excluded by !**/*.snap
📒 Files selected for processing (9)
  • .github/workflows/kubescape.yaml
  • charts/kubescape-operator/templates/_helpers.tpl
  • charts/kubescape-operator/templates/kubevuln/deployment.yaml
  • charts/kubescape-operator/templates/node-agent/_node-agent.tpl
  • charts/kubescape-operator/templates/node-agent/template-configmap.yaml
  • charts/kubescape-operator/templates/operator/configmap.yaml
  • charts/kubescape-operator/tests/snapshot_test.yaml
  • charts/kubescape-operator/values.yaml
  • docs/node-agent-autoscaler.md
📝 Walkthrough

Walkthrough

Helm templates add helpers to compute GOMEMLIMIT from container memory settings, replace downward API usage with template-driven calculations, add configurable gomemlimitPercentage for kubevuln and node-agent, and make SBOM-scanner inclusion/behavior configurable across node-agent templates and configmap.

Changes

Cohort / File(s) Summary
Helm template helpers
charts/kubescape-operator/templates/_helpers.tpl
Add kubescape-operator.convertMemToBytes (parses K8s memory quantities) and kubescape-operator.gomemlimit (computes percentage of memory, returns MiB string).
kubevuln deployment
charts/kubescape-operator/templates/kubevuln/deployment.yaml
Replace resourceFieldRef-derived GOMEMLIMIT with template-computed value via kubescape-operator.gomemlimit; emit only when resources.limits.memory present; applies to main container and sbom-scanner.
node-agent templates
charts/kubescape-operator/templates/node-agent/_node-agent.tpl, charts/kubescape-operator/templates/node-agent/template-configmap.yaml
Compute GOMEMLIMIT via chart helpers in non-autoscaler mode and via .GoMemLimit in autoscaler mode; pass resources into env template; SBOM scanner inclusion made configurable and its GOMEMLIMIT emitted only when its limits are set.
operator config & values
charts/kubescape-operator/templates/operator/configmap.yaml, charts/kubescape-operator/values.yaml
Add goMemLimitPercentage to operator config; add kubevuln.gomemlimitPercentage and nodeAgent.gomemlimitPercentage (default 0.8) in values; conditional 600Mi min memory rule adjusted based on SBOM capability and sidecar enablement; image tag bumps.
Tests & docs
charts/kubescape-operator/tests/snapshot_test.yaml, docs/node-agent-autoscaler.md
Add autoscaler-mode snapshot cases (with/without SBOM sidecar); document gomemlimitPercentage, SBOM sidecar behavior, and adjusted min-memory rules.
CI workflow
.github/workflows/kubescape.yaml
Replace action-based scan with direct Kubescape CLI download & run, post-process SARIF, add permissions and upload-sarif@v3; guard for empty SARIF.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I nibble templates late at night,
Converting bytes till morning light,
Percentages set to keep Go tame,
Sidecars join the memory game,
Helm hops forward — code takes flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: setting GOMEMLIMIT to 80% of memory limit for node-agent and kubevuln, which is the primary objective reflected throughout the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/gomemlimit-80pct

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 51 minutes and 51 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@slashben
Copy link
Copy Markdown
Contributor Author

@matthyx — these three PRs implement the syft memory-reduction work we discussed (NAUT-1283). The combined effect is -498 MB peak RSS on gitlab-ee (1,621 → 1,123 MB), fitting the 1.5 GB cgroup with margin. The syft side is a clean two-commit branch on kubescape/syft tagged v1.32.0-ks.2 (rebased on anchore v1.32.0 per your "two commits" request). Cross-linked PRs:

Whenever you have a moment.

Comment thread charts/kubescape-operator/templates/_helpers.tpl Outdated
Comment thread charts/kubescape-operator/templates/node-agent/_node-agent.tpl
@matthyx matthyx moved this to Waiting on Author in KS PRs tracking Apr 28, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/node-agent-autoscaler.md (1)

187-189: Add language specifier to fenced code block.

The fenced code block should have a language specifier for consistent rendering and to satisfy linting. Since this is a formula/pseudocode, text is appropriate.

📝 Proposed fix
-```
+```text
 GOMEMLIMIT = floor(memoryLimit × gomemlimitPercentage)
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @docs/node-agent-autoscaler.md around lines 187 - 189, The fenced code block
containing the formula "GOMEMLIMIT = floor(memoryLimit × gomemlimitPercentage)"
lacks a language specifier; update that block to use a language tag (use "text")
so the block becomes text ... to satisfy linting and ensure consistent
rendering—find the block with the symbols GOMEMLIMIT, memoryLimit, and
gomemlimitPercentage and add the "text" specifier.


</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against the current code and only fix it if needed.

Inline comments:
In @charts/kubescape-operator/templates/_helpers.tpl:

  • Around line 115-117: The convertMemToBytes helper misses an else branch to
    handle bare numeric memory strings (raw byte counts); add an else after the
    existing hasSuffix checks (the block that checks "Gi", "Mi", "m") that trims the
    value and converts it to a float64 directly (no division) so $mem becomes a
    numeric byte count for downstream float operations; update the code around the
    hasSuffix "Gi"/"Mi"/"m" conditions (the $mem variable assignment logic) to
    include this fallback.

Nitpick comments:
In @docs/node-agent-autoscaler.md:

  • Around line 187-189: The fenced code block containing the formula "GOMEMLIMIT
    = floor(memoryLimit × gomemlimitPercentage)" lacks a language specifier; update
    that block to use a language tag (use "text") so the block becomes ```text ...
symbols GOMEMLIMIT, memoryLimit, and gomemlimitPercentage and add the "text"
specifier.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c41c6c75-de49-4015-9fc2-ee7b4d904cb9

📥 Commits

Reviewing files that changed from the base of the PR and between ff1b3a9 and b9b7f83.

⛔ Files ignored due to path filters (1)
  • charts/kubescape-operator/tests/__snapshot__/snapshot_test.yaml.snap is excluded by !**/*.snap
📒 Files selected for processing (8)
  • charts/kubescape-operator/templates/_helpers.tpl
  • charts/kubescape-operator/templates/kubevuln/deployment.yaml
  • charts/kubescape-operator/templates/node-agent/_node-agent.tpl
  • charts/kubescape-operator/templates/node-agent/template-configmap.yaml
  • charts/kubescape-operator/templates/operator/configmap.yaml
  • charts/kubescape-operator/tests/snapshot_test.yaml
  • charts/kubescape-operator/values.yaml
  • docs/node-agent-autoscaler.md

Comment on lines +115 to +117
{{- else if hasSuffix "m" $mem -}}
{{- $mem = divf (trimSuffix "m" $mem | float64) 1e3 -}}
{{- end }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing fallback for bare numeric memory values.

The convertMemToBytes helper is missing the else clause to handle bare numeric values (e.g., "1073741824"), which are valid Kubernetes memory quantities. If a user specifies memory as a raw byte count, the string won't be converted and subsequent float operations may fail or produce incorrect results.

🐛 Proposed fix to handle bare numbers
   {{- else if hasSuffix "m" $mem -}}
     {{- $mem = divf (trimSuffix "m" $mem | float64) 1e3 -}}
+  {{- else -}}
+    {{- $mem = ($mem | float64) -}}
   {{- end }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{{- else if hasSuffix "m" $mem -}}
{{- $mem = divf (trimSuffix "m" $mem | float64) 1e3 -}}
{{- end }}
{{- else if hasSuffix "m" $mem -}}
{{- $mem = divf (trimSuffix "m" $mem | float64) 1e3 -}}
{{- else -}}
{{- $mem = ($mem | float64) -}}
{{- end }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/kubescape-operator/templates/_helpers.tpl` around lines 115 - 117, The
convertMemToBytes helper misses an else branch to handle bare numeric memory
strings (raw byte counts); add an else after the existing hasSuffix checks (the
block that checks "Gi", "Mi", "m") that trims the value and converts it to a
float64 directly (no division) so $mem becomes a numeric byte count for
downstream float operations; update the code around the hasSuffix "Gi"/"Mi"/"m"
conditions (the $mem variable assignment logic) to include this fallback.

slashben and others added 21 commits April 29, 2026 16:48
Two helpers for computing GOMEMLIMIT as a percentage of a memory limit:
- convertMemToBytes: parse a Kubernetes memory string into a byte count
- gomemlimit: format "<N>MiB" from memory + percentage

Adapted from the Traefik helm chart's traefik.gomemlimit pattern.

Refs: NAUT-1283
Signed-off-by: Ben <ben@armosec.io>
Defaults to 0.8 (80%). Used by the kubescape-operator.gomemlimit helper to
compute GOMEMLIMIT from resources.limits.memory.

Refs: NAUT-1283
Signed-off-by: Ben <ben@armosec.io>
Replaces resourceFieldRef-based GOMEMLIMIT (= 100% of limit) with the
kubescape-operator.gomemlimit helper, gated on nodeAgent.gomemlimitPercentage.

Refs: NAUT-1283
Signed-off-by: Ben <ben@armosec.io>
Replaces resourceFieldRef-based GOMEMLIMIT (= 100% of limit) with the
kubescape-operator.gomemlimit helper, gated on kubevuln.gomemlimitPercentage.

Refs: NAUT-1283
Signed-off-by: Ben <ben@armosec.io>
Snapshot now records value-based GOMEMLIMIT entries computed by
kubescape-operator.gomemlimit (= 0.8 of limits.memory) instead of
resourceFieldRef.

Refs: NAUT-1283
Signed-off-by: Ben <ben@armosec.io>
…o node-agent.env

- convertMemToBytes: remove lower() call which confused M (mega, 1e6) with
  m (milli, 1e-3); use proper Kubernetes SI/BinarySI case (Gi/Mi/Ki for
  binary, G/M/k for decimal) — binary two-char checked before decimal one-char
- node-agent.env: accept optional resources parameter and prefer it over the
  default .Values.nodeAgent.resources.limits.memory, so multipleDaemonSets
  configurations each get a GOMEMLIMIT that matches their own container limit
- Update snapshot after template change
Signed-off-by: Ben <ben@armosec.io>
…telUrl null fields

Six test cases were generated from a cached docker image that didn't render
configurations.excludeJsonPaths and configurations.otelUrl null values;
re-run with fresh pull to match CI output exactly
Signed-off-by: Ben <ben@armosec.io>
…om env in autoscaler

Signed-off-by: Ben <ben@armosec.io>
When sbomScanner is enabled, include it in the autoscaler-managed DaemonSet
template so that SBOM_SCANNER_SOCKET env var and the sidecar container are
consistent with each other.
Signed-off-by: Ben <ben@armosec.io>
…0Mi bump

Add goMemLimitPercentage to nodeAgentAutoscaler config so the operator
knows what percentage to use when computing GOMEMLIMIT per node group.

Fix the 600Mi memory minimum bump: it was unconditionally applied when
nodeSbomGeneration was enabled, but when the sbom-scanner sidecar is present
the main node-agent container does not do SBOM generation, so the extra
headroom is unnecessary. Now only bumps to 600Mi when nodeSbomGeneration=enabled
AND sbomScanner sidecar is NOT enabled.
Signed-off-by: Ben <ben@armosec.io>
… check

Non-empty strings like "disable" are truthy in Go templates, so bare
.Values.capabilities.nodeSbomGeneration would incorrectly trigger the
600Mi bump even when explicitly disabled. Match the pattern used throughout
the chart (eq ... "enable").
Signed-off-by: Ben <ben@armosec.io>
Update 18 failing snapshot assertions caused by operator configmap
content changes (goMemLimitPercentage field + 600Mi bump fix).

Add two autoscaler snapshot test cases:
- without sbom sidecar: verifies 600Mi bump and no sidecar container
- with sbom sidecar: verifies 180Mi (no bump) and sidecar included
Signed-off-by: Ben <ben@armosec.io>

# Conflicts:
#	charts/kubescape-operator/tests/snapshot_test.yaml
Signed-off-by: Ben <ben@armosec.io>
Document the new goMemLimitPercentage parameter, how GOMEMLIMIT is computed
per node group at reconcile time, the sbom sidecar in autoscaler mode, and
the corrected 600Mi bump condition (only when sbomScanner sidecar is disabled).
Signed-off-by: Ben <ben@armosec.io>
Signed-off-by: Ben <ben@armosec.io>
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…ove scan results handling

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…days

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
matthyx added 2 commits April 29, 2026 16:49
Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…108 respectively

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
@matthyx matthyx force-pushed the feature/gomemlimit-80pct branch from 7e38dc5 to df2152a Compare April 29, 2026 14:49
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
charts/kubescape-operator/tests/snapshot_test.yaml (1)

569-620: ⚠️ Potential issue | 🟡 Minor

Note that the new test cases follow the existing accessKey dummy value pattern used throughout the snapshot test file

The accessKey: f304d73b-d43c-412b-82ea-e4c859493ce6 value appears in all 23 test cases in this file (not newly introduced by this PR). While security scanners may flag it, this is a pre-existing test hygiene pattern. If replacing it is desired, apply the change uniformly across all test cases and regenerate snapshots accordingly.

The new autoscaler test cases can optionally be made more explicit by adding nodeAgent.gomemlimitPercentage: 0.8 (the chart default), though this is not required since chart defaults will apply during snapshot generation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/kubescape-operator/tests/snapshot_test.yaml` around lines 569 - 620,
The snapshot tests currently reuse the existing dummy accessKey value
(accessKey: f304d73b-d43c-412b-82ea-e4c859493ce6) across many cases which may
trigger scanners; either leave it as-is to match the project's existing pattern
or replace it uniformly in all 23 test cases and regenerate snapshots;
additionally, if you want the new autoscaler scenarios to explicitly reflect
chart defaults, add nodeAgent.gomemlimitPercentage: 0.8 under the nodeAgent
block in the two new cases (nodeAgent.autoscaler and nodeAgent.sbomScanner
remain as shown) and then run the snapshot regeneration so tests remain
consistent.
🧹 Nitpick comments (1)
charts/kubescape-operator/tests/snapshot_test.yaml (1)

575-594: Make nodeAgent.gomemlimitPercentage explicit in the autoscaler snapshot scenarios

This PR’s objective includes setting GOMEMLIMIT at 80%. These two new autoscaler snapshots don’t explicitly set nodeAgent.gomemlimitPercentage, so they may rely on chart defaults (which can change and silently weaken the coverage).

I recommend adding nodeAgent.gomemlimitPercentage: 80 to both scenarios so the snapshot asserts the intended behavior directly.

🛠️ Proposed change
   - it: autoscaler mode without sbom sidecar
     ...
     set:
       unittest: true
       account: 9e6c0c2c-6bd0-4919-815b-55030de7c9a0
       accessKey: ...
       server: api.armosec.io
       clusterName: kind-kind
+      nodeAgent.gomemlimitPercentage: 80
       kubescapeScheduler.scanSchedule: "1 2 3 4 5"
       kubevulnScheduler.scanSchedule: "1 2 3 4 5"
       capabilities:
         ...

   - it: autoscaler mode with sbom sidecar
     ...
     set:
       unittest: true
       account: 9e6c0c2c-6bd0-4919-815b-55030de7c9a0
       accessKey: ...
       server: api.armosec.io
       clusterName: kind-kind
+      nodeAgent.gomemlimitPercentage: 80
       kubescapeScheduler.scanSchedule: "1 2 3 4 5"
       kubevulnScheduler.scanSchedule: "1 2 3 4 5"
       capabilities:
         ...

Confirm the exact values key expected by the chart templates (and whether kubevuln needs an explicit kubevuln.gomemlimitPercentage too) so this remains stable and doesn’t become a no-op.

Also applies to: 601-620

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/kubescape-operator/tests/snapshot_test.yaml` around lines 575 - 594,
Add an explicit gomemlimitPercentage key set to 80 in the autoscaler snapshot
scenarios so the chart assertions don't rely on defaults: update the YAML under
the existing nodeAgent block (near the autoscaler and sbomScanner entries) to
include nodeAgent.gomemlimitPercentage: 80 for both snapshots; also verify
whether kubevuln expects an explicit kubevuln.gomemlimitPercentage and, if
required, add kubevuln.gomemlimitPercentage: 80 alongside the existing
kubevulnScheduler keys to ensure the snapshots assert the intended GOMEMLIMIT
value.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/kubescape.yaml:
- Around line 39-44: Download and verify the Kubescape release checksum before
executing the binary: after constructing binary and before chmod/exec, fetch the
corresponding checksum (or signature) for KUBESCAPE_VERSION/version_no_prefix
and arch from the release assets, validate the downloaded "$binary" by checking
its SHA256 (or verifying the signature) using a checksum verification step
(e.g., sha256sum -c or gpg verification), and fail the workflow if verification
does not pass; reference the variables binary, KUBESCAPE_VERSION,
version_no_prefix, arch, RUNNER_TEMP and ensure the verification step runs prior
to "$binary" version.
- Around line 15-23: The workflow currently resolves Kubescape via the
releases/latest API in the step named "Resolve Kubescape version" (id:
kubescape-version), which makes CI non-deterministic; replace the runtime
curl/jq logic with a pinned, explicit version string (e.g., set an output or
environment variable like KUBESCAPE_VERSION with the fixed tag) and update any
later steps that consume steps.kubescape-version.outputs.version to use that
pinned value instead; remove the curl/jq commands and ensure the step emits the
fixed version as the same output name so downstream usage (by id
kubescape-version) continues to work.

---

Outside diff comments:
In `@charts/kubescape-operator/tests/snapshot_test.yaml`:
- Around line 569-620: The snapshot tests currently reuse the existing dummy
accessKey value (accessKey: f304d73b-d43c-412b-82ea-e4c859493ce6) across many
cases which may trigger scanners; either leave it as-is to match the project's
existing pattern or replace it uniformly in all 23 test cases and regenerate
snapshots; additionally, if you want the new autoscaler scenarios to explicitly
reflect chart defaults, add nodeAgent.gomemlimitPercentage: 0.8 under the
nodeAgent block in the two new cases (nodeAgent.autoscaler and
nodeAgent.sbomScanner remain as shown) and then run the snapshot regeneration so
tests remain consistent.

---

Nitpick comments:
In `@charts/kubescape-operator/tests/snapshot_test.yaml`:
- Around line 575-594: Add an explicit gomemlimitPercentage key set to 80 in the
autoscaler snapshot scenarios so the chart assertions don't rely on defaults:
update the YAML under the existing nodeAgent block (near the autoscaler and
sbomScanner entries) to include nodeAgent.gomemlimitPercentage: 80 for both
snapshots; also verify whether kubevuln expects an explicit
kubevuln.gomemlimitPercentage and, if required, add
kubevuln.gomemlimitPercentage: 80 alongside the existing kubevulnScheduler keys
to ensure the snapshots assert the intended GOMEMLIMIT value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 545b5c92-dc59-417c-a495-1462a85e5d8f

📥 Commits

Reviewing files that changed from the base of the PR and between b9b7f83 and 7e38dc5.

⛔ Files ignored due to path filters (1)
  • charts/kubescape-operator/tests/__snapshot__/snapshot_test.yaml.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • .github/workflows/kubescape.yaml
  • charts/kubescape-operator/tests/snapshot_test.yaml
  • charts/kubescape-operator/values.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • charts/kubescape-operator/values.yaml

Comment on lines +15 to +23
- name: Resolve Kubescape version
id: kubescape-version
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
version="$(curl -fsSL -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/kubescape/kubescape/releases/latest | jq -r .tag_name)"
test -n "$version"
test "$version" != "null"
echo "version=$version" >> "$GITHUB_OUTPUT"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify where dynamic "latest" resolution is used in workflows.
rg -n 'repos/kubescape/kubescape/releases/latest' .github/workflows -C2

Repository: kubescape/helm-charts

Length of output: 527


Pin Kubescape version instead of resolving releases/latest at runtime.

This makes scan behavior non-deterministic and can break CI unexpectedly when upstream releases change.

♻️ Suggested change
-      - name: Resolve Kubescape version
+      - name: Resolve Kubescape version (pinned)
         id: kubescape-version
-        env:
-          GITHUB_TOKEN: ${{ github.token }}
         run: |
-          version="$(curl -fsSL -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/kubescape/kubescape/releases/latest | jq -r .tag_name)"
+          version="${KUBESCAPE_VERSION:?Set repository variable KUBESCAPE_VERSION (e.g. vX.Y.Z)}"
           test -n "$version"
           test "$version" != "null"
           echo "version=$version" >> "$GITHUB_OUTPUT"
+        env:
+          KUBESCAPE_VERSION: ${{ vars.KUBESCAPE_VERSION }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Resolve Kubescape version
id: kubescape-version
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
version="$(curl -fsSL -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/kubescape/kubescape/releases/latest | jq -r .tag_name)"
test -n "$version"
test "$version" != "null"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Resolve Kubescape version (pinned)
id: kubescape-version
run: |
version="${KUBESCAPE_VERSION:?Set repository variable KUBESCAPE_VERSION (e.g. vX.Y.Z)}"
test -n "$version"
test "$version" != "null"
echo "version=$version" >> "$GITHUB_OUTPUT"
env:
KUBESCAPE_VERSION: ${{ vars.KUBESCAPE_VERSION }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/kubescape.yaml around lines 15 - 23, The workflow
currently resolves Kubescape via the releases/latest API in the step named
"Resolve Kubescape version" (id: kubescape-version), which makes CI
non-deterministic; replace the runtime curl/jq logic with a pinned, explicit
version string (e.g., set an output or environment variable like
KUBESCAPE_VERSION with the fixed tag) and update any later steps that consume
steps.kubescape-version.outputs.version to use that pinned value instead; remove
the curl/jq commands and ensure the step emits the fixed version as the same
output name so downstream usage (by id kubescape-version) continues to work.

Comment on lines +39 to +44
binary="$RUNNER_TEMP/bin/kubescape"
mkdir -p "$(dirname "$binary")"
curl -fsSL "https://github.com/kubescape/kubescape/releases/download/${KUBESCAPE_VERSION}/kubescape_${version_no_prefix}_linux_${arch}" -o "$binary"
chmod +x "$binary"
echo "$(dirname "$binary")" >> "$GITHUB_PATH"
"$binary" version
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In kubescape/kubescape GitHub releases, what checksum or signature asset should be used to verify Linux CLI binaries, and what is the recommended verification command?

💡 Result:

Use the “checksums.sha256” asset (SHA-256 checksum list published in each kubescape/kubescape GitHub release) to verify the Linux CLI binaries. Kubescape does not indicate GPG/PGP signature assets for the Linux CLI binaries in the release assets; instead it provides the SHA-256 checksums file. Recommended verification command (after downloading both the Linux binary and the corresponding checksums.sha256): sha256sum --check checksums.sha256 (You can run it from the directory containing the downloaded kubescape Linux binary and the checksums.sha256 file.)

Citations:


Verify binary integrity before executing the downloaded Kubescape CLI.

The workflow executes a downloaded binary without checksum validation, which weakens supply-chain security posture.

🔐 Suggested change
           version_no_prefix="${KUBESCAPE_VERSION#v}"
           binary="$RUNNER_TEMP/bin/kubescape"
+          asset="kubescape_${version_no_prefix}_linux_${arch}"
+          checksums="$RUNNER_TEMP/kubescape_checksums.sha256"
           mkdir -p "$(dirname "$binary")"
-          curl -fsSL "https://github.com/kubescape/kubescape/releases/download/${KUBESCAPE_VERSION}/kubescape_${version_no_prefix}_linux_${arch}" -o "$binary"
+          curl -fsSL "https://github.com/kubescape/kubescape/releases/download/${KUBESCAPE_VERSION}/${asset}" -o "$binary"
+          curl -fsSL "https://github.com/kubescape/kubescape/releases/download/${KUBESCAPE_VERSION}/checksums.sha256" -o "$checksums"
+          grep " ${asset}$" "$checksums" | sha256sum -c -
           chmod +x "$binary"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/kubescape.yaml around lines 39 - 44, Download and verify
the Kubescape release checksum before executing the binary: after constructing
binary and before chmod/exec, fetch the corresponding checksum (or signature)
for KUBESCAPE_VERSION/version_no_prefix and arch from the release assets,
validate the downloaded "$binary" by checking its SHA256 (or verifying the
signature) using a checksum verification step (e.g., sha256sum -c or gpg
verification), and fail the workflow if verification does not pass; reference
the variables binary, KUBESCAPE_VERSION, version_no_prefix, arch, RUNNER_TEMP
and ensure the verification step runs prior to "$binary" version.

@matthyx matthyx merged commit b4b59cf into main Apr 29, 2026
9 checks passed
@matthyx matthyx deleted the feature/gomemlimit-80pct branch April 29, 2026 15:16
@matthyx matthyx moved this from Waiting on Author to To Archive in KS PRs tracking Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants