fix(engine): include inputTokenPattern in deny-hook ruleSignature identity - #8127
Closed
JSONbored wants to merge 1 commit into
Closed
fix(engine): include inputTokenPattern in deny-hook ruleSignature identity#8127JSONbored wants to merge 1 commit into
JSONbored wants to merge 1 commit into
Conversation
…ntity
ruleSignature (the identity function resolveEffectiveDenyRules and
synthesizeDenyRuleProposals use to decide "is this the same rule")
omitted DenyRule's inputTokenPattern field, so a maintainer-approved
rule differing from an existing one only by that field would collapse
onto the same signature and silently get dropped as a duplicate.
RegExp doesn't survive JSON.stringify (it serializes to `{}`), so a
naive `rule.inputTokenPattern ?? null` addition wouldn't distinguish
two different patterns either — using .toString() instead captures
both source and flags.
Closes #8013.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8127 +/- ##
==========================================
- Coverage 92.02% 92.02% -0.01%
==========================================
Files 760 760
Lines 77394 77395 +1
Branches 23392 23393 +1
==========================================
- Hits 71225 71222 -3
Misses 5061 5061
- Partials 1108 1112 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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
ruleSignature(packages/loopover-engine/src/miner/deny-hook-synthesis.ts) is the sole identity functionresolveEffectiveDenyRules(merge built-in + approved custom rules) andsynthesizeDenyRuleProposals(dedup newly-derived proposals) use to decide "is this the same rule." It included 4 ofDenyRule's 5 matching fields, omittinginputTokenPattern— added specifically because a plaininputIncludesAllsubstring test false-positives on unrelated longer flags (-fvs--follow-tags).matcher/pathPattern/inputIncludesAll/reasonbut a different (or newly-added)inputTokenPatternwould be treated as an exact duplicate and silently dropped from the merged set.inputTokenPatternto the signature, nullish-coalesced like the other optional fields — but via.toString()rather than the field itself, sinceRegExpdoesn't surviveJSON.stringify(it serializes to{}}); a naiverule.inputTokenPattern ?? nulladdition would still collapse two different patterns onto the same signature..toString()captures both source and flags (e.g."/^-[a-z]*f[a-z]*$/i").Closes #8013.
Test plan
test/unit/miner-deny-hook-synthesis.test.ts: two approved rules identical except forinputTokenPatternboth surviveresolveEffectiveDenyRules(not deduped), and each one's own pattern is still the one enforced.11merged rules instead of the expected12), then restored the fix and confirmed green.npm run build --workspace @loopover/engine && npm run build:miner(rebuilt so the test, which imports the compiled miner-lib wrapper, reflects the source change)npx tsc --noEmitnpm run test --workspace @loopover/engine(648/648 passing)npm run engine-parity:drift-check— clean, not one of the 5 hand-duplicated twin-pair files