Skip to content

feat(appsec): forward sidecar injection mode and istio-gateway config to cluster-agent#2774

Open
eliottness wants to merge 5 commits intomainfrom
eliottness/appsec-sidecar-istio-gateway-forwarding
Open

feat(appsec): forward sidecar injection mode and istio-gateway config to cluster-agent#2774
eliottness wants to merge 5 commits intomainfrom
eliottness/appsec-sidecar-istio-gateway-forwarding

Conversation

@eliottness
Copy link
Contributor

@eliottness eliottness commented Mar 18, 2026

What does this PR do?

Forwards three sets of new AppSec configuration from the operator to the cluster-agent, covering changes introduced in recent datadog-agent PRs:

  1. [APPSEC-61552] Support networking.istio.io/v1 Gateway objects for injection datadog-agent#47263 — adds "istio-gateway" to the list of allowed appsec.injector.proxies values so operators can select it via annotation.
  2. [APPSEC] Fix injection validation and testing RBAC for istio-gateway and envoy-gateway datadog-agent#47926 — adds Get/List/Watch on networking.istio.io/gateways so the cluster-agent's informer works for the Istio Gateway integration.
  3. [APPSEC-60795] Appsec Injector with sidecars using admission controller datadog-agent#45331 — adds AnnotationInjectorMode + 9 AnnotationSidecar* annotations and their corresponding env vars (DD_CLUSTER_AGENT_APPSEC_INJECTOR_MODE, DD_ADMISSION_CONTROLLER_APPSEC_SIDECAR_*) that the cluster-agent reads.

Motivation

The operator was not forwarding any of these configs, meaning users on sidecar mode or using the Istio Gateway integration had to set env vars manually on the cluster-agent. This closes that gap.

Describe your test plan

  • go test ./internal/controller/datadogagent/feature/appsec/...
  • golangci-ling -w ./internal/controller/datadogagent/feature/appsec/...

Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies
  • PR has a milestone or the qa/skip-qa label
  • All commits are signed (see: signing commits)

… to cluster-agent

- Add "istio-gateway" to allowed proxy values (networking.istio.io/gateways informer)
- Add RBAC rule for gateways.networking.istio.io (Get/List/Watch)
- Add RBAC rule for configmaps (Get/Update) picked up by linter
- Add AnnotationInjectorMode + 9 AnnotationSidecar* annotation constants
- Add DDClusterAgentAppsecInjectorMode + 9 DDAdmissionControllerAppsecSidecar* env var constants
- Add Mode and sidecar fields to Config struct; parse from annotations in FromAnnotations()
- Relax validation: ProcessorServiceName now only required in external mode (not sidecar)
- Forward all new env vars in ManageClusterAgent() via a map[string]string loop
- Update rbac_test.go: split Istio rule test, add gateways assertion
- Update feature_test.go: add sidecar mode, istio-gateway proxy, and mode validation test cases

Rationale: Three recent datadog-agent PRs (#45331, #47263, #47926) introduced sidecar
injection mode, istio-gateway as a new proxy type, and the corresponding RBAC requirements.
The operator was not forwarding any of these configs to the cluster-agent. This change
closes that gap so operators using sidecar mode or the Istio Gateway integration get the
correct cluster-agent configuration without manual env var overrides.
@eliottness eliottness modified the milestones: v1.25.0, v1.26.0 Mar 18, 2026
@eliottness eliottness added enhancement New feature or request qa/skip-qa labels Mar 18, 2026
- Bump ClusterAgentMinVersion from 7.73.0 to 7.76.0
- Update version boundary tests to match new minimum
- Commit go.work.sum update
@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 97.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.02%. Comparing base (8931a7b) to head (18fa96a).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../controller/datadogagent/feature/appsec/feature.go 88.88% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2774      +/-   ##
==========================================
+ Coverage   38.81%   39.02%   +0.20%     
==========================================
  Files         309      309              
  Lines       26803    27153     +350     
==========================================
+ Hits        10404    10596     +192     
- Misses      15620    15776     +156     
- Partials      779      781       +2     
Flag Coverage Δ
unittests 39.02% <97.33%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...l/controller/datadogagent/feature/appsec/config.go 100.00% <100.00%> (+5.12%) ⬆️
...al/controller/datadogagent/feature/appsec/const.go 100.00% <ø> (ø)
...nal/controller/datadogagent/feature/appsec/rbac.go 100.00% <100.00%> (ø)
.../controller/datadogagent/feature/appsec/feature.go 68.04% <88.88%> (+7.81%) ⬆️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8931a7b...18fa96a. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eliottness eliottness marked this pull request as ready for review March 19, 2026 11:05
@eliottness eliottness requested a review from a team March 19, 2026 11:05
@eliottness eliottness requested a review from a team as a code owner March 19, 2026 11:05
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43ea9f6186

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…nd body parsing limit

- Validate SidecarPort and SidecarHealthPort using k8s IsValidPortNum (1-65535)
- Validate SidecarBodyParsingSizeLimit is a non-zero integer (negative disables body parsing)
- Validate sidecar resource quantities (CPU/memory) using resource.ParseQuantity
- Add test cases covering all new validation paths
strconv.Itoa(0) produces the non-empty string '0', causing
DD_APPSEC_PROXY_PROCESSOR_PORT=0 to be injected even when the
annotation is not set. Move processor port out of the string map
and guard it with != 0, matching the original per-field pattern.
Add a test case to assert the env var is absent when unset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request qa/skip-qa

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants