github / github/codeql

Adding functions from typescript lib files to analysis

未关闭
#18,748 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
question
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

Hello,

I want to be able to get the CallSignatureType for functions defined in the typescript lib files. I can't seem to get this to work. However, getting the getReturnTypeAnnotation seems to work for some functions. Please let me know how to add typescript lib files to my analysis so I can get call signatures consistently. Do I have to copy over the .d.ts files from the typescript source?

JavaScript file:
```
let x = BigInt.asUintN(64, 0);

let cachedTextEncoder = new TextEncoder('utf-8');
let y = cachedTextEncoder.encode("hi")
```

The following CodeQL query returns no results:
```
from Function called_function, CallExpr call
where called_function.getName() = call.getCalleeName()
select call, called_function.getCallSignature()
```
The following CodeQL query returns results for the `cachedTextEncoder.encode` call:
```
from Function called_function, CallExpr call
where called_function.getName() = call.getCalleeName()
select call, called_function.getCallSignature()
```

I am building the codeql database as follows after running `tsc --init` in the directory with the js file I want to analyze.
```
codeql database create --language=javascript -- ql_db
```

Thank you!

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。