Repository navigation
fix: policy.for accepts list of entities and hardens id_hash matching - #499
Merged
Merged
Conversation
sini
force-pushed
the
fix/policy-for-list-entities
branch
from
May 9, 2026 20:29
912dd1e to
19432bf
Compare
sini
force-pushed
the
fix/policy-for-list-entities
branch
from
May 10, 2026 13:08
19432bf to
5a58bc5
Compare
charlesfire
pushed a commit
to charlesfire/den
that referenced
this pull request
May 16, 2026
…denful#499) ## Summary - `policy.for` now accepts a single entity or a list of entities as its first argument — matching fires if the context entity's `id_hash` matches any entity in the list - Fixes `policy.for` never applying when users pass `policy.for [ host1 host2 ] (policy.include ...)` — the list had no `id_hash` attribute, so the comparison always failed - Hardens `id_hash` to require non-null on both sides (prevents `null == null` false positives) and filters `_`-prefixed options from the identity hash computation ## Test plan - [x] 760/760 CI tests pass - [x] New test: `test-for-entity-list` — list of entities matches any member - [x] New test: `test-for-mixed-hash-list` — list with mixed `id_hash` presence, hash-less entries silently dropped - [x] New test: `test-for-no-id-hash` — entities without `id_hash` never match - [ ] Manual verification with the reported user pattern: `policy.for [ x86_64-linux.yalova ] (policy.include aspects.tlp)`
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.
Summary
policy.fornow accepts a single entity or a list of entities as its first argument — matching fires if the context entity'sid_hashmatches any entity in the listpolicy.fornever applying when users passpolicy.for [ host1 host2 ] (policy.include ...)— the list had noid_hashattribute, so the comparison always failedid_hashto require non-null on both sides (preventsnull == nullfalse positives) and filters_-prefixed options from the identity hash computationTest plan
test-for-entity-list— list of entities matches any membertest-for-mixed-hash-list— list with mixedid_hashpresence, hash-less entries silently droppedtest-for-no-id-hash— entities withoutid_hashnever matchpolicy.for [ x86_64-linux.yalova ] (policy.include aspects.tlp)