Skip to content

Commit 2341678

Browse files
argument-injection.js: Minor cleanups
Signed-off-by: David A. Wheeler <[email protected]>
1 parent 5831af7 commit 2341678

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

docs/labs/argument-injection.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,73 @@ info =
33
hints: [
44
{
55
present: String.raw`exec \(`,
6-
text: "The `exec` function is vulnerable to command injection. Replace it with `execFile` to improve security.\n"
6+
text: "The `exec` function is vulnerable to command injection. Replace it with `execFile` to improve security."
77
},
88
{
99
absent: String.raw`^[\n\r]*\s*execFile\s*\(`,
10-
text: "Use the `execFile` function instead of `exec` to avoid shell interpretation. Your line should start with `execFile(`.\n"
10+
text: "Use the `execFile` function instead of `exec` to avoid shell interpretation. Your line should start with `execFile(`."
1111
},
1212
{
1313
absent: String.raw`execFile\s*\(\s*['"${BACKQUOTE}]git['"${BACKQUOTE}]\s*,`,
14-
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git' without any of the command arguments.\n"
14+
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git' without any of the command arguments."
1515
},
1616
{
1717
present: String.raw`['"${BACKQUOTE}]git\x20blame['"${BACKQUOTE}]`,
18-
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git', followed by an array with parameters, like this: `execFile('git', ['blame', ...])`.\n"
18+
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git', followed by an array with parameters, like this: `execFile('git', ['blame', ...])`."
1919
},
2020
{
2121
absent: String.raw`\[ ['"${BACKQUOTE}]blame`,
22-
text: "Pass the arguments as an array, like this: `execFile('git', ['blame', ...])`.\n"
22+
text: "Pass the arguments as an array, like this: `execFile('git', ['blame', ...])`."
2323
},
2424
{
2525
present: "--",
2626
absent: String.raw`['"${BACKQUOTE}]--['"${BACKQUOTE}]`,
27-
text: "To pass `--` you need to pass it as a literal string. Typically this is notated as `'--'` or `\"--\"`.\n"
27+
text: "To pass `--` you need to pass it as a literal string. Typically this is notated as `'--'` or `\"--\"`."
2828
},
2929
{
3030
absent: String.raw`\[ ['"${BACKQUOTE}]blame['"${BACKQUOTE}] , ['"${BACKQUOTE}]--['"${BACKQUOTE}] ,`,
31-
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', ...`.\n"
31+
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', ...`."
3232
},
3333
{
3434
present: String.raw`['"${BACKQUOTE}]filePath['"${BACKQUOTE}]`,
35-
text: "`filePath` is a variable, use it directly without using quote marks.\n"
35+
text: "`filePath` is a variable, use it directly without using quote marks."
3636
},
3737
{
3838
present: String.raw`['"]\$\{filePath\}['"]`,
39-
text: "`filePath` is a variable, use it directly without using quote marks. This is simply a constant string beginning with a dollar sign, which is not what you want.\n"
39+
text: "`filePath` is a variable, use it directly without using quote marks."
4040
},
4141
{
4242
present: String.raw`${BACKQUOTE}\$\{filePath\}${BACKQUOTE}`,
43-
text: "Strictly speaking, using a backquoted template with a single reference to a variable name works. In this case, it's being done to `filePath`. However, this is unnecessarily complicated. When you want to simply refer to a variable's value, use the variable name.\n"
43+
text: "Strictly speaking, using a backquoted template with a single reference to a variable name works. In this case, it's being done to `filePath`. However, this is unnecessarily complicated. When you want to simply refer to a variable's value, use the variable name."
4444
},
4545
{
4646
absent: String.raw`\[ ['"${BACKQUOTE}]blame['"${BACKQUOTE}] , ['"${BACKQUOTE}]--['"${BACKQUOTE}] , filePath \]`,
47-
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', filePath]`.\n"
47+
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', filePath]`."
4848
},
4949
{
5050
present: "shell = [fF]alse",
51-
text: "When passing options to execFile, you need an option with the options, and those use `:` not `=`. So you should say something like: `{shell: false}`.\n"
51+
text: "When passing options to execFile, you need an option with the options, and those use `:` not `=`. So you should say something like: `{shell: false}`."
5252
},
5353
{
5454
present: "[F]alse",
55-
text: "JavaScript is case-sensitive. The false value is spelled as `false` and not `False`.\n"
55+
text: "JavaScript is case-sensitive. The false value is spelled as `false` and not `False`."
5656
},
5757
{
5858
absent: String.raw`\{ shell : false \}`,
5959
present: "shell : false",
60-
text: "When passing options to execFile, you must provide those options as a JavaScript object. That means you must surround them with `{...}` like this: `{shell: false}`.\n"
60+
text: "When passing options to execFile, you must provide those options as a JavaScript object. That means you must surround them with `{...}` like this: `{shell: false}`."
6161
},
6262
{
6363
absent: String.raw`\{ shell : false \}`,
64-
text: "We encourage you to explicitly set `shell: false` in the options object to prevent shell interpretation. That is something like this: `execFile('git', ['blame', '--', filePath], { shell: false }, ...`\n"
64+
text: "We encourage you to explicitly set `shell: false` in the options object to prevent shell interpretation. That is something like this: `execFile('git', ['blame', '--', filePath], { shell: false }, ...`"
6565
},
6666
{
6767
absent: String.raw`\(\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*,\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*,\s*[a-zA-Z_$][a-zA-Z0-9_$]*\s*\)\s*=>`,
68-
text: "Maintain the callback function structure with three parameters (typically named error, stdout, and stderr, but any valid variable names are acceptable).\n"
68+
text: "Maintain the callback function structure with three parameters (typically named error, stdout, and stderr, but any valid variable names are acceptable)."
6969
},
7070
{
7171
present: String.raw`\) \) =>`,
72-
text: "The `exec` function should be closed in later lines, not here.\n"
72+
text: "The `exec` function should be closed in later lines, not here."
7373
}
7474
],
7575
expected: [

0 commit comments

Comments
 (0)