Repository navigation
fix(dir): refuse an environment variable over any configuration block - #2497
Merged
ramizpolic merged 1 commit intoNov 11, 2026
Merged
Conversation
A variable over a non-leaf key, such as DIRECTORY_DAEMON_RECONCILER, replaced every setting under it, even when empty. The daemon then started with policy evaluation off and served every record despite its configured gate. Each loader now derives the blocks from the keys viper already holds and refuses a variable set for one, naming it. Fixes agntcy#2464 Signed-off-by: sarankumar1325 <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2464
What
A variable for a non-leaf key, like
DIRECTORY_DAEMON_RECONCILER, replaced every setting under that block, even when it was set but empty. With the reconciler block emptied,policy_evaluation.enabledwent back to itsfalsedefault. The daemon then started, produced no verdicts, and served every record while its read gate was configured.As the issue suggests, this is a general rule rather than more entries in the #2462 list:
env.CheckBlocks(prefix, keys)inutils/env. It works out the blocks from the leaf keys the loader already holds (v.AllKeys()after the config is read). Each proper prefix of a key counts as a block. It then refuses any<PREFIX>_<BLOCK>variable that is present in the environment, empty or not, and names it. If a leaf happens to map to the same variable name as a block, the leaf wins.CheckFileOnly, so the policy-specific messages from [Bug]: An environment variable for a policy list silently empties it, and the node starts enforcing nothing #2462 are unchanged.dir-content-policy-enforcement.md.I left the second idea in the issue (refuse to start when policies are configured but
policy_evaluation.enabledis off) out of this PR. It changes a default behaviour, and maintainers may want to decide on it separately.Tests
utils/env:blocks_test.gocovers refusal for nested and top-level blocks (""and"x"), settings still accepted, another prefix ignored, and a leaf that shares a block's variable name.cli/cmd/daemon:TestLoadConfig_RefusesAVariableOverAnyBlock(DIRECTORY_DAEMON_RECONCILER,..._RECONCILER_POLICY_EVALUATION,DIRECTORY_DAEMON_SERVER) fails without the loader change.TestLoadConfig_AcceptsASettingUnderABlockchecks that a leaf setting still works.reconciler/config:RECONCILER_POLICY_EVALUATIONis refused.go testpasses inutils ./env,cli ./cmd/daemon,server ./configandreconciler ./config.golangci-lint runreports 0 issues onutils/envandcli/cmd/daemon.