From 4ed57e71db6c1e58dc33d3cced6c74b5b842368f Mon Sep 17 00:00:00 2001 From: tiferet Date: Tue, 6 Dec 2022 16:37:11 -0800 Subject: [PATCH] Remove tokens from the prompt that the Java side can't handle --- .../adaptivethreatmodeling/ModelPrompt.qll | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ModelPrompt.qll b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ModelPrompt.qll index 700dcd58dc3..f3ce2705dfc 100644 --- a/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ModelPrompt.qll +++ b/javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ModelPrompt.qll @@ -35,11 +35,18 @@ module ModelPrompt { strictconcat(Token token | location.containsLoosely(token.getLocation()) | - token.getValue(), - // Use space as the separator, since that is most likely. - // May not be an exact reconstruction, e.g. if the code - // had newlines between successive tokens. - " " + token + .getValue() + .replaceAll("\"", " ") + .replaceAll("\\", " ") + .replaceAll("\n", " ") + .replaceAll("\r", " ") + .replaceAll("|", " ") + .replaceAll("`", " ") + + // Use space as the separator, since that is most likely. + // May not be an exact reconstruction, e.g. if the code + // had newlines between successive tokens. + " " order by token.getLocation().getStartLine(), token.getLocation().getStartColumn() )