-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
In all of the external string selectedSourceFile();
for contextual queries, references for windows paths are not created properly. All paths must begin with a /
. The reason is that this path represents a piece of a uri (even though special characters like spaces are not encoded) and must always have a slash at the front.
Currently, paths inside of a database's src.zip
file for dbs created on windows look like this:
/C_/databases/my-database/my-file.cpp
and the original path looks like this:
C:\databases\my-database\my-file.cpp
The problem is that inside of the extension, there is no way to determine if C_
is an encoded drive name on windows, or a directory name from a linux-like system.
The extension, therefore passes the path with the leading /
to the contextual query and the contextual query does not recognize it as a path to any file in the database.
One example is here:
codeql/cpp/ql/src/definitions.qll
Line 217 in 89a808c
File getEncodedFile(string name) { result.getAbsolutePath().replaceAll(":", "_") = name } |
One proposed solution is to move getEncodedFile
to a shared location and fix it once. All language libraries would use the same implementation. Though, this would not work for go
or ruby
.
Originally reported by @nickrolfe