Skip to content

Commit 7040473

Browse files
committed
Update to use the sourceLocationPrefix
In our testing framework we don't always have the .cds file indexed so we can't guarantee the presence of the File entry. Instead, compose the path using the sourceLocationPrefix, which will be robust to whether the .cds file was indexed or not.
1 parent 8959b02 commit 7040473

File tree

1 file changed

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

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ abstract class CdlObject extends JsonObject {
1616
locValue = this.getPropValue("$location") and
1717
// The path in the cds.json file is relative to the working directory used when running
1818
// 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.
20-
path =
21-
any(File f | f.getRelativePath() = locValue.getPropValue("file").getStringValue())
22-
.getAbsolutePath() and
19+
// so we can identify the sourceLocationPrefix to find the path of the root of the repo
20+
// then append the relative path
21+
exists(string sourceLocationPrefix |
22+
sourceLocationPrefix(sourceLocationPrefix) and
23+
path =
24+
sourceLocationPrefix.regexpReplaceAll("/$", "") + "/" +
25+
locValue.getPropValue("file").getStringValue()
26+
) and
2327
if
2428
not exists(locValue.getPropValue("line")) and
2529
not exists(locValue.getPropValue("col"))

0 commit comments

Comments
 (0)