-
Notifications
You must be signed in to change notification settings - Fork 80
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
[MCG] Using put-bucket-policy with wrong syntax under Resource results in InternalError instead of MalformedPolicy #8783
base: master
Are you sure you want to change the base?
Conversation
f84f57a
to
2280c6f
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.
Hey @vh05
- Please add unit tests
- Initializing regex in a function is unrecommended due to performance issues and it should be pre-compiled as a global variable, read more about it here - Pre-compiled regexp optimization #7110
- To me It looks like this issue can happen in every bucket policy field, can you please check if we need this fix in more places?
- @nadavMiz since you are the last one to change this area, I would appreciate your review as well.
const resource_regex = RegExp(`^${resource_bucket_part.replace(qm_regex, '.?').replace(ar_regex, '.*')}$`); | ||
const resource_regex = RegExp( | ||
`^${resource_bucket_part | ||
.replace(/[-/^$+?.()|[\]{}]/g, '\\$&') |
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.
notice that we are modifying the ? character right after your change. did you check it doesn't effect this? worth adding a test as well if one doesn't already exists
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.
@nadavMiz I think the question mark (?) will be replaced with \?
in the 1st part then ? will be replace by \.?
. Have limited or no knowledge on this. Checking this
|
…s in InternalError instead of MalformedPolicy The malformed syntax should give malformed systax error. Issue: Square brackets ([ ]) in resource_bucket_part were misinterpreted in regex. Fix: Escape all regex special characters before inserting into RegExp(). Fixes: https://issues.redhat.com/browse/DFBUGS-1517 Signed-off-by: Vinayakswami Hariharmath <[email protected]>
The malformed syntax should give malformed systax error.
Issue: Square brackets ([ ]) in resource_bucket_part were misinterpreted in regex.
Fix: Escape all regex special characters before inserting into RegExp().
Fixes: https://issues.redhat.com/browse/DFBUGS-1517