AccessChecker: exact-match rules not found in single-line ACLJ file, fixes #628 #629
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.
Motivation and Context
This PR addresses #628.
Description
Problem Analysis
The key used to search for a ACL rule is the SURT URL followed by
###
, e.g.The exact-match rule in the ACLJ file consists of the SURT URL followed by
###
, a white space, the timestamp and the JSON data:Because the rule line sorts before (in reverse alphabetical order) the search key, the "search cursor" is then positioned just after the rule line and not before it. Although AccessChecker requests one additional line (
prev_size=1
) before the search position line 41, this has no effect in a single-line file because we reach EOF just after this line, see binsearch.py, line 78. Consequently, AccessChecker cannot match the single rule in the ACLJ file.Proposed Solution
As a solution we could extend the search key suffix by one more number sign
#
(U+0023). The search key then compares properly to the key followed by a white space character (U+0020) in the rule file.Note: Afaics, the above solution would allow to search with
prev_size=0
.Proof of sort order using the Unix sort command:
The "new" search key sorts before the exact match rule (and also before any prefix rules):
Types of changes
Checklist: