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

src: whitelist v8 options with '_' or '-' #14093

Closed

Conversation

sam-github
Copy link
Contributor

V8 options allow either '_' or '-' to be used in options as a seperator,
such as "--abort-on_uncaught-exception". Allow these case variations
when used with NODE_OPTIONS.

@richardlau , re #13932 (comment)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

src

@sam-github sam-github requested a review from richardlau July 5, 2017 21:30
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jul 5, 2017
@sam-github sam-github force-pushed the allow-v8-options-with-underscore branch from c30731d to 46d25fe Compare July 5, 2017 21:30
@refack
Copy link
Contributor

refack commented Jul 5, 2017

Is it worth the extra code? Maybe just give a better error then:

C:\Users\refael>set NODE_OPTIONS=--abort-on_uncaught-exception
C:\Users\refael>node
node: --abort-on_uncaught-exception is not allowed in NODE_OPTIONS
  • ...please use the all dash variant...

src/node.cc Outdated
@@ -3729,15 +3729,32 @@ static void PrintHelp() {
}


static bool ArgIsAllowed(const char* arg, const char* allowed) {
for (;*arg && *allowed; arg++, allowed++) {
Copy link
Member

Choose a reason for hiding this comment

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

Tiniest of nits: space after semicolon.

@sam-github
Copy link
Contributor Author

Node supports the variant spellings at the CLI, but not via NODE_OPTIONS, eventually someone (other than @richardlau ) is going to report this a bug, better to preempt.

This PR makes NODE_OPTIONS=--abort-on_uncaught-exception valid, just as node --abort-on_uncaught-exception is valid) so its not necessary to give a better error, because its not an error.

@sam-github sam-github added the semver-minor PRs that contain new features and should be released in the next minor version. label Jul 6, 2017
@refack
Copy link
Contributor

refack commented Jul 6, 2017

Node supports the variant spellings at the CLI, but not via NODE_OPTIONS, eventually someone (other than @richardlau ) is going to report this a bug, better to preempt.

This PR makes NODE_OPTIONS=--abort-on_uncaught-exception valid, just as node --abort-on_uncaught-exception is valid) so its not necessary to give a better error, because its not an error.

  1. I'm just preaching parsimony and trying to K.I.S.S. If instead of allowing, we print a not "error" but a "direction", IMHO we can do it in less lines of code.
  2. This PR also enables all node CLI options to work with _, e.g. --inspect_brk, which is a disparity with CLI invocation. read code again.

@sam-github
Copy link
Contributor Author

sam-github commented Jul 6, 2017

  1. I don't see how fuzzy matching, and telling the person that we knew what they were trying to do, and know that it works from the CLI, but are just going to give them a nice error message instead of doing the right thing is helpful!
  2. It does not, only V8 options are allowed to mix - and _, just like it is on the CLI.
% NODE_OPTIONS=--inspect_brk ./out/Release/node 
./out/Release/node: --inspect_brk is not allowed in NODE_OPTIONS
NODE_OPTIONS=--inspect-brk ./out/Release/node 
Debugger listening on ws://127.0.0.1:9229/6cb26d3b-f53e-4f57-ba16-7d38229a7c5e

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

Convinced

@@ -60,7 +60,12 @@ if (common.hasCrypto) {
}

// V8 options
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you fix the strange indent?

src/node.cc Outdated
if (*arg == '=')
return true;

return *arg == *allowed;
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT this could be return true?

@@ -60,7 +60,12 @@ if (common.hasCrypto) {
}

// V8 options
expect('--abort-on-uncaught-exception', 'B\n');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: define const printB_expectedOutput = 'B\n'; (Actualy I think '^B\n$' would be better).

@sam-github sam-github force-pushed the allow-v8-options-with-underscore branch from e39106d to 2a2bba2 Compare July 6, 2017 21:15
@sam-github
Copy link
Contributor Author

@sam-github sam-github force-pushed the allow-v8-options-with-underscore branch from 2a2bba2 to 083a4df Compare July 7, 2017 17:32
@sam-github
Copy link
Contributor Author

@sam-github
Copy link
Contributor Author

Jenkins built the wrong commit last time, not sure why, trying again.

ci: https://ci.nodejs.org/job/node-test-pull-request/9032/

sam-github added a commit that referenced this pull request Jul 10, 2017
V8 options allow either '_' or '-' to be used in options as a seperator,
such as "--abort-on_uncaught-exception". Allow these case variations
when used with NODE_OPTIONS.

PR-URL: #14093
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@sam-github sam-github closed this Jul 10, 2017
@sam-github sam-github force-pushed the allow-v8-options-with-underscore branch from 083a4df to 97a6aa9 Compare July 10, 2017 19:08
@sam-github sam-github deleted the allow-v8-options-with-underscore branch July 10, 2017 19:08
@vsemozhetbyt
Copy link
Contributor

Landed in 97a6aa9

addaleax pushed a commit that referenced this pull request Jul 11, 2017
V8 options allow either '_' or '-' to be used in options as a seperator,
such as "--abort-on_uncaught-exception". Allow these case variations
when used with NODE_OPTIONS.

PR-URL: #14093
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax addaleax mentioned this pull request Jul 11, 2017
addaleax pushed a commit that referenced this pull request Jul 18, 2017
V8 options allow either '_' or '-' to be used in options as a seperator,
such as "--abort-on_uncaught-exception". Allow these case variations
when used with NODE_OPTIONS.

PR-URL: #14093
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
V8 options allow either '_' or '-' to be used in options as a seperator,
such as "--abort-on_uncaught-exception". Allow these case variations
when used with NODE_OPTIONS.

PR-URL: #14093
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@gibfahn
Copy link
Member

gibfahn commented Nov 13, 2017

@nodejs/lts I know we just did a semver-minor for 6.x, and thus it probably won't happen for a while, but it seems like it'd be helpful for people if we could backport this at some point, the errors you get with different versions of node are pretty opaque (see #16999).

@MylesBorins
Copy link
Contributor

I'd be up for considering this semver patch if we assume it likely should have landed in 6.12.0

@gibfahn
Copy link
Member

gibfahn commented Nov 14, 2017

@MylesBorins makes sense, the actual feature (supporting the args in NODE_OPTIONS) landed already, actually supporting the alternatives would be a bug fix.

Thoughts on how we avoid forgetting to include this in the next patch? Maybe just land on staging now?

@MylesBorins
Copy link
Contributor

MylesBorins commented Nov 14, 2017 via email

MylesBorins pushed a commit that referenced this pull request Nov 14, 2017
V8 options allow either '_' or '-' to be used in options as a seperator,
such as "--abort-on_uncaught-exception". Allow these case variations
when used with NODE_OPTIONS.

PR-URL: #14093
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins
Copy link
Contributor

I've landed this on v6.x-staging and am going to be shipping it as semver patch

@nodejs/lts please lmk if you have concerns

@MylesBorins MylesBorins mentioned this pull request Nov 21, 2017
MylesBorins pushed a commit that referenced this pull request Nov 21, 2017
V8 options allow either '_' or '-' to be used in options as a seperator,
such as "--abort-on_uncaught-exception". Allow these case variations
when used with NODE_OPTIONS.

PR-URL: #14093
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Nov 28, 2017
V8 options allow either '_' or '-' to be used in options as a seperator,
such as "--abort-on_uncaught-exception". Allow these case variations
when used with NODE_OPTIONS.

PR-URL: #14093
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins added a commit that referenced this pull request Nov 28, 2017
Notable Changes:

* build:
  - fix npm install with --shared (Ben Noordhuis)
    #16438
* build:
  - building with python 3 is now supported (Emily Marigold Klassen)
    #16058
* src:
  - v8 options can be specified with either '\_' or '-' in NODE_OPTIONS
    (Sam Roberts) #14093

PR-URL: #17180
MylesBorins added a commit that referenced this pull request Dec 5, 2017
Notable Changes:

* build:
  - fix npm install with --shared (Ben Noordhuis)
    #16438
* build:
  - building with python 3 is now supported (Emily Marigold Klassen)
    #16058
* src:
  - v8 options can be specified with either '\_' or '-' in NODE_OPTIONS
    (Sam Roberts) #14093

PR-URL: #17180
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants