Skip to content

Commit 99981bd

Browse files
committed
Test WIP
1 parent 8ac497a commit 99981bd

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ class RootDirectory extends Folder {
1212

1313
/**
1414
* Gets the path of a file relative to this root directory.
15+
*
16+
* Note: We normalize path separators for cross-platform compatibility.
17+
* On Windows, getAbsolutePath() returns backslashes, so we convert them
18+
* to forward slashes before processing.
1519
*/
1620
string getFilePathRelativeToRoot(File file) {
17-
result = file.getAbsolutePath().regexpReplaceAll(this.getAbsolutePath(), ".") and
21+
result =
22+
file.getAbsolutePath()
23+
.regexpReplaceAll("\\\\", "/")
24+
.regexpReplaceAll(this.getAbsolutePath().regexpReplaceAll("\\\\", "/"), ".") and
1825
result.charAt(0) = "."
1926
}
2027

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@ abstract class CdlObject extends JsonObject {
2020
// performed and `.cds.json` files are stored in that base project directory. The
2121
// `$location` values in the generated JSON data are, therefore, relative to the
2222
// base directory of the project.
23+
//
24+
// Note: We normalize path separators for cross-platform compatibility.
25+
// On Windows, getAbsolutePath() returns backslashes, but the CDS JSON uses
26+
// forward slashes, so we convert backslashes to forward slashes.
2327
path =
24-
locValue.getJsonFile().getParentContainer().getAbsolutePath().regexpReplaceAll("/$", "") +
25-
"/" + locValue.getPropValue("file").getStringValue() and
28+
locValue
29+
.getJsonFile()
30+
.getParentContainer()
31+
.getAbsolutePath()
32+
.regexpReplaceAll("\\\\", "/")
33+
.regexpReplaceAll("/$", "") + "/" + locValue.getPropValue("file").getStringValue() and
2634
if
2735
not exists(locValue.getPropValue("line")) and
2836
not exists(locValue.getPropValue("col"))
@@ -167,11 +175,19 @@ class CdlService extends CdlElement {
167175
exists(JsonValue jsonFileLocation |
168176
jsonFileLocation = this.getPropValue("$location").getPropValue("file")
169177
|
170-
result.getFile().getAbsolutePath().regexpReplaceAll("\\.[^.]+$", ".cds") =
178+
// Normalize path separators for cross-platform compatibility.
179+
// On Windows, getAbsolutePath() returns backslashes, but the CDS JSON uses
180+
// forward slashes, so we convert backslashes to forward slashes.
181+
result
182+
.getFile()
183+
.getAbsolutePath()
184+
.regexpReplaceAll("\\\\", "/")
185+
.regexpReplaceAll("\\.[^.]+$", ".cds") =
171186
jsonFileLocation
172187
.getJsonFile()
173188
.getParentContainer()
174189
.getAbsolutePath()
190+
.regexpReplaceAll("\\\\", "/")
175191
.regexpReplaceAll("/$", "") + "/" + jsonFileLocation.getStringValue()
176192
)
177193
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ class ServiceInstanceFromCdsConnectTo extends ServiceInstance {
152152
override UserDefinedApplicationService getDefinition() {
153153
exists(RequiredService serviceDecl |
154154
serviceDecl.getName() = serviceDesignator and
155-
result.hasLocationInfo(serviceDecl.getImplementationFile().getAbsolutePath(), _, _, _, _)
155+
// Normalize path separators for cross-platform compatibility
156+
result
157+
.hasLocationInfo(serviceDecl
158+
.getImplementationFile()
159+
.getAbsolutePath()
160+
.regexpReplaceAll("\\\\", "/"), _, _, _, _)
156161
)
157162
or
158163
result.getUnqualifiedName() = serviceDesignator
@@ -546,7 +551,11 @@ abstract class UserDefinedApplicationService extends UserDefinedService {
546551
*/
547552
string getManifestName() {
548553
exists(RequiredService serviceManifest |
549-
this.hasLocationInfo(serviceManifest.getImplementationFile().getAbsolutePath(), _, _, _, _) and
554+
// Normalize path separators for cross-platform compatibility
555+
this.hasLocationInfo(serviceManifest
556+
.getImplementationFile()
557+
.getAbsolutePath()
558+
.regexpReplaceAll("\\\\", "/"), _, _, _, _) and
550559
result = serviceManifest.getName()
551560
)
552561
}

0 commit comments

Comments
 (0)