Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize removing negated items with same start #7

Closed
RyanTheAllmighty opened this issue Feb 24, 2018 · 3 comments
Closed

Normalize removing negated items with same start #7

RyanTheAllmighty opened this issue Feb 24, 2018 · 3 comments
Labels
bug To be fixed.

Comments

@RyanTheAllmighty
Copy link

So I've been using accesscontrol to do filtering of objects based on roles and what attributes they have access to and I came across an issue that seems to track down to the normalize function of notation.

Given I have the following:

// allow access to all except password and password_reset_code
const globs = [
    '*',
    '!password',
    '!password_reset_code'
];

// normalize them (called as part of filter but the issue remains in normalize)
const normalizedGlobs = normalize(globs);

// prints out ['*', '!password']
console.log(normalizedGlobs);

It seems normalize is stripping out all negated globs that start with another negated attirbute.

It seems to be caused by https://github.com/onury/notation/blob/master/src/core/notation.glob.js#L383 as it does a regex check, in my case, like below:

/^password/.test('password_reset_code')

So any globs with the same beginning as a previous glob will be 'normalized' out.

Is this intended?

I've tried changing the ordering of the globs in the array and nothing seems to help short of changing the way I structure my data to ensure there is no repeated names.

@onury onury added the bug To be fixed. label Feb 24, 2018
@onury
Copy link
Owner

onury commented Feb 24, 2018

This is definitely a bug. Thanks for the report. Looking into it.

@onury onury closed this as completed in ab26167 Feb 24, 2018
onury added a commit that referenced this issue Feb 24, 2018
@onury
Copy link
Owner

onury commented Feb 24, 2018

This is auto-closed with the fix.
Pls check out v1.3.6 and let me know if it works for you.

EDIT: AccessControl v2.2.1 is released with this fix.

@RyanTheAllmighty
Copy link
Author

Everything working as expected. Thanks for the super fast turn around time. Keep up the great work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug To be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants