-
-
Notifications
You must be signed in to change notification settings - Fork 592
Strict ACL parsing without a regex #2587
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
Conversation
🦋 Changeset detectedLatest commit: 3772a8e The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This definitely looks more performant - a single loop over the string rather than at least 26! However, it's not as clearly correct as it was - the previous code was very obvious and this code is less so - so it will need some unit tests. Just simple assertions that a number of standard permissions strings with/without role, with/without grants parse correctly. Since pg-introspection doesn't seem to have tests already, please use node:test
for them (or mocha/chai if you prefer).
In general we trust permission strings to be valid (we trust Postgres) so I'm not too concerned about malicious permission strings, however Postgres does add new permissions from time to time so it's worth ensuring that the code correctly handles (via an error) a new permission character.
I've included a number of TypeScript improvements, all minor.
bd70431
to
e0db4db
Compare
…fiers, and fix order of permissions to match Postgres' order.
2650195
to
9aa2637
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whilst implementing tests for this I discovered we had a bug in the way that we were handling roles containing "
characters, and also that our permission string output was in a different order to Postgres'. Both of these are now resolved. Thanks!
Hey, sorry for dropping the ball here. I got caught up at work. Thank you for taking this past the finish line. |
Description
Supersedes #2586 per maintainer comments.
Motivation: browsing through the code and saw a simple opportunity.
No new tests. Should only require regression testing.
Performance impact
Minor speed improvement for ACL parsing logic in aggregate due to one less regex.
Security impact
Excludes most invalid ACL input. (Doesn't stop duplicate ACL tokens.)
Checklist
yarn lint:fix
passes.yarn test
passes.RELEASE_NOTES.md
file (if one exists).