summaryrefslogtreecommitdiff
path: root/dev/bin
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-19 00:33:38 -0500
committerGitHub <noreply@github.com>2023-12-19 05:33:38 +0000
commit1ced9aafc00c10992bab8bd3f1b6b1397f05b7b9 (patch)
tree305bb2b3bfc7fc3b051ee1cd3d1c35f442af0de4 /dev/bin
parent5f96276fda93dcad39f2165fd3c8d890aa5f9be5 (diff)
Make JSON.parse usage safer (#373)
* Make JSON.parse usage safer * Fix any type * Add readResponseJson * Use readResponseJson * Additional updates * Rename files * Add types
Diffstat (limited to 'dev/bin')
-rw-r--r--dev/bin/schema-validate.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/dev/bin/schema-validate.js b/dev/bin/schema-validate.js
index 206f26ca..bbd5ad5f 100644
--- a/dev/bin/schema-validate.js
+++ b/dev/bin/schema-validate.js
@@ -18,6 +18,7 @@
import fs from 'fs';
import {performance} from 'perf_hooks';
+import {parseJson} from '../../ext/js/core/json.js';
import {createJsonSchema} from '../schema-validate.js';
/** */
@@ -39,14 +40,14 @@ function main() {
}
const schemaSource = fs.readFileSync(args[0], {encoding: 'utf8'});
- const schema = JSON.parse(schemaSource);
+ const schema = parseJson(schemaSource);
for (const dataFileName of args.slice(1)) {
const start = performance.now();
try {
console.log(`Validating ${dataFileName}...`);
const dataSource = fs.readFileSync(dataFileName, {encoding: 'utf8'});
- const data = JSON.parse(dataSource);
+ const data = parseJson(dataSource);
createJsonSchema(mode, schema).validate(data);
const end = performance.now();
console.log(`No issues detected (${((end - start) / 1000).toFixed(2)}s)`);