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

[meta] Overarching code audit of differences #19

Open
14 of 18 tasks
jonathanKingston opened this issue Mar 16, 2017 · 5 comments
Open
14 of 18 tasks

[meta] Overarching code audit of differences #19

jonathanKingston opened this issue Mar 16, 2017 · 5 comments
Assignees
Labels

Comments

@jonathanKingston
Copy link
Collaborator

jonathanKingston commented Mar 16, 2017

As mentioned I would check through the code and see for obvious differences and pull them out. I'm going to raise everything here and we can decide which differences we care about and should import.
Rather than question the differences etc, I will just state them as fact and we can dismiss and add comments (none of this should be considered criticism, other than I'm an idiot for making a competing code base etc 😬).

That should mostly be it...


Different code example over using switch or if statements:

checkThing(node) {
  if (node.type in checkNode) {
    return checkNode[node.type](node);
  } else {
    throw new Error('Argh something happened with a node we didn\'t expect');
  }
};

const checkNode = {
  TaggedTemplateExpression(node) {
    // do something...
    return isValid;
  },
  CallExpression(node) {
    // do something...
    return isValid;
  }
};
@mozfreddyb
Copy link
Collaborator

I'll go through your points one by one:

  • difference in export rule: I'll use whatever eslint prefers, I don't want to get philosophical on that. If both works, I'm fine with making this a low-priority change later
  • use strict: I like the benefits of strict mode. I want to keep using it.
  • expression operators: innerhtml -=, **= *= etc, dont make a lot of sense to me. Strings turn into NaN when operated with -, *, etc..
  • permitted escaping: yes, I think we should have specific escapers. If things get too "weird" for * jquery/jsx, we could even throw that in its own rules. These areas are mostly unknown to me, so I'd like to dig deeper in the future.
  • checks are completed on AssignmentExpression:exit, I think I wanted some subnodes. Maybe this is because I checked comments and not required anymore. is this a problem? let's remove and see if it breaks tests! trying in Try checking AssignmentExpression, not :exit. #21.
  • es2016+: yeah sure :) let's see how good nodejs compat is though
  • non-hardcoding property checks and stuff: aye!
  • argument information in error report: agreed
  • not explicitly returning false: good catch
  • configurability & defaults: ack
  • I think I have linting. maybe I'm missing a rule.
  • EsNext expression concerns: also a good catch, we should be careful of those things indeed, I have been broken by this before.
  • I don't understand the native code check
  • props checking, aye. should become its own rule mayyyyyybe
  • getting identifier, yeah.
  • allowedExpression doesnt need parentNode anymore: agreed

@mozfreddyb
Copy link
Collaborator

I'm in a bit of a rush and I feel bad for doing this bad multi-response thing.
I will likely turn most of those into single issues in the next week, as tracking it like this is horrible.
Thank you for your input!!

@mozfreddyb mozfreddyb changed the title Overarching code audit of differences [meta] Overarching code audit of differences Mar 17, 2017
@mozfreddyb mozfreddyb self-assigned this Mar 17, 2017
@mozfreddyb
Copy link
Collaborator

mozfreddyb commented Mar 20, 2017

I'll go through your points one by one:

@jonathanKingston
Copy link
Collaborator Author

jonathanKingston commented Mar 21, 2017

@mozfreddyb can we consider making the expression operators use an allow list of permitted expressions rather than a block list of checked operators. Such that we would have allowedExpressions = ["-=", "**=", "*=", "/="]; or similar? So if fancy new operator comes along that adds an exploit we don't need to remember to fix out code in future etc. #42

@jonathanKingston
Copy link
Collaborator Author

@mozfreddyb also I notice you are only checking for context.getSource(node.callee) for write and writeln but node.callee.property.name for insertAdjacentHTML was this intentional to avoid valid write functions? This might be a very breaking code change to add to make write use the property.name (I remember now this is exactly why I forked, when I mentioned breaking changes). #41

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

No branches or pull requests

2 participants