Skip to content

Commit 2a5a8a2

Browse files
Merge pull request #740 from ossf/redos_no_yaml
redos.html: Remove YAML
2 parents b7a5362 + f9ba78d commit 2a5a8a2

File tree

2 files changed

+76
-49
lines changed

2 files changed

+76
-49
lines changed

docs/labs/redos.html

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<link rel="stylesheet" href="checker.css">
88
<script src="js-yaml.min.js"></script>
99
<script src="checker.js"></script>
10+
<script src="redos.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! -->
@@ -24,55 +25,6 @@
2425
</script>
2526

2627

27-
<script id="info" type="application/yaml">
28-
---
29-
hints:
30-
- absent: ", $"
31-
text: This is a parameter, it must end with a comma.
32-
- absent: |
33-
query \( ["'`]id["'`] \)
34-
text: Use query() with an 'id' parameter.
35-
- present: |
36-
query \( ["'`]id["'`] \) [^. ]
37-
text: After query("id") use a period to invoke a verification method.
38-
- present: |
39-
(islength|Islength|IsLength|ISLENGTH)
40-
text: >
41-
JavaScript is case-sensitive. Use isLength instead of the case you have.
42-
- absent: isLength
43-
text: Limit the maximum length of input strings using isLength().
44-
- present: |
45-
isLength \( m
46-
text: |
47-
You need to pass isLength() an object with the max parameter, e.g., isLength({max: VALUE}).
48-
- absent: matches
49-
text: Use matches().
50-
- present: |
51-
matches \( /[^^]
52-
text: Match the whole string - begin the regular expression with ^
53-
- present: |
54-
matches \( /.*[^$]/
55-
text: Match the whole string - end the regular expression with $
56-
- present: |
57-
matches \( /.*[^$]/
58-
text: Match the whole string - end the regular expression with $
59-
- present: |
60-
matches \( /\^\[A-Z\]
61-
text: That would match only letters, you need digits as well.
62-
- present: |
63-
matches \( /\^\[a-z\]
64-
text: That would match only lower case letters, the format requirement is uppercase letters.
65-
- present: |
66-
matches \( /\^\(\[A-Z0-9\]\+\)\+\$
67-
text: Remember to fix the regex, the outer + quantifier causes backtracking by trying to match one or more sequences of one or more uppercase alphanumeric characters.
68-
- present: |
69-
matches \( /\^\(\[A-Z0-9\]\+\)\$
70-
text: Remove the grouping, you don’t need the parentheses.
71-
- present: \[0-9[Aa]-[Zz]\]
72-
text: It's conventional to list letters first, so use [A-Z0-9] not [0-9A-Z]
73-
74-
# debug: true
75-
</script>
7628
</head>
7729
<body>
7830
<!-- For GitHub Pages formatting: -->

docs/labs/redos.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
info =
2+
{
3+
hints: [
4+
{
5+
absent: ", $",
6+
text: "This is a parameter, it must end with a comma."
7+
},
8+
{
9+
absent: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \)
10+
`,
11+
text: "Use query() with an 'id' parameter."
12+
},
13+
{
14+
present: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \) [^. ]
15+
`,
16+
text: "After query(\"id\") use a period to invoke a verification method."
17+
},
18+
{
19+
present: "(islength|Islength|IsLength|ISLENGTH)\n",
20+
text: "JavaScript is case-sensitive. Use isLength instead of the case you have.\n"
21+
},
22+
{
23+
absent: "isLength",
24+
text: "Limit the maximum length of input strings using isLength()."
25+
},
26+
{
27+
present: String.raw`isLength \( m
28+
`,
29+
text: "You need to pass isLength() an object with the max parameter, e.g., isLength({max: VALUE}).\n"
30+
},
31+
{
32+
absent: "matches",
33+
text: "Use matches()."
34+
},
35+
{
36+
present: String.raw`matches \( /[^^]
37+
`,
38+
text: "Match the whole string - begin the regular expression with ^"
39+
},
40+
{
41+
present: String.raw`matches \( /.*[^$]/
42+
`,
43+
text: "Match the whole string - end the regular expression with $"
44+
},
45+
{
46+
present: String.raw`matches \( /.*[^$]/
47+
`,
48+
text: "Match the whole string - end the regular expression with $"
49+
},
50+
{
51+
present: String.raw`matches \( /\^\[A-Z\]
52+
`,
53+
text: "That would match only letters, you need digits as well."
54+
},
55+
{
56+
present: String.raw`matches \( /\^\[a-z\]
57+
`,
58+
text: "That would match only lower case letters, the format requirement is uppercase letters."
59+
},
60+
{
61+
present: String.raw`matches \( /\^\(\[A-Z0-9\]\+\)\+\$
62+
`,
63+
text: "Remember to fix the regex, the outer + quantifier causes backtracking by trying to match one or more sequences of one or more uppercase alphanumeric characters."
64+
},
65+
{
66+
present: String.raw`matches \( /\^\(\[A-Z0-9\]\+\)\$
67+
`,
68+
text: "Remove the grouping, you don’t need the parentheses."
69+
},
70+
{
71+
present: String.raw`\[0-9[Aa]-[Zz]\]`,
72+
text: "It's conventional to list letters first, so use [A-Z0-9] not [0-9A-Z]"
73+
}
74+
]
75+
}

0 commit comments

Comments
 (0)