Skip to content

Commit 5831af7

Browse files
Lab argument-injections: Move answers
Signed-off-by: David A. Wheeler <[email protected]>
1 parent 9d3cd56 commit 5831af7

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

docs/labs/argument-injection.html

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@
1010
<script src="argument-injection.js"></script>
1111
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
1212

13-
<!-- expected answer -->
14-
<script id="expected0" type="plain/text">
15-
execFile('git', ['blame', '--', filePath], { shell: false }, (error, stdout, stderr) => {
16-
</script>
17-
18-
<script id="correct0" type="plain/text">
19-
\s* execFile \(
20-
('git'|"git"|`git`) ,
21-
\[ ('blame'|"blame"|`blame`) , ('--'|"--"|`--`) , filePath \] ,
22-
(\{ (shell : false)? \} ,)?
23-
\( [a-zA-Z_$][a-zA-Z0-9_$]* ,
24-
[a-zA-Z_$][a-zA-Z0-9_$]* , [a-zA-Z_$][a-zA-Z0-9_$]* \) => \{ \s*
25-
</script>
26-
2713
</head>
2814
<body>
2915
<!-- For GitHub Pages formatting: -->

docs/labs/argument-injection.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ info =
7272
text: "The `exec` function should be closed in later lines, not here.\n"
7373
}
7474
],
75+
expected: [
76+
`execFile('git', ['blame', '--', filePath], { shell: false }, (error, stdout, stderr) => {`
77+
],
78+
correct: [
79+
String.raw`\s* execFile \(
80+
('git'|"git"|${BACKQUOTE}git${BACKQUOTE}) ,
81+
\[ ('blame'|"blame"|${BACKQUOTE}blame${BACKQUOTE}) ,
82+
('--'|"--"|${BACKQUOTE}--${BACKQUOTE}) , filePath \] ,
83+
(\{ (shell : false)? \} ,)?
84+
\( [a-zA-Z_$][a-zA-Z0-9_$]* ,
85+
[a-zA-Z_$][a-zA-Z0-9_$]* , [a-zA-Z_$][a-zA-Z0-9_$]* \) => \{ \s*`
86+
],
7587
successes: [
7688
[
7789
" execFile('git', ['blame', '--', filePath], { shell: false }, (error, stdout, stderr) => {",

0 commit comments

Comments
 (0)