Skip to content

Commit 8959b02

Browse files
committed
CDL: Improve performance by simplifying location identification
We can assume that the path in the cds.json is relative to the repository root, as that is the directory the CDS compiler is run from.
1 parent ac8dd07 commit 8959b02

File tree

1 file changed

+5
-4
lines changed
  • javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap

1 file changed

+5
-4
lines changed

javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap/CDL.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ abstract class CdlObject extends JsonObject {
1414
exists(Location loc, JsonValue locValue |
1515
loc = this.getLocation() and
1616
locValue = this.getPropValue("$location") and
17+
// The path in the cds.json file is relative to the working directory used when running
18+
// the cds compile command. In our extractor, that's always the root of the repository,
19+
// so we can identify the entry in the `File` table by its relative path.
1720
path =
18-
any(File f |
19-
f.getAbsolutePath()
20-
.matches("%" + locValue.getPropValue("file").getStringValue() + ".json")
21-
).getAbsolutePath().regexpReplaceAll("\\.json$", "") and
21+
any(File f | f.getRelativePath() = locValue.getPropValue("file").getStringValue())
22+
.getAbsolutePath() and
2223
if
2324
not exists(locValue.getPropValue("line")) and
2425
not exists(locValue.getPropValue("col"))

0 commit comments

Comments
 (0)