From 4b4f6365210d1004a781f1a6a75239732573c0c1 Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Wed, 29 Jan 2025 15:23:28 -0500 Subject: [PATCH 1/3] Lab oob1: Remove yaml Signed-off-by: David A. Wheeler --- docs/labs/oob1.html | 112 +------------------------------------------- docs/labs/oob1.js | 66 ++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 111 deletions(-) create mode 100644 docs/labs/oob1.js diff --git a/docs/labs/oob1.html b/docs/labs/oob1.html index 2e7d202b..35f3b296 100644 --- a/docs/labs/oob1.html +++ b/docs/labs/oob1.html @@ -7,6 +7,7 @@ + @@ -37,117 +38,6 @@ \s* - diff --git a/docs/labs/oob1.js b/docs/labs/oob1.js new file mode 100644 index 00000000..ac8337ff --- /dev/null +++ b/docs/labs/oob1.js @@ -0,0 +1,66 @@ +info = +{ + hints: [ + { + absent: "if", + text: "Begin with \"if\" as we will return 0 when there is a problem." + }, + { + absent: String.raw`\( +`, + text: "Need \"(...)\" around the condition after an if statement." + }, + { + absent: ">\n", + text: "Need comparison \"if ( ... > ....)\"" + }, + { + absent: String.raw`s -> s3 -> rrec \. length`, + text: "Need to compare a value with s->s3->rrec.length" + }, + { + absent: "return", + text: "Need \"return 0;\" to skip attempts to send a too-long response." + } + ], + definitions: [ + { + term: "NINETEEN", + value: String.raw`(1 \+ 2 \+ 16|19) +` + }, + { + term: "NINETEEN", + value: String.raw`(NINETEEN|\( NINETEEN \)) +` + }, + { + term: "PAYLOAD_LENGTH", + value: String.raw`(1 \+ 2|3) \+ payload \+ 16` + }, + { + term: "PAYLOAD_LENGTH", + value: String.raw`(PAYLOAD_LENGTH|payload \+ NINETEEN|NINETEEN \+ payload)` + }, + { + term: "PAYLOAD_LENGTH", + value: String.raw`(PAYLOAD_LENGTH|\( PAYLOAD_LENGTH \)) +` + }, + { + term: "RETURN0", + value: String.raw`return \s+ 0 ; +` + }, + { + term: "FULL_LENGTH", + value: String.raw`s -> s3 -> rrec \. length +` + }, + { + term: "RETURN0", + value: String.raw`(RETURN0|\{ RETURN0 \}) +` + } + ] +} From 16f15a42d98de64af92a0999f88beb232a021efa Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Wed, 29 Jan 2025 15:26:10 -0500 Subject: [PATCH 2/3] Simplify oob1.js Signed-off-by: David A. Wheeler --- docs/labs/oob1.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/docs/labs/oob1.js b/docs/labs/oob1.js index ac8337ff..0be492f5 100644 --- a/docs/labs/oob1.js +++ b/docs/labs/oob1.js @@ -6,12 +6,11 @@ info = text: "Begin with \"if\" as we will return 0 when there is a problem." }, { - absent: String.raw`\( -`, + absent: String.raw`\(`, text: "Need \"(...)\" around the condition after an if statement." }, { - absent: ">\n", + absent: ">", text: "Need comparison \"if ( ... > ....)\"" }, { @@ -26,13 +25,11 @@ info = definitions: [ { term: "NINETEEN", - value: String.raw`(1 \+ 2 \+ 16|19) -` + value: String.raw`(1 \+ 2 \+ 16|19)` }, { term: "NINETEEN", - value: String.raw`(NINETEEN|\( NINETEEN \)) -` + value: String.raw`(NINETEEN|\( NINETEEN \))` }, { term: "PAYLOAD_LENGTH", @@ -44,23 +41,19 @@ info = }, { term: "PAYLOAD_LENGTH", - value: String.raw`(PAYLOAD_LENGTH|\( PAYLOAD_LENGTH \)) -` + value: String.raw`(PAYLOAD_LENGTH|\( PAYLOAD_LENGTH \))` }, { term: "RETURN0", - value: String.raw`return \s+ 0 ; -` + value: String.raw`return \s+ 0 ;` }, { term: "FULL_LENGTH", - value: String.raw`s -> s3 -> rrec \. length -` + value: String.raw`s -> s3 -> rrec \. length` }, { term: "RETURN0", - value: String.raw`(RETURN0|\{ RETURN0 \}) -` + value: String.raw`(RETURN0|\{ RETURN0 \})` } ] } From fd826eea845e022acf546df756bb4511b0f48412 Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Wed, 29 Jan 2025 15:35:42 -0500 Subject: [PATCH 3/3] oob1: Move answers into JavaScript file Signed-off-by: David A. Wheeler --- docs/labs/oob1.html | 26 -------------------------- docs/labs/oob1.js | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/docs/labs/oob1.html b/docs/labs/oob1.html index 35f3b296..9837a624 100644 --- a/docs/labs/oob1.html +++ b/docs/labs/oob1.html @@ -12,32 +12,6 @@ - - - - - - - - - diff --git a/docs/labs/oob1.js b/docs/labs/oob1.js index 0be492f5..f87acd8c 100644 --- a/docs/labs/oob1.js +++ b/docs/labs/oob1.js @@ -54,6 +54,34 @@ info = { term: "RETURN0", value: String.raw`(RETURN0|\{ RETURN0 \})` - } - ] + }, + ], + expected: [ + `if (1 + 2 + 16 > s->s3->rrec.length) + return 0;`, + `if (1 + 2 + payload + 16 > s->s3->rrec.length) + return 0;` + ], + correct: [ + String.raw` \s* + if \( (NINETEEN > FULL_LENGTH|FULL_LENGTH < NINETEEN) \) + RETURN0 \s*`, + String.raw` \s* + if \( (PAYLOAD_LENGTH > FULL_LENGTH|FULL_LENGTH < PAYLOAD_LENGTH) \) + RETURN0 \s*`, + ], + successes: [ + [ + ` if ( s -> s3 -> rrec . length < 19 ) + return 0 ;`, + ` if ( s -> s3 -> rrec . length < payload + 19 ) + return 0;` + ], + [ + `if(s->s3->rrec.length<19) + return 0 ;`, + `if(s->s3->rrec.length