Skip to content

fix: policy.for accepts list of entities and hardens id_hash matching - #499

Merged
sini merged 1 commit into
denful:mainfrom
sini:fix/policy-for-list-entities
May 10, 2026
Merged

sini merged 1 commit into
denful:mainfrom
sini:fix/policy-for-list-entities

Conversation

@sini

@sini sini commented May 9, 2026

Copy link
Copy Markdown
Collaborator

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

  • 760/760 CI tests pass
  • New test: test-for-entity-list — list of entities matches any member
  • New test: test-for-mixed-hash-list — list with mixed id_hash presence, hash-less entries silently dropped
  • 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)

@sini
sini force-pushed the fix/policy-for-list-entities branch from 912dd1e to 19432bf Compare May 9, 2026 20:29
@sini
sini force-pushed the fix/policy-for-list-entities branch from 19432bf to 5a58bc5 Compare May 10, 2026 13:08

@drupol drupol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Diff LGTM

@sini
sini merged commit 4e4dd02 into denful:main May 10, 2026
19 checks passed
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)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants