From 0db788bb1045beab25cfb040151d514a0e240e93 Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Thu, 14 Dec 2023 14:50:17 +0100 Subject: [PATCH] use direct string comparison instead, that doesn't crash on invalid values --- javascript/extractor/lib/typescript/src/main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/javascript/extractor/lib/typescript/src/main.ts b/javascript/extractor/lib/typescript/src/main.ts index 272f11e8de6..d34f516cf55 100644 --- a/javascript/extractor/lib/typescript/src/main.ts +++ b/javascript/extractor/lib/typescript/src/main.ts @@ -554,7 +554,7 @@ function handleOpenProjectCommand(command: OpenProjectCommand) { let program = project.program; let typeChecker = program.getTypeChecker(); - let shouldReportDiagnostics = getEnvironmentVariable("SEMMLE_TYPESCRIPT_REPORT_DIAGNOSTICS", v => JSON.parse(v.toLowerCase()), false); + let shouldReportDiagnostics = getEnvironmentVariable("SEMMLE_TYPESCRIPT_REPORT_DIAGNOSTICS", v => v.trim().toLowerCase() === "true", false); let diagnostics = shouldReportDiagnostics ? program.getSemanticDiagnostics().filter(d => d.category === ts.DiagnosticCategory.Error) : []; @@ -807,8 +807,8 @@ function handleGetMetadataCommand(command: GetMetadataCommand) { function reset() { state = new State(); - state.typeTable.restrictedExpansion = getEnvironmentVariable("SEMMLE_TYPESCRIPT_NO_EXPANSION", v => JSON.parse(v.toLowerCase()), true); - state.typeTable.skipExtractingTypes = getEnvironmentVariable("CODEQL_EXTRACTOR_JAVASCRIPT_OPTION_SKIP_TYPES", v => JSON.parse(v.toLowerCase()), false); + state.typeTable.restrictedExpansion = getEnvironmentVariable("SEMMLE_TYPESCRIPT_NO_EXPANSION", v => v.trim().toLowerCase() === "true", true); + state.typeTable.skipExtractingTypes = getEnvironmentVariable("CODEQL_EXTRACTOR_JAVASCRIPT_OPTION_SKIP_TYPES", v => v.trim().toLowerCase() === "true", false); } function getEnvironmentVariable(name: string, parse: (x: string) => T, defaultValue: T) {