[Backport 7.78.x] Add config provider based security controls for agent checks#48225
Conversation
… ### What does this PR do? Adds `provider` parameter to check configuration to track which config provider (kubernetes, file, etcd, etc.) issued the check config and allow for secure mode when dealing with agent python integrations/checks. Changes: - Add `provider` parameter to `Check.Configure()` method - Add `ConfigProvider()` method to `Check` interface - Update `CheckBase` to store the provider value - Update all check implementations to pass the parameter through #### Configuration Changes Adds new integration security properties: - `integration_ignore_untrusted_file_params`: When enabled, integrations ignore file path parameters from untrusted providers - `integration_file_paths_allowlist`: Allowlist of file paths integrations can access even from untrusted providers - `integration_trusted_providers`: List of trusted providers (defaults to `["file", "remote-config"]`) - `integration_security_excluded_checks`: Integration names excluded from security restrictions These settings enable security controls based on the config provider. Untrusted providers (container labels, pod annotations, ### Motivation Need to track where check configs come from to support provider-based security controls in the agent checks. RFC: https://datadoghq.atlassian.net/wiki/spaces/AI/pages/5802623155/RFC+Remediate+untrusted+checks+configs+in+Integrations Jira: https://datadoghq.atlassian.net/browse/AI-5322 ### Describe how you validated your changes - Updated all check implementations and tests to pass the provider parameter - Added tests in `checkbase_test.go` to verify provider is stored and returned correctly - Existing tests pass with empty string or "provider" placeholder values - Testing in a kubernetes lab environment using both an existing agent docker image and a pipeline docker image from this #47971 where I update the release.json ints core hash to target the latest commit on this branch, and have a http_check configured via pod annotation and testing for the expected output. (currently waiting for CI to redeploy the environment with the new agent docker image from the pipeline) Here is a report detailing the experiment: https://datadoghq.atlassian.net/wiki/spaces/~550367931/pages/6428329336/DEMO+Remediate+untrusted+checks+configs+in+Integrations ### Additional Notes Relates to: DataDog/integrations-core#22226 ### Update (2026-03-19) Addressed review feedback: - **Assert provider in CGo test mocks**: Added `get_check_provider` and `get_check_deprecated_provider` globals with `strdup`/reset/assertions in `testConfigure` and `testConfigureDeprecated`, matching the pattern used for other parameters - **Add `ConfigProvider()` to `check.Info` interface**: For symmetry with `ConfigSource()`, so consumers operating on `Info` references don't need a type assertion to `Check` to read the provider. Updated `MockInfo` accordingly. - **Move `source`/`provider` out of `handleConf` closure**: Assignments were redundantly written twice (once per `handleConf` call). Moved them after both calls alongside `initConfig`/`instanceConfig`. Co-authored-by: noueman.khalikine <[email protected]> (cherry picked from commit 07b2c8d) ___ Co-authored-by: NouemanKHAL <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eac9454ac5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Files inventory check summaryFile checks results against ancestor bb16b07b: Results for datadog-agent_7.78.0~rc.1.git.9.eac9454.pipeline.104016624-1_amd64.deb:No change detected |
Static quality checks✅ Please find below the results from static quality gates Successful checksInfo
10 successful checks with minimal change (< 2 KiB)
On-wire sizes (compressed)
|
Regression DetectorRegression Detector ResultsMetrics dashboard Baseline: bb16b07 Optimization Goals: ✅ No significant changes detected
|
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | docker_containers_cpu | % cpu utilization | -0.91 | [-3.91, +2.09] | 1 | Logs |
Fine details of change detection per experiment
| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|---|---|---|---|---|---|---|
| ➖ | quality_gate_metrics_logs | memory utilization | +0.68 | [+0.43, +0.92] | 1 | Logs bounds checks dashboard |
| ➖ | ddot_logs | memory utilization | +0.33 | [+0.27, +0.39] | 1 | Logs |
| ➖ | tcp_syslog_to_blackhole | ingress throughput | +0.26 | [+0.14, +0.38] | 1 | Logs |
| ➖ | ddot_metrics_sum_cumulativetodelta_exporter | memory utilization | +0.22 | [-0.00, +0.44] | 1 | Logs |
| ➖ | uds_dogstatsd_20mb_12k_contexts_20_senders | memory utilization | +0.10 | [+0.04, +0.16] | 1 | Logs |
| ➖ | quality_gate_idle_all_features | memory utilization | +0.06 | [+0.02, +0.09] | 1 | Logs bounds checks dashboard |
| ➖ | file_to_blackhole_100ms_latency | egress throughput | +0.05 | [-0.02, +0.12] | 1 | Logs |
| ➖ | file_tree | memory utilization | +0.04 | [-0.01, +0.10] | 1 | Logs |
| ➖ | file_to_blackhole_0ms_latency | egress throughput | +0.02 | [-0.45, +0.48] | 1 | Logs |
| ➖ | file_to_blackhole_1000ms_latency | egress throughput | +0.02 | [-0.42, +0.45] | 1 | Logs |
| ➖ | quality_gate_idle | memory utilization | +0.00 | [-0.05, +0.05] | 1 | Logs bounds checks dashboard |
| ➖ | uds_dogstatsd_to_api | ingress throughput | -0.00 | [-0.20, +0.19] | 1 | Logs |
| ➖ | tcp_dd_logs_filter_exclude | ingress throughput | -0.00 | [-0.11, +0.10] | 1 | Logs |
| ➖ | file_to_blackhole_500ms_latency | egress throughput | -0.01 | [-0.40, +0.38] | 1 | Logs |
| ➖ | uds_dogstatsd_to_api_v3 | ingress throughput | -0.01 | [-0.21, +0.19] | 1 | Logs |
| ➖ | docker_containers_memory | memory utilization | -0.04 | [-0.11, +0.03] | 1 | Logs |
| ➖ | otlp_ingest_logs | memory utilization | -0.07 | [-0.16, +0.03] | 1 | Logs |
| ➖ | otlp_ingest_metrics | memory utilization | -0.10 | [-0.25, +0.06] | 1 | Logs |
| ➖ | ddot_metrics_sum_cumulative | memory utilization | -0.20 | [-0.34, -0.05] | 1 | Logs |
| ➖ | ddot_metrics_sum_delta | memory utilization | -0.30 | [-0.46, -0.14] | 1 | Logs |
| ➖ | ddot_metrics | memory utilization | -0.49 | [-0.68, -0.31] | 1 | Logs |
| ➖ | docker_containers_cpu | % cpu utilization | -0.91 | [-3.91, +2.09] | 1 | Logs |
| ➖ | quality_gate_logs | % cpu utilization | -1.45 | [-3.03, +0.12] | 1 | Logs bounds checks dashboard |
Bounds Checks: ✅ Passed
| perf | experiment | bounds_check_name | replicates_passed | observed_value | links |
|---|---|---|---|---|---|
| ✅ | docker_containers_cpu | simple_check_run | 10/10 | 709 ≥ 26 | |
| ✅ | docker_containers_memory | memory_usage | 10/10 | 275.90MiB ≤ 370MiB | |
| ✅ | docker_containers_memory | simple_check_run | 10/10 | 690 ≥ 26 | |
| ✅ | file_to_blackhole_0ms_latency | memory_usage | 10/10 | 0.19GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_0ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | file_to_blackhole_1000ms_latency | memory_usage | 10/10 | 0.23GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_1000ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | file_to_blackhole_100ms_latency | memory_usage | 10/10 | 0.20GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_100ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | file_to_blackhole_500ms_latency | memory_usage | 10/10 | 0.22GiB ≤ 1.20GiB | |
| ✅ | file_to_blackhole_500ms_latency | missed_bytes | 10/10 | 0B = 0B | |
| ✅ | quality_gate_idle | intake_connections | 10/10 | 3 = 3 | bounds checks dashboard |
| ✅ | quality_gate_idle | memory_usage | 10/10 | 173.78MiB ≤ 175MiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | intake_connections | 10/10 | 2 ≤ 3 | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | memory_usage | 10/10 | 502.95MiB ≤ 550MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | intake_connections | 10/10 | 4 ≤ 6 | bounds checks dashboard |
| ✅ | quality_gate_logs | memory_usage | 10/10 | 204.04MiB ≤ 220MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | cpu_usage | 10/10 | 339.19 ≤ 2000 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | intake_connections | 10/10 | 4 ≤ 6 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | memory_usage | 10/10 | 426.50MiB ≤ 475MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
Explanation
Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%
Performance changes are noted in the perf column of each table:
- ✅ = significantly better comparison variant performance
- ❌ = significantly worse comparison variant performance
- ➖ = no significant change in performance
A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".
For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:
-
Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.
-
Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.
-
Its configuration does not mark it "erratic".
CI Pass/Fail Decision
✅ Passed. All Quality Gates passed.
- quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
- quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
a6b9820
into
7.78.x
Backport 07b2c8d from #44544.
What does this PR do?
Adds
providerparameter to check configuration to track which config provider (kubernetes, file, etcd, etc.) issued the check config and allow for secure mode when dealing with agent python integrations/checks.Changes:
providerparameter toCheck.Configure()methodConfigProvider()method toCheckinterfaceCheckBaseto store the provider valueConfiguration Changes
Adds new integration security properties:
integration_ignore_untrusted_file_params: When enabled, integrations ignore file path parameters from untrusted providersintegration_file_paths_allowlist: Allowlist of file paths integrations can access even from untrusted providersintegration_trusted_providers: List of trusted providers (defaults to["file", "remote-config"])integration_security_excluded_checks: Integration names excluded from security restrictionsThese settings enable security controls based on the config provider. Untrusted providers (container labels, pod annotations,
Motivation
Need to track where check configs come from to support provider-based security controls in the agent checks.
RFC: https://datadoghq.atlassian.net/wiki/spaces/AI/pages/5802623155/RFC+Remediate+untrusted+checks+configs+in+Integrations
Jira: https://datadoghq.atlassian.net/browse/AI-5322
Describe how you validated your changes
checkbase_test.goto verify provider is stored and returned correctlyHere is a report detailing the experiment: https://datadoghq.atlassian.net/wiki/spaces/~550367931/pages/6428329336/DEMO+Remediate+untrusted+checks+configs+in+Integrations
Additional Notes
Relates to: DataDog/integrations-core#22226
Update (2026-03-19)
Addressed review feedback:
get_check_providerandget_check_deprecated_providerglobals withstrdup/reset/assertions intestConfigureandtestConfigureDeprecated, matching the pattern used for other parametersConfigProvider()tocheck.Infointerface: For symmetry withConfigSource(), so consumers operating onInforeferences don't need a type assertion toCheckto read the provider. UpdatedMockInfoaccordingly.source/providerout ofhandleConfclosure: Assignments were redundantly written twice (once perhandleConfcall). Moved them after both calls alongsideinitConfig/instanceConfig.