Skip to content

Commit 325e1a5

Browse files
Refine input1, per education SIG discussion
This refines lab input1 per discussion at OpenSSF education SIG on 2024-04-03. Signed-off-by: David A. Wheeler <[email protected]>
1 parent 6ef53e5 commit 325e1a5

File tree

6 files changed

+21
-23
lines changed

6 files changed

+21
-23
lines changed

docs/labs/csp1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
<h1>Lab Exercise csp1</h1>
202202
<p>
203203
This is a lab exercise on developing secure software.
204-
For more information, see the <a href="introduction.html">introduction to
204+
For more information, see the <a href="introduction.html" target="_blank">introduction to
205205
the labs</a>.
206206

207207
<p>

docs/labs/hello.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
<h1>Lab Exercise hello</h1>
121121
<p>
122122
This is a lab exercise on developing secure software.
123-
For more information, see the <a href="introduction.html">introduction to
123+
For more information, see the <a href="introduction.html" target="_blank">introduction to
124124
the labs</a>.
125125

126126
<p>

docs/labs/input1-emulation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<h1>Lab Exercise Input1</h1>
88
<p>
99
This is a lab exercise on developing secure software.
10-
For more information, see the <a href="introduction.html">introduction to
10+
For more information, see the <a href="introduction.html" target="_blank">introduction to
1111
the labs</a>.
1212

1313
<p>

docs/labs/input1.html

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,13 @@
109109
<h1>Lab Exercise input1</h1>
110110
<p>
111111
This is a lab exercise on developing secure software.
112-
For more information, see the <a href="introduction.html">introduction to
112+
For more information, see the <a href="introduction.html" target="_blank">introduction to
113113
the labs</a>.
114114

115115
<p>
116-
<h2>Task</h2>
116+
<h2>Goal</h2>
117117
<p>
118-
<b>Please change the code below so the query parameter
119-
<tt>id</tt> <i>must</i> be an integer between 1 and 9999 (including
120-
those numbers).</b>
118+
Practice validating input of a simple data type.
121119

122120
<p>
123121
<h2>Background</h2>
@@ -130,18 +128,14 @@ <h2>Background</h2>
130128

131129
<p>
132130
<!-- https://expressjs.com/en/guide/routing.html -->
133-
Express allows us to state that when the system receives
134-
an HTTP <tt>get</tt> request for a given route
135-
(e.g., <tt>/invoices</tt>), Express will run a list of functions ("handlers").
131+
Express allows us to state that when the system receives a specific request,
132+
it will run a list of functions ("handlers").
136133
The library <tt>express-validator</tt> provides a set of validation functions
137134
to make it easy to add validation checks.
138135

139136
<p>
140137
The code below sets up handlers for a <tt>get</tt> request on path
141138
<tt>/invoices</tt>.
142-
This code could be triggered, for example, by requesting
143-
<tt>http://localhost:3000/invoices?id=1</tt>
144-
(if it was running at <tt>localhost</tt> and responding to port 3000).
145139
If there are no validation errors, the code is supposed to show the invoice id.
146140
If there is a validation error, it responds with HTTP
147141
error code 422 ("Unprocessable Content"), a status code suggesting
@@ -164,25 +158,25 @@ <h2>Background</h2>
164158
<p>
165159
<h2>Task Information</h2>
166160
<p>
167-
168-
<p>
169-
To complete this task,
170-
after the first parameter to <tt>app.get</tt>
161+
To complete this task:
162+
<ol>
163+
<li>After the first parameter to <tt>app.get</tt>
171164
which says <tt>'/invoices'</tt>,
172165
add a new comma-separated parameter.
173-
Start this new parameter with
166+
<li>Start this new parameter with
174167
<tt>query('id')</tt> to select the
175168
<tt>id</tt> parameter for validation (we've filled in this part
176169
to help get you started).
177-
After <tt>query('id')</tt> (and before the terminating comma),
170+
<li>After <tt>query('id')</tt> (and before the terminating comma),
178171
add a period (<tt>.</tt>) and the validation requirement
179172
<tt>isInt()</tt> (<tt>isInt</tt> validates that the named parameter is
180173
an integer).
181-
The <tt>isInt</tt> method takes, as an optional parameter inside
174+
<li>The <tt>isInt</tt> method takes, as an optional parameter inside
182175
its parentheses,
183176
an object providing a minimum and maximum, e.g.,
184177
<tt>isInt({min: YOUR_MINIMUM, max: YOUR_MAXIMUM})</tt>.
185178
Set <tt>min</tt> and <tt>max</tt> to specify the allowed range.
179+
</ol>
186180

187181
<p>
188182
Note: JavaScript names are case-sensitive, so <tt>isint</tt> won't work.
@@ -197,6 +191,10 @@ <h2>Task Information</h2>
197191
<p>
198192
<h2>Interactive Lab (<span id="grade"></span>)</h2>
199193
<p>
194+
<b>The code below accepts the query parameter <tt>id</tt> as input.
195+
Please change it so <tt>id</tt> is only accepted if it is
196+
an integer between 1 and 9999 (including those numbers).</b>
197+
<p>
200198
<!--
201199
You can use this an example for new labs.
202200
For multi-line inputs, instead of <input id="attempt0" type="text" ...>, use

docs/labs/input2.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<h1>Lab Exercise input2</h1>
9595
<p>
9696
This is a lab exercise on developing secure software.
97-
For more information, see the <a href="introduction.html">introduction to
97+
For more information, see the <a href="introduction.html" target="_blank">introduction to
9898
the labs</a>.
9999

100100
<p>

docs/labs/regex1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
<h1>Lab Exercise regex1</h1>
246246
<p>
247247
This is a lab exercise on developing secure software.
248-
For more information, see the <a href="introduction.html">introduction to
248+
For more information, see the <a href="introduction.html" target="_blank">introduction to
249249
the labs</a>.
250250

251251
<p>

0 commit comments

Comments
 (0)