Add security config validation based on configuration provider#22226
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
Cover three security-critical code paths that had zero test coverage: GLOBAL_SECURE_FIELDS fallback blocking, allowlist bypass, and excluded_checks bypass. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Use specific ConfigurationError in pytest.raises to avoid masking unexpected exceptions. Co-Authored-By: Claude Opus 4.6 <[email protected]>
dd_run_check wraps all errors as Exception, so match on ConfigurationError in the traceback string to verify the correct exception type is raised internally. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add (?s) dotall flag so ConfigurationError match works across newlines in dd_run_check's traceback output. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…cking Add an object-typed `auth_token` field with `require_trusted_provider: true` to the test spec/model and a test asserting that non-string secure fields are blocked from untrusted providers. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Remove the `isinstance(value, str)` early return that let non-string values bypass validation. Non-string values (e.g. object-typed auth_token) from untrusted providers are now blocked; the allowlist escape is applied only to string file paths. Co-Authored-By: Claude Opus 4.6 <[email protected]>
…fault to default providers
AAraKKe
left a comment
There was a problem hiding this comment.
Minimum base checks tests are not running and I think this would actually break unless we bump the minimum base check of all integrations that have been updated. Maybe we can split this into multiple PRs?
Just requesting changes to block the merge in case we rush merge without noticing that.
Reset integration model regenerations, changelogs, and unrelated dependency changes so the branch only contains datadog_checks_base/ diffs. Co-Authored-By: Claude Opus 4.6 <[email protected]>
AAraKKe
left a comment
There was a problem hiding this comment.
Thanks @NouemanKHAL mostly questions from my side, I am approving and let you decide whether to merge and handle the suggestion later.
I still think the nomenclature of this feature is very confusing and hard to follow 😅
| return True | ||
| if security_config.is_provider_trusted(security_config.provider): | ||
| return True | ||
| if isinstance(value, str): |
There was a problem hiding this comment.
question: how do you know this is a path to validate in is_file_path_allowed? A string can be anything, why not making an actual validation?
if isinstance(value, str) and Path(value).is_file()There was a problem hiding this comment.
By design, these security validations were designed for file path parameters only. But it's true, it could be better to handle and have proper error handling in case of misuse of the parameter.
Will address in a follow-up PR if you don't mind.
| return True | ||
| if isinstance(value, str): | ||
| return security_config.is_file_path_allowed(value) | ||
| # auth_token is the only non-string field with require_trusted_provider; |
There was a problem hiding this comment.
question: is this ok? How do you know this is the case? As in, what happens if tomorrow there is a new configuration option that requires trusted provider? Are we overfitting the solution to the currently known fields or we know for sure this is only going to be used for files.
There was a problem hiding this comment.
By design, these security validations were designed for file path parameters only.
What does this PR do?
trust settings from the Agent configuration (trusted providers, file path
allowlist, excluded checks)
model loading, blocking values from untrusted providers unless they're in the file
path allowlist
generated models
checking reader.path against the allowlist, other reader types (e.g. oauth) pass
through
- Regenerate config models across all integrations_( Will be done in a separate PR after datadog-checks-base release with these changes)Depends on: DataDog/datadog-agent#44544
Motivation
https://datadoghq.atlassian.net/browse/AI-5322
Verification Process
release.jsonints 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)Review checklist (to be filled by reviewers)
qa/skip-qalabel if the PR doesn't need to be tested during QA.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged