Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/labs/argument-injection.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="argument-injection.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/assert.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="assert.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
44 changes: 10 additions & 34 deletions docs/labs/checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,30 +598,10 @@ function processHints(requestedHints) {
return compiledHints;
}

/** Load and parse YAML data, return result to be placed in "info".
* @info: String with YAML (including JSON) data to use
*/
function processYamlToInfo(configurationInfo) {
// This would only allow JSON, but then we don't need to load YAML lib:
// let parsedJson = JSON.parse(configurationInfo);

let parsedData; // Parsed data, *if* we manage to parse it.
try {
parsedData = jsyaml.load(configurationInfo);
}
catch (e) {
showDebugOutput(
`Lab Error: Cannot process YAML of info.\n${e}`);
throw e; // Rethrow, so containing browser also gets exception
}

return parsedData;
}

/** Set global values based on other than "correct" and "expected" values.
* The correct and expected values may come from elsewhere, but we have to set up the
* info-based values first, because info can change how those are interpreted.
* @info: String with YAML (including JSON) data to use
* @configurationInfo: Data to use
*/
function processInfo(configurationInfo) {
const allowedInfoFields = new Set([
Expand Down Expand Up @@ -746,17 +726,12 @@ function runSelftest() {
* The "info" data includes the regex preprocessing steps, hints, etc.
*/
function setupInfo() {
// We must load info *first*, because it can affect how other things
// (like pattern preprocessing) is handled.

// Deprecated approach: Load embedded "info" data in YAML file.
// If there is "info" data embedded in the HTML (e.g., hints),
// load it & set up global variable hints.
let infoElement = document.getElementById('info');
if (infoElement) {
let configurationYamlText = infoElement.textContent;
// Set global variable "info"
info = processYamlToInfo(configurationYamlText);
// We no longer need a *separate* step to load info, we presume the
// HTML loaded it.
// As a safety check, let's make sure some data *was* loaded.

if (Object.keys(info).length == 0) {
alert(`ERROR: info has no values set. Load/modify your lab .js file.`);
};

// If an "info2" exists, report any differences between it and "info".
Expand All @@ -768,7 +743,6 @@ function setupInfo() {
}
};


// Set global values *except* correct and expected arrays
processInfo(info);

Expand Down Expand Up @@ -830,8 +804,10 @@ function initPage() {
attempt.oninput = runCheck;
current++;
}
for (let hintButton of document.querySelectorAll("button.hintButton")) {
for (let hintButton of document.querySelectorAll("button.hintButton")){
hintButton.addEventListener('click', (e) => { showHint(e); });
// Precompute inputIndexes to work around problems that occur
// if a user uses a browser's built-in natural language translation.
// Presumes button's parent is the form
hintButton.dataset.inputIndexes = findIndexes(hintButton.parentNode);
if (!hintButton.title) {
Expand Down
1 change: 0 additions & 1 deletion docs/labs/conversion.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="conversion.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/csp1.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="csp1.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/deserialization.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="deserialization.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/format-strings.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="format-strings.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/free.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="free.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/handling-errors.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="handling-errors.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/hardcoded.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="hardcoded.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/hello.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="hello.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/input1.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="input1.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/input2.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="input2.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/ja_hello.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="hello.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/oob1.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="oob1.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/redos.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="redos.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/regex0.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="regex0.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/regex1.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="regex1.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/shell-injection.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="shell-injection.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/sql-injection.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="sql-injection.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="template.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down
1 change: 0 additions & 1 deletion docs/labs/xss.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="xss.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">
Expand Down