Dynamic/JS: Add library for exporting models

This commit is contained in:
Asger F
2024-04-04 15:03:00 +02:00
parent bd1de179b3
commit acef9b7111
10 changed files with 392 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
typeModel
| (reexport).func | reexport | Member[func] |
summaryModel

View File

@@ -0,0 +1,6 @@
extensions:
- addsTo:
pack: codeql/javascript-all
extensible: typeModel
data:
- ["upstream-lib.XYZ", "upstream-lib", "Member[x].Member[y].Member[z]"]

View File

@@ -0,0 +1,17 @@
private import javascript
private import semmle.javascript.endpoints.EndpointNaming as EndpointNaming
private import semmle.javascript.frameworks.data.internal.ApiGraphModels as Shared
module ModelExportConfig implements ModelExportSig {
predicate shouldContain(API::Node node) {
node.getAValueReachingSink() instanceof DataFlow::FunctionNode
}
predicate mustBeNamed(API::Node node) { shouldContain(node) }
}
module Exported = ModelExport<ModelExportConfig>;
query predicate typeModel = Exported::typeModel/3;
query predicate summaryModel = Exported::summaryModel/5;

View File

@@ -0,0 +1,4 @@
{
"name": "reexport",
"main": "reexport.js"
}

View File

@@ -0,0 +1,10 @@
import * as lib from "upstream-lib";
export { lib };
export const x = lib.x;
export const xy = lib.x.y;
export function func() {
return lib;
}