From 0b4f239ab553ac991398274b9122d27b648958b2 Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Mon, 3 Apr 2023 10:47:13 +0200 Subject: [PATCH] only set the file in the diagnostics message if the file is within the source root --- .../extractor/src/com/semmle/js/extractor/AutoBuild.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java index 3b86ed15f8e..dc552a0427e 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java +++ b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java @@ -1239,12 +1239,11 @@ protected DependencyInstallationResult preparePackagesAndDependencies(Set String msg = "A parse error occurred: " + StringUtil.escapeMarkdown(err.getMessage()) + ". Check the syntax of the file. If the file is invalid, correct the error or [exclude](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning) the file from analysis."; // file, relative to the source root - String relativeFilePath = null; + DiagnosticLocation.Builder builder = DiagnosticLocation.builder(); if (file.startsWith(LGTM_SRC)) { - relativeFilePath = file.subpath(LGTM_SRC.getNameCount(), file.getNameCount()).toString(); + builder = builder.setFile(file.subpath(LGTM_SRC.getNameCount(), file.getNameCount()).toString()); } - DiagnosticLocation diagLoc = DiagnosticLocation.builder() - .setFile(relativeFilePath) + DiagnosticLocation diagLoc = builder .setStartLine(err.getPosition().getLine()) .setStartColumn(err.getPosition().getColumn()) .setEndLine(err.getPosition().getLine())