I have the following folder structure:
└── MyProj
├── Dangerous_Memcopy
│ ├── Config.qll
│ └── ...
├── MemMangementLibraries
│ ├── FFmpegMemory
│ └── ...
This is the beginning of Config.qll:
import cpp
import Utils
// Change here the memory library if wrappers exists in project
import MemMangementLibraries.FFmpegMemory
import semmle.code.cpp.dataflow.TaintTracking
class MyConfig extends TaintTracking::Configuration{
MyConfig() {this = "MyConfig"}
override predicate isSource(DataFlow::Node node){
exists(
CallAllocationExpr alloc_foo |
(
node.asExpr() = alloc_foo
and not alloc_foo.getFile().toString().matches("%mem.c%")
)
)
}
...
I have an error on the four line: import MemMangementLibraries.FFmpegMemory:
Could not resolve module MemMangementLibraries.FFmpegMemory
I don't understand why. I gave the import with the name of the folder following the name of the library:
import MemMangementLibraries.FFmpegMemory
Any idea what can be the problem?
If I move the library FFmpegMemory.qll to be under the folder Dangerous_Memcopy and change the fourth line in Config.qll to import FFmpegMemory, it will accept it.
It seems that it doesn't recognize the folder MemMangementLibraries that is used in the import.
Imports in QL are resolved relative to the "QL pack root", which is the nearest enclosing directory containing a
qlpack.ymlfile. (They are also resolved relatively to the file containing theimportstatement, which is why this works if you move the library next to the importing file.)In this case, could it be that your
MyProjdirectory does not contain aqlpack.yml? If it is itself in a QL pack (that is, its parent contains aqlpack.yml), then you should be able to import it asMyProj. MemMangementLibraries.FFmpegMemory. Alternatively, you could add a minimalqlpack.ymlin it to make imports work.