Skip to content

Commit 651bf91

Browse files
Merge pull request #783 from ossf/commaize
Add trailing commas to text lines
2 parents 0fff0b9 + e709228 commit 651bf91

File tree

12 files changed

+91
-91
lines changed

12 files changed

+91
-91
lines changed

docs/labs/argument-injection.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,73 +6,73 @@ info =
66
hints: [
77
{
88
present: String.raw`exec \(`,
9-
text: "The `exec` function is vulnerable to command injection. Replace it with `execFile` to improve security."
9+
text: "The `exec` function is vulnerable to command injection. Replace it with `execFile` to improve security.",
1010
},
1111
{
1212
absent: String.raw`^[\n\r]*\s*execFile\s*\(`,
13-
text: "Use the `execFile` function instead of `exec` to avoid shell interpretation. Your line should start with `execFile(`."
13+
text: "Use the `execFile` function instead of `exec` to avoid shell interpretation. Your line should start with `execFile(`.",
1414
},
1515
{
1616
absent: String.raw`execFile\s*\(\s*['"${BACKQUOTE}]git['"${BACKQUOTE}]\s*,`,
17-
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git' without any of the command arguments."
17+
text: "Separate the command and its arguments. The first argument to `execFile` should be the command 'git' without any of the command arguments.",
1818
},
1919
{
2020
present: String.raw`['"${BACKQUOTE}]git\x20blame['"${BACKQUOTE}]`,
21-
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', ...])`."
21+
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', ...])`.",
2222
},
2323
{
2424
absent: String.raw`\[ ['"${BACKQUOTE}]blame`,
25-
text: "Pass the arguments as an array, like this: `execFile('git', ['blame', ...])`."
25+
text: "Pass the arguments as an array, like this: `execFile('git', ['blame', ...])`.",
2626
},
2727
{
2828
present: "--",
2929
absent: String.raw`['"${BACKQUOTE}]--['"${BACKQUOTE}]`,
30-
text: "To pass `--` you need to pass it as a literal string. Typically this is notated as `'--'` or `\"--\"`."
30+
text: "To pass `--` you need to pass it as a literal string. Typically this is notated as `'--'` or `\"--\"`.",
3131
},
3232
{
3333
absent: String.raw`\[ ['"${BACKQUOTE}]blame['"${BACKQUOTE}] , ['"${BACKQUOTE}]--['"${BACKQUOTE}] ,`,
34-
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', ...`."
34+
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', ...`.",
3535
},
3636
{
3737
present: String.raw`['"${BACKQUOTE}]filePath['"${BACKQUOTE}]`,
38-
text: "`filePath` is a variable, use it directly without using quote marks."
38+
text: "`filePath` is a variable, use it directly without using quote marks.",
3939
},
4040
{
4141
present: String.raw`['"]\$\{filePath\}['"]`,
42-
text: "`filePath` is a variable, use it directly without using quote marks."
42+
text: "`filePath` is a variable, use it directly without using quote marks.",
4343
},
4444
{
4545
present: String.raw`${BACKQUOTE}\$\{filePath\}${BACKQUOTE}`,
46-
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."
46+
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.",
4747
},
4848
{
4949
absent: String.raw`\[ ['"${BACKQUOTE}]blame['"${BACKQUOTE}] , ['"${BACKQUOTE}]--['"${BACKQUOTE}] , filePath \]`,
50-
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', filePath]`."
50+
text: "Pass the arguments as an array. Include '--' before the file path to prevent argument injection. Your array should look like `['blame', '--', filePath]`.",
5151
},
5252
{
5353
present: "shell = [fF]alse",
54-
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}`."
54+
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}`.",
5555
},
5656
{
5757
present: "[F]alse",
58-
text: "JavaScript is case-sensitive. The false value is spelled as `false` and not `False`."
58+
text: "JavaScript is case-sensitive. The false value is spelled as `false` and not `False`.",
5959
},
6060
{
6161
absent: String.raw`\{ shell : false \}`,
6262
present: "shell : false",
63-
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}`."
63+
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}`.",
6464
},
6565
{
6666
absent: String.raw`\{ shell : false \}`,
67-
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 }, ...`"
67+
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 }, ...`",
6868
},
6969
{
7070
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*=>`,
71-
text: "Maintain the callback function structure with three parameters (typically named error, stdout, and stderr, but any valid variable names are acceptable)."
71+
text: "Maintain the callback function structure with three parameters (typically named error, stdout, and stderr, but any valid variable names are acceptable).",
7272
},
7373
{
7474
present: String.raw`\) \) =>`,
75-
text: "The `exec` function should be closed in later lines, not here."
75+
text: "The `exec` function should be closed in later lines, not here.",
7676
},
7777
],
7878
expected: [

docs/labs/assert.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ info =
2020
},
2121
{
2222
present: "(bindingresult|BindingResult)",
23-
text: "Java is case-sensitive. Use `bindingResult`, not `bindingresult` nor `BindingResult`."
23+
text: "Java is case-sensitive. Use `bindingResult`, not `bindingresult` nor `BindingResult`.",
2424
},
2525
{
2626
present: "(haserrors|HasErrors)",
27-
text: "Java is case-sensitive. Use `hasErrors`, not `haserrors` nor `HasErrors`."
27+
text: "Java is case-sensitive. Use `hasErrors`, not `haserrors` nor `HasErrors`.",
2828
},
2929
{
3030
present: String.raw`^\s*if\s*[^\(\s]`,
@@ -42,25 +42,25 @@ info =
4242
},
4343
{
4444
absent: String.raw`^ if \( bindingResult \. hasErrors \( \) \) `,
45-
text: "Begin the answer with the text `if (bindingResult.hasErrors())` so that a statement will be executed if that condition is true."
45+
text: "Begin the answer with the text `if (bindingResult.hasErrors())` so that a statement will be executed if that condition is true.",
4646
},
4747
{
4848
present: String.raw`if \( bindingResult \. hasErrors \( \) \) [^\{\s] `,
49-
text: "Follow the conditional with an open brace, e.g., `if (bindingResult.hasErrors()) {...`."
49+
text: "Follow the conditional with an open brace, e.g., `if (bindingResult.hasErrors()) {...`.",
5050
},
5151
{
5252
absent: String.raw`return "form"
5353
`,
54-
text: "You need to use `return \"form\";` somewhere."
54+
text: "You need to use `return \"form\";` somewhere.",
5555
},
5656
{
5757
present: String.raw`return "form"`,
5858
absent: String.raw`return "form" ;`,
59-
text: "You need to use `;` (semicolon) after `return \"form\"` because in Java statements must be followed by a semicolon."
59+
text: "You need to use `;` (semicolon) after `return \"form\"` because in Java statements must be followed by a semicolon.",
6060
},
6161
{
6262
absent: String.raw`\} $`,
63-
text: "The answer needs to end with `}` (closing brace)."
63+
text: "The answer needs to end with `}` (closing brace).",
6464
},
6565
],
6666
expected: [

docs/labs/conversion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ info =
66
hints: [
77
{
88
absent: "unsigned",
9-
text: "The type defined for queue_count should exactly match the return type of get_queue."
9+
text: "The type defined for queue_count should exactly match the return type of get_queue.",
1010
},
1111
{
1212
present: String.raw`unsigned\s+queue_count`,
13-
text: "The declared return type of get_queue is `unsigned int`; you should match it exactly instead of using a synonym like `unsigned`."
13+
text: "The declared return type of get_queue is `unsigned int`; you should match it exactly instead of using a synonym like `unsigned`.",
1414
},
1515
],
1616
expected: [

docs/labs/csp1.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ info =
1515
},
1616
{
1717
absent: "const",
18-
text: "Start with const."
18+
text: "Start with const.",
1919
},
2020
{
2121
absent: String.raw`const\s+helmet =`,
@@ -42,22 +42,22 @@ info =
4242
{
4343
absent: String.raw`\s* app \. use \( helmet \( \{`,
4444
index: 1,
45-
text: "Your code should begin with app.use(helmet({"
45+
text: "Your code should begin with app.use(helmet({",
4646
},
4747
{
4848
absent: String.raw`\s* app \. use \( helmet \( \{
4949
contentSecurityPolicy: \{ \s*
5050
`,
5151
index: 1,
52-
text: "Your code should begin with:\napp.use(helmet({\n contentSecurityPolicy: {\n"
52+
text: "Your code should begin with:\napp.use(helmet({\n contentSecurityPolicy: {\n",
5353
},
5454
{
5555
absent: String.raw`\s* app \. use \( helmet \( \{
5656
contentSecurityPolicy: \{
5757
directives: \{ \s*
5858
`,
5959
index: 1,
60-
text: "Your code should begin with:\napp.use(helmet({\n contentSecurityPolicy: {\n directives: {\n"
60+
text: "Your code should begin with:\napp.use(helmet({\n contentSecurityPolicy: {\n directives: {\n",
6161
},
6262
{
6363
absent: String.raw`\s* app \. use \( helmet \( \{
@@ -66,26 +66,26 @@ info =
6666
"script-src": \[ "'self'" , ["']https://example.com["'] \] , \s*
6767
`,
6868
index: 1,
69-
text: "Your code should continue with:\napp.use(helmet({\n contentSecurityPolicy: {\n directives: {\n \"script-src\": [\"'self'\", \"https://example.com\"],\n"
69+
text: "Your code should continue with:\napp.use(helmet({\n contentSecurityPolicy: {\n directives: {\n \"script-src\": [\"'self'\", \"https://example.com\"],\n",
7070
},
7171
{
7272
absent: String.raw`"style-src": \[ "'self'" \]
7373
`,
7474
index: 1,
75-
text: "Don't forget to include \"style-src\": [\"'self'\"]\n"
75+
text: "Don't forget to include \"style-src\": [\"'self'\"]\n",
7676
},
7777
{
7878
absent: "; $",
7979
index: 1,
80-
text: "JavaScript doesn''t require semicolon terminators, but the rest of the code uses them. You should try to match a coding style when modifying existing code unless there''s an important reason not to. Please update the second statement to use a semicolon terminator."
80+
text: "JavaScript doesn''t require semicolon terminators, but the rest of the code uses them. You should try to match a coding style when modifying existing code unless there''s an important reason not to. Please update the second statement to use a semicolon terminator.",
8181
},
8282
{
8383
absent: String.raw`\} \} \) \) ; $`,
8484
index: 1,
85-
text: "The correct answer is expected to end with `} } ) ) ;` ignoring whitespace. Check that you have matching parentheses and braces."
85+
text: "The correct answer is expected to end with `} } ) ) ;` ignoring whitespace. Check that you have matching parentheses and braces.",
8686
},
8787
{
88-
text: "I do not have more specific hints to provide. Please ensure that the parentheses, braces, and brackets pair correctly, as that is often the problem."
88+
text: "I do not have more specific hints to provide. Please ensure that the parentheses, braces, and brackets pair correctly, as that is often the problem.",
8989
},
9090
],
9191
expected: [

docs/labs/deserialization.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,31 @@ info =
3030
},
3131
{
3232
term: "CONDALL",
33-
value: "(COND0 && (COND1 && COND2|COND2 && COND1))"
33+
value: "(COND0 && (COND1 && COND2|COND2 && COND1))",
3434
},
3535
],
3636
hints: [
3737
{
3838
absent: "^ const data =\n",
39-
text: "The first section should begin with `const data =`"
39+
text: "The first section should begin with `const data =`",
4040
},
4141
{
4242
present: "json",
43-
text: "the JSON built-in global object is witten in uppercase."
43+
text: "the JSON built-in global object is witten in uppercase.",
4444
},
4545
{
4646
absent: String.raw`JSON \. parse
4747
`,
48-
text: "Make a call to `JSON.parse` with the data retrieved, e.g., `JSON.parse(base64Decoded)` should be stored in `data`."
48+
text: "Make a call to `JSON.parse` with the data retrieved, e.g., `JSON.parse(base64Decoded)` should be stored in `data`.",
4949
},
5050
{
5151
present: String.raw`\+
5252
`,
53-
text: "You should not have any concatenation (`+`) in the first section."
53+
text: "You should not have any concatenation (`+`) in the first section.",
5454
},
5555
{
5656
absent: "; $\n",
57-
text: "JavaScript does not require semicolons at the end of a statement, but since the other statements terminate with semicolons, you should also terminate your statement with a semicolon to be consistent."
57+
text: "JavaScript does not require semicolons at the end of a statement, but since the other statements terminate with semicolons, you should also terminate your statement with a semicolon to be consistent.",
5858
},
5959
{
6060
absent: String.raw`^ if \(`,
@@ -71,28 +71,28 @@ info =
7171
absent: String.raw`data \. username
7272
`,
7373
index: 1,
74-
text: "Check if the data object has a property called username. You can do this by referencing data.username."
74+
text: "Check if the data object has a property called username. You can do this by referencing data.username.",
7575
},
7676
{
7777
absent: String.raw`\&\&`,
7878
index: 1,
79-
text: "To combine multiple conditions in JavaScript use &&. This operator means 'and', so both conditions must be true for the entire statement to pass."
79+
text: "To combine multiple conditions in JavaScript use &&. This operator means 'and', so both conditions must be true for the entire statement to pass.",
8080
},
8181
{
8282
absent: "typeof",
8383
index: 1,
84-
text: "Use typeof to check the type of the operand's value. You should have `typeof data.username == 'string'` or similar."
84+
text: "Use typeof to check the type of the operand's value. You should have `typeof data.username == 'string'` or similar.",
8585
},
8686
{
8787
present: String.raw`typeof data \. username == 'String'
8888
`,
8989
index: 1,
90-
text: "When using typeof, JavaScript expects \"string\" all lowercase."
90+
text: "When using typeof, JavaScript expects \"string\" all lowercase.",
9191
},
9292
{
9393
absent: "length",
9494
index: 1,
95-
text: "check if the length of the string is smaller than 20 characters. Use the expression `data.username.length < 20` to determine this."
95+
text: "check if the length of the string is smaller than 20 characters. Use the expression `data.username.length < 20` to determine this.",
9696
},
9797
{
9898
present: String.raw`^ if \(`,

docs/labs/format-strings.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ info =
77
{
88
present: String.raw`def format_event \( user_input
99
`,
10-
text: "The `user_format` should no longer be used, so we should remove it from the list of parameters being passed into the function being defined by `def`. The first line should read `def format_event(new_event):`"
10+
text: "The `user_format` should no longer be used, so we should remove it from the list of parameters being passed into the function being defined by `def`. The first line should read `def format_event(new_event):`",
1111
},
1212
{
1313
present: "user_input",
14-
text: "Do not support a user-provided format at all. In this case there is no need for it."
14+
text: "Do not support a user-provided format at all. In this case there is no need for it.",
1515
},
1616
{
1717
absent: "event",
18-
text: "We want to see `event`, e.g., return '{event.level},...'.format(event=new_event)"
18+
text: "We want to see `event`, e.g., return '{event.level},...'.format(event=new_event)",
1919
},
2020
{
2121
present: String.raw`\{0`,
22-
text: "For our purposes we want to use named parameters, so do not use `{0}` or similar."
22+
text: "For our purposes we want to use named parameters, so do not use `{0}` or similar.",
2323
},
2424
{
2525
absent: String.raw`\'\{event.level\},\{event.message\}\'
2626
`,
27-
text: "The constant text `'{event.level},{event.message}'` should be present."
27+
text: "The constant text `'{event.level},{event.message}'` should be present.",
2828
},
2929
],
3030
expected: [

docs/labs/free.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ info =
2525
},
2626
{
2727
absent: "return",
28-
text: "This fails to return the result."
28+
text: "This fails to return the result.",
2929
},
3030
{
3131
absent: String.raw`\s* [^;]+;[^;]+;[^;]+; \s*`,

docs/labs/handling-errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ info =
77
{
88
index: 0,
99
absent: "; $",
10-
text: "This code uses the convention of terminating each line with a semicolon; please follow the conventions of the code being modified.\n"
10+
text: "This code uses the convention of terminating each line with a semicolon; please follow the conventions of the code being modified.\n",
1111
},
1212
{
1313
index: 0,

0 commit comments

Comments
 (0)