如何创建对 CodeQL 的导入

问题描述

我想为我的 CodeQL 查询创建一个导入。
我希望此导入将命名为 Utils,并且我将在其中创建一个名为 isNumber 的谓词。

如何创建这样的导入?

我希望我的代码看起来像这样:

import cpp
import Utils

where
    if exists(...)
    then isNumber(size.(VariableAccess).getTarget())
    else ...
select ...

我不知道如何创建 Utils 导入,它写道:

无法解析模块实用程序

我尝试在我的代码查询 (Utils) 附近创建一个名为 code.ql 的文件夹,但没有成功。

解决方法

我找到了方法。
需要在 CodeQL 查询的同一文件夹中创建一个名为 Utils.qll 的文件。

这是它的代码:

import cpp

predicate isNumber(Variable v){
    v.getUnspecifiedType() instanceof IntegralType
}

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...