Repository navigation
fix(policy): let an account DENY win over an earlier override ALLOW - #111
Closed
bookingminds wants to merge 2 commits into
Closed
bookingminds wants to merge 2 commits into
bookingminds wants to merge 2 commits into
Conversation
A matching override_broader_scope ALLOW returned ALLOW_FINAL at once, so an account-scope DENY registered after it was never evaluated. The same two rules gave BLOCK or ALLOW depending on registration order. Keep scanning the account group after a matching override. A DENY in the group still wins; the override only skips project-scope evaluation. The first matching override is still the one reported. Closes tetherto#100 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
1 task done
After an override ALLOW is recorded, only a later DENY can change the result. Other rules still ran their conditions, which added their latency and fired stateful conditions such as rate-limit counters. Skip them before their conditions run. Raised by @AlonzoRicardo in review of tetherto#119. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Closing this one: the same fix landed in #119, merged on 15 October, which closed #100. Thanks @Boka44 for merging it and @AlonzoRicardo for the review. For #120: the protocol |
2 tasks done
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.
Description
A matching
override_broader_scopeALLOW returnedALLOW_FINALat once, so an account-scope DENY registered after it was never evaluated.evalGroupnow remembers the first matching override and keeps scanning the account group:The
override_broader_scopeJSDoc no longer says that the first override wins against later DENYs.Motivation and Context
The README says DENY still wins on the same account. Before this change, the same two account rules gave BLOCK or ALLOW depending on registration order.
I also ran a differential check of
evaluate()against those semantics over random policy sets. The sets mix ALLOW and DENY, wildcard and array operations, override flags, and passing, failing or throwing conditions. Each case also runs with the registration order reversed.main, 494 of 20,000 cases differ from the documented outcome. In 710 cases the outcome changes when the registration order is reversed.The script is not part of this PR. I can add it as a test if that is useful.
Related Issue
Closes #100
Type of change
Verification
npm ci,npm test(184 passed) andnpm run lintpass.test.eachcovers both registration orders through the public API. It fails onmainfor the override-first order.types/src/policy/policy-engine.d.ts, only the changed JSDoc line is updated. A fullnpm run build:typeson my machine rewrote 13 unrelated declaration files, so I left those out.Prepared with Claude Code. I reproduced the bug and ran the tests and lint.