|
7 | 7 | <link rel="stylesheet" href="checker.css"> |
8 | 8 | <script src="js-yaml.min.js"></script> |
9 | 9 | <script src="checker.js"></script> |
| 10 | +<script src="oob1.js"></script> |
10 | 11 | <link rel="license" href="https://creativecommons.org/licenses/by/4.0/"> |
11 | 12 |
|
12 | 13 | <!-- See create_labs.md for how to create your own lab! --> |
13 | 14 |
|
14 | | -<!-- Sample expected answer --> |
15 | | -<script id="expected0" type="plain/text"> |
16 | | - if (1 + 2 + 16 > s->s3->rrec.length) |
17 | | - return 0; |
18 | | -</script> |
19 | | -<!-- |
20 | | ---> |
21 | | -<script id="expected1" type="plain/text"> |
22 | | - if (1 + 2 + payload + 16 > s->s3->rrec.length) |
23 | | - return 0; |
24 | | -</script> |
25 | | - |
26 | | -<!-- Full pattern of correct answer --> |
27 | | -<script id="correct0" type="plain/text"> |
28 | | -\s* |
29 | | - if \( (NINETEEN > FULL_LENGTH|FULL_LENGTH < NINETEEN) \) |
30 | | - RETURN0 |
31 | | -\s* |
32 | | -</script> |
33 | | -<script id="correct1" type="plain/text"> |
34 | | -\s* |
35 | | - if \( (PAYLOAD_LENGTH > FULL_LENGTH|FULL_LENGTH < PAYLOAD_LENGTH) \) |
36 | | - RETURN0 |
37 | | -\s* |
38 | | -</script> |
39 | | - |
40 | | -<script id="info" type="application/yaml"> |
41 | | ---- |
42 | | -hints: |
43 | | -- absent: "if" |
44 | | - text: Begin with "if" as we will return 0 when there is a problem. |
45 | | -- absent: | |
46 | | - \( |
47 | | - text: Need "(...)" around the condition after an if statement. |
48 | | -- absent: | |
49 | | - > |
50 | | - text: Need comparison "if ( ... > ....)" |
51 | | -- absent: s -> s3 -> rrec \. length |
52 | | - text: Need to compare a value with s->s3->rrec.length |
53 | | -- absent: return |
54 | | - text: Need "return 0;" to skip attempts to send a too-long response. |
55 | | -definitions: |
56 | | -- term: NINETEEN |
57 | | - value: | |
58 | | - (1 \+ 2 \+ 16|19) |
59 | | -- term: NINETEEN |
60 | | - value: | |
61 | | - (NINETEEN|\( NINETEEN \)) |
62 | | -- term: PAYLOAD_LENGTH |
63 | | - value: (1 \+ 2|3) \+ payload \+ 16 |
64 | | -- term: PAYLOAD_LENGTH |
65 | | - value: (PAYLOAD_LENGTH|payload \+ NINETEEN|NINETEEN \+ payload) |
66 | | -- term: PAYLOAD_LENGTH |
67 | | - value: | |
68 | | - (PAYLOAD_LENGTH|\( PAYLOAD_LENGTH \)) |
69 | | -- term: RETURN0 |
70 | | - value: | |
71 | | - return \s+ 0 ; |
72 | | -- term: FULL_LENGTH |
73 | | - value: | |
74 | | - s -> s3 -> rrec \. length |
75 | | -- term: RETURN0 |
76 | | - value: | |
77 | | - (RETURN0|\{ RETURN0 \}) |
78 | | -# - present: "import" |
79 | | -# text: Yes, many JavaScript implementations support an import statement. |
80 | | -# However, in this exercise we will use a require form. Please use that |
81 | | -# instead. |
82 | | -# examples: |
83 | | -# - - 'import express from "express";' |
84 | | -# - absent: "const" |
85 | | -# text: Start with const. |
86 | | -# - absent: 'const\s+helmet =' |
87 | | -# text: Create a constant name named helmet using the form const helmet = ... |
88 | | -# examples: |
89 | | -# - - 'const' |
90 | | -# - - 'consthelmet = ' |
91 | | -# - present: 'require \( helmet \)' |
92 | | -# text: The parameter of a requirement statement must be string. |
93 | | -# Surround the term helment with double-quotes. |
94 | | -# examples: |
95 | | -# - - ' const helmet = require(helmet);' |
96 | | -# - absent: "; $" |
97 | | -# text: JavaScript doesn''t require semicolon terminators, but the rest of |
98 | | -# the code uses them. You should try to match a coding style when modifying |
99 | | -# existing code unless there''s an important reason not to. |
100 | | -# Please update the first statment. |
101 | | -# examples: |
102 | | -# - - ' const helmet = require("helmet")' |
103 | | -# - absent: '\s* app \. use \( helmet \( \{' |
104 | | -# index: 1 |
105 | | -# text: Your code should begin with app.use(helmet({ |
106 | | -# - absent: | |
107 | | -# \s* app \. use \( helmet \( \{ |
108 | | -# contentSecurityPolicy: \{ \s* |
109 | | -# index: 1 |
110 | | -# text: | |
111 | | -# Your code should begin with: |
112 | | -# app.use(helmet({ |
113 | | -# contentSecurityPolicy: { |
114 | | -# - absent: | |
115 | | -# \s* app \. use \( helmet \( \{ |
116 | | -# contentSecurityPolicy: \{ |
117 | | -# directives: \{ \s* |
118 | | -# index: 1 |
119 | | -# text: | |
120 | | -# Your code should begin with: |
121 | | -# app.use(helmet({ |
122 | | -# contentSecurityPolicy: { |
123 | | -# directives: { |
124 | | -# - absent: | |
125 | | -# \s* app \. use \( helmet \( \{ |
126 | | -# contentSecurityPolicy: \{ |
127 | | -# directives: \{ |
128 | | -# "script-src": \[ "'self'" , ["']https://example.com["'] \] , \s* |
129 | | -# index: 1 |
130 | | -# text: | |
131 | | -# Your code should continue with: |
132 | | -# app.use(helmet({ |
133 | | -# contentSecurityPolicy: { |
134 | | -# directives: { |
135 | | -# "script-src": ["'self'", "https://example.com"], |
136 | | -# - absent: | |
137 | | -# "style-src": \[ "'self'" \] |
138 | | -# index: 1 |
139 | | -# text: | |
140 | | -# Don't forget to include "style-src": ["'self'"] |
141 | | -# - absent: '; $' |
142 | | -# index: 1 |
143 | | -# text: JavaScript doesn''t require semicolon terminators, but the rest of |
144 | | -# the code uses them. You should try to match a coding style when modifying |
145 | | -# existing code unless there''s an important reason not to. |
146 | | -# Please update the second statment. |
147 | | -# - text: I do not have more specific hints to provide. Please ensure that |
148 | | -# the parentheses, braces, and brackets pair correctly. |
149 | | -# # debug: true |
150 | | -</script> |
151 | 15 | </head> |
152 | 16 | <body> |
153 | 17 | <!-- For GitHub Pages formatting: --> |
|
0 commit comments