Skip to content

Commit 66b125a

Browse files
Merge pull request #742 from ossf/oob1_no_yaml
Oob1 no yaml
2 parents 5a31b1c + fd826ee commit 66b125a

File tree

2 files changed

+88
-137
lines changed

2 files changed

+88
-137
lines changed

docs/labs/oob1.html

Lines changed: 1 addition & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -7,147 +7,11 @@
77
<link rel="stylesheet" href="checker.css">
88
<script src="js-yaml.min.js"></script>
99
<script src="checker.js"></script>
10+
<script src="oob1.js"></script>
1011
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
1112

1213
<!-- See create_labs.md for how to create your own lab! -->
1314

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>
15115
</head>
15216
<body>
15317
<!-- For GitHub Pages formatting: -->

docs/labs/oob1.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
info =
2+
{
3+
hints: [
4+
{
5+
absent: "if",
6+
text: "Begin with \"if\" as we will return 0 when there is a problem."
7+
},
8+
{
9+
absent: String.raw`\(`,
10+
text: "Need \"(...)\" around the condition after an if statement."
11+
},
12+
{
13+
absent: ">",
14+
text: "Need comparison \"if ( ... > ....)\""
15+
},
16+
{
17+
absent: String.raw`s -> s3 -> rrec \. length`,
18+
text: "Need to compare a value with s->s3->rrec.length"
19+
},
20+
{
21+
absent: "return",
22+
text: "Need \"return 0;\" to skip attempts to send a too-long response."
23+
}
24+
],
25+
definitions: [
26+
{
27+
term: "NINETEEN",
28+
value: String.raw`(1 \+ 2 \+ 16|19)`
29+
},
30+
{
31+
term: "NINETEEN",
32+
value: String.raw`(NINETEEN|\( NINETEEN \))`
33+
},
34+
{
35+
term: "PAYLOAD_LENGTH",
36+
value: String.raw`(1 \+ 2|3) \+ payload \+ 16`
37+
},
38+
{
39+
term: "PAYLOAD_LENGTH",
40+
value: String.raw`(PAYLOAD_LENGTH|payload \+ NINETEEN|NINETEEN \+ payload)`
41+
},
42+
{
43+
term: "PAYLOAD_LENGTH",
44+
value: String.raw`(PAYLOAD_LENGTH|\( PAYLOAD_LENGTH \))`
45+
},
46+
{
47+
term: "RETURN0",
48+
value: String.raw`return \s+ 0 ;`
49+
},
50+
{
51+
term: "FULL_LENGTH",
52+
value: String.raw`s -> s3 -> rrec \. length`
53+
},
54+
{
55+
term: "RETURN0",
56+
value: String.raw`(RETURN0|\{ RETURN0 \})`
57+
},
58+
],
59+
expected: [
60+
`if (1 + 2 + 16 > s->s3->rrec.length)
61+
return 0;`,
62+
`if (1 + 2 + payload + 16 > s->s3->rrec.length)
63+
return 0;`
64+
],
65+
correct: [
66+
String.raw` \s*
67+
if \( (NINETEEN > FULL_LENGTH|FULL_LENGTH < NINETEEN) \)
68+
RETURN0 \s*`,
69+
String.raw` \s*
70+
if \( (PAYLOAD_LENGTH > FULL_LENGTH|FULL_LENGTH < PAYLOAD_LENGTH) \)
71+
RETURN0 \s*`,
72+
],
73+
successes: [
74+
[
75+
` if ( s -> s3 -> rrec . length < 19 )
76+
return 0 ;`,
77+
` if ( s -> s3 -> rrec . length < payload + 19 )
78+
return 0;`
79+
],
80+
[
81+
`if(s->s3->rrec.length<19)
82+
return 0 ;`,
83+
`if(s->s3->rrec.length<payload+19)
84+
return 0;`
85+
],
86+
],
87+
}

0 commit comments

Comments
 (0)