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

feat: adds includePattern option #63

Closed
wants to merge 1 commit into from
Closed

feat: adds includePattern option #63

wants to merge 1 commit into from

Conversation

morgs32
Copy link

@morgs32 morgs32 commented Jun 5, 2019

Closes #62

Copy link
Collaborator

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #62 (comment); this seems like something your babel config can do without any individual transform needing to participate.

@@ -1,3 +1,6 @@
# IDE configs
.idea
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

individual IDE configs should go in your global gitignore, not in every project you happen to touch.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best advice I've gotten all day.

if (ignorePattern) {
if (includePattern) {
// Only set the includeRegex once:
includeRegex = includeRegex || new RegExp(includePattern);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's dangerous to pass user input into RegExp; this is a DOS attack vector, for example.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb In case you come around to the idea of adding this option, might you suggest how I could resolve this issue? I've copied the behavior of the ignorePattern almost exactly: https://github.com/airbnb/babel-plugin-inline-react-svg/pull/63/files#diff-1fdf421c05c1140f6d71444ea2b27638R65

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of supporting regex, it should only support globs (gitignore syntax) - you can use https://npmjs.com/glob for that, i think

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool I'll give that a shot

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I've been trying to find some literature about this vulnerability - this is the best I can do so far: https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS.

It doesn't seem to me that this is a DOS risk (not like that at least). Is there precedent for protecting the engineer from doing this to his/herself? I suppose another babel preset could end up doing this - but still I'd have to have deliberately installed a malicious preset, right? Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I’d consider a self-DOS to be a non-problem - however, avoiding footguns is a UX concern, and i consider regexes in configs to be an attractive pit of failure.

@morgs32 morgs32 closed this Jun 6, 2019
@ljharb ljharb reopened this Jun 17, 2019
@mrassili
Copy link

@ljharb @morgs32 guys, would you like me to take over this PR?
This option could be useful

@morgs32
Copy link
Author

morgs32 commented Jan 22, 2020

@mrassili sure. You're going to go to the trouble of using glob? I'd love someone to describe the vulnerability in more detail. Maybe with a short example.

@ljharb
Copy link
Collaborator

ljharb commented Jan 23, 2020

It’s about the UX to me more than a vulnerability.

@morgs32
Copy link
Author

morgs32 commented Jan 24, 2020

That seems reasonable. @mrassili you can have it if you want. It might be a week or so before I'd have the time.

@ljharb
Copy link
Collaborator

ljharb commented Dec 14, 2023

Unfortunately the fork was deleted, so this PR is unrecoverable.

@ljharb ljharb closed this Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need includePattern as option
3 participants