Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
2cbcc1d
JS: Overlay annotations for AST layer
asgerf Aug 29, 2025
4950fa0
JS: Fix getRawEnclosingStmt call
asgerf Oct 3, 2025
afa8cd9
JS: Add overlay[local?] to new summaries after rebasing
asgerf Oct 10, 2025
eded45a
JS: Make more general-purpose data flow things local
asgerf Oct 10, 2025
1da2fc9
JS: Overlay annotations for some failing tests
tausbn Oct 10, 2025
cfda393
JS: Add some overlay[caller] and a pragma[nomagic] annotations
asgerf Oct 15, 2025
b86d88f
JS: Add more overlay[caller?] annotations
asgerf Oct 15, 2025
fd96b72
JS: Fix bad join in DuplicateProperty.ql
asgerf Oct 16, 2025
1bcb2ea
JS: Add overlay[local] to restore magic in unwrap() predicate
asgerf Oct 16, 2025
88351d5
JS: Avoid bad join in shared predicate induced by 'forex'.
asgerf Oct 16, 2025
8dd1a9e
JS: Avoid more bad joins due to locality
asgerf Oct 20, 2025
4ef6f02
JS: Improve join orders related to getABooleanValue()
asgerf Oct 22, 2025
84e7101
JS: Remove obsolete overlay[global] annotations
asgerf Oct 31, 2025
7c9c992
JS: Make isAssignedInUniqueFile global, as it should be
asgerf Nov 3, 2025
15cc9a2
Sync ApiGraphModelsExtensions.qll
asgerf Nov 3, 2025
b9c4636
Sync ApiGraphModels.qll
asgerf Nov 3, 2025
7fcc357
wp
asgerf Oct 7, 2025
a6f3990
JS: Convert boolean to a newtype
asgerf Oct 9, 2025
39cba9e
WIP: Factor out Promisification state
asgerf Oct 9, 2025
f5d105c
Revert "WIP: Factor out Promisification state"
asgerf Oct 9, 2025
f0f93c3
Revert "JS: Convert boolean to a newtype"
asgerf Oct 9, 2025
6b423e5
JS: Make MkSyntheticCallbackArg() independent of trackUseNode
asgerf Oct 9, 2025
0a181be
JS: Make other node types not depend on tracking predicates
asgerf Oct 9, 2025
73531e5
JS: Remove unused predicate
asgerf Oct 9, 2025
4511f7c
JS: Make use() and rhs() uncached and private
asgerf Oct 9, 2025
cf09daa
JS: Wrap in a module
asgerf Oct 9, 2025
f7208f9
JS: Parameterise the module (still only one instantiation)
asgerf Oct 9, 2025
0c39e04
Revert "JS: Remove unused predicate"
asgerf Oct 9, 2025
46a9b1a
JS: Fixup restriction of MkClassInstance
asgerf Oct 9, 2025
3d638f5
JS: Moving 'cache' annotations outside the parameterised module
asgerf Oct 9, 2025
3db63af
JS: Localize charpred of API::EntryPoint
asgerf Oct 10, 2025
6018df3
JS: Localize MkModuleExport
asgerf Oct 10, 2025
523054b
JS: Localize MkModuleImport
asgerf Oct 10, 2025
5d09ab5
JS: Localize MkClassInstance
asgerf Oct 10, 2025
77da92f
JS: Further localize MkDef
asgerf Oct 10, 2025
aa7a02e
JS: Temporarily disable MkTypeUse (too hard to localize for now)
asgerf Oct 10, 2025
93aa190
JS: Remove unused predicate
asgerf Oct 10, 2025
8fcaa72
JS: Make API nodes and labels local
asgerf Oct 10, 2025
6c20d52
JS: Apply forceLocal overlay trick to API graphs
asgerf Oct 10, 2025
e9fe48b
JS: Also forceLocal getAPromisifiedInvocation
asgerf Oct 10, 2025
8489bdd
JS: Stop dependeding on getPath() for toString()
asgerf Oct 10, 2025
60c6c0e
JS:Add more member labels
asgerf Oct 10, 2025
20b2ac0
JS: Add predicate for detecting lost edges
asgerf Oct 10, 2025
e88ed69
JS: Add MkDef case for 'export const bar = foo'
asgerf Oct 10, 2025
f1177ac
Debug predicates for missing def/use nodes
asgerf Oct 10, 2025
c900baf
JS: Add MkDef case for export namespace specifiers
asgerf Oct 10, 2025
3b776e7
JS: Restrict entry point edges to those in scope
asgerf Oct 10, 2025
981cf13
JS: Change signature of 'edges' to support quick eval
asgerf Oct 10, 2025
f90f863
JS: Refine criteria so that explicit this-passing is not affected
asgerf Oct 6, 2025
a58b1b4
JS: Add receivers to MkDef
asgerf Oct 10, 2025
a1c41cc
JS: Minor improvements to some join orders
asgerf Oct 10, 2025
b7cd35f
wip
asgerf Oct 10, 2025
67eef3a
JS: Add back CallReceiverStep() restriction
asgerf Oct 10, 2025
05e2d26
JS: Update debugging stuff in API graphs
asgerf Oct 10, 2025
dc4ca96
JS: Mass overlay[local?]
asgerf Oct 10, 2025
c8e83df
JS: Add overlay[global] to abstract classes with fields
asgerf Oct 10, 2025
e0fb2d0
JS: Use forceLocal to implement MkTypeUse
asgerf Oct 31, 2025
a2251ec
JS: Add a few missing node types
asgerf Oct 31, 2025
c8abbdc
JS: Remove global dependency that wasnt needed anyway
asgerf Nov 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions javascript/ql/lib/Customizations.qll
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
* `FileSystemAccess`, or the `Source` and `Sink` classes associated with the security queries
* to model frameworks that are not covered by the standard library.
*/
overlay[local?]
module;

import javascript
2 changes: 2 additions & 0 deletions javascript/ql/lib/Declarations/Declarations.qll
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Provides predicates for finding variable references and declarations
* in a given function or toplevel.
*/
overlay[local?]
module;

import javascript

Expand Down
2 changes: 2 additions & 0 deletions javascript/ql/lib/Declarations/UnusedVariable.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides classes and predicates for the 'js/unused-local-variable' query.
*/
overlay[local?]
module;

import javascript
import LanguageFeatures.UnusedIndexVariable
Expand Down
2 changes: 2 additions & 0 deletions javascript/ql/lib/Expressions/DOMProperties.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides predicates for working with the DOM type hierarchy.
*/
overlay[local?]
module;

import semmle.javascript.Externs

Expand Down
6 changes: 6 additions & 0 deletions javascript/ql/lib/Expressions/ExprHasNoEffect.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides classes and predicates for the 'js/useless-expression' query.
*/
overlay[local]
module;

import javascript
import DOMProperties
Expand Down Expand Up @@ -60,6 +62,7 @@ predicate isDeclaration(Expr e) {
/**
* Holds if there exists a getter for a property called `name` anywhere in the program.
*/
overlay[global]
predicate isGetterProperty(string name) {
// there is a call of the form `Object.defineProperty(..., name, descriptor)` ...
exists(CallToObjectDefineProperty defProp | name = defProp.getPropertyName() |
Expand All @@ -85,6 +88,7 @@ predicate isGetterProperty(string name) {
/**
* A property access that may invoke a getter.
*/
overlay[global]
class GetterPropertyAccess extends PropAccess {
override predicate isImpure() { isGetterProperty(this.getPropertyName()) }
}
Expand Down Expand Up @@ -123,6 +127,7 @@ predicate isReceiverSuppressingCall(CallExpr c, Expr dummy, PropAccess callee) {
* even if they do, the call itself is useless and should be flagged by this
* query.
*/
overlay[global]
predicate noSideEffects(Expr e) {
e.isPure()
or
Expand All @@ -148,6 +153,7 @@ predicate isCompoundExpression(Expr e) {
/**
* Holds if the expression `e` should be reported as having no effect.
*/
overlay[global]
predicate hasNoEffect(Expr e) {
noSideEffects(e) and
inVoidContext(e) and
Expand Down
2 changes: 2 additions & 0 deletions javascript/ql/lib/IDEContextual.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides shared predicates related to contextual queries in the code viewer.
*/
overlay[local?]
module;

import semmle.files.FileSystem
private import codeql.util.FileSystem
Expand Down
2 changes: 2 additions & 0 deletions javascript/ql/lib/LanguageFeatures/UnusedIndexVariable.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides a predicate for identifying unused index variables in loops.
*/
overlay[local?]
module;

import javascript

Expand Down
2 changes: 2 additions & 0 deletions javascript/ql/lib/default.qll
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
*
* Provides classes for working with JavaScript programs, as well as JSON, YAML and HTML.
*/
overlay[local?]
module;

import javascript
2 changes: 2 additions & 0 deletions javascript/ql/lib/definitions.qll
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Provides classes and predicates related to jump-to-definition links
* in the code viewer.
*/
overlay[local?]
module;

import javascript
import IDEContextual
Expand Down
2 changes: 2 additions & 0 deletions javascript/ql/lib/external/ExternalArtifact.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides classes for working with external data.
*/
overlay[local?]
module;

import semmle.javascript.Locations

Expand Down
2 changes: 2 additions & 0 deletions javascript/ql/lib/javascript.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides classes for working with JavaScript programs, as well as JSON, YAML and HTML.
*/
overlay[local?]
module;

import Customizations
import semmle.javascript.Aliases
Expand Down
2 changes: 2 additions & 0 deletions javascript/ql/lib/semmle/files/FileSystem.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/** Provides classes for working with files and folders. */
overlay[local?]
module;

import semmle.javascript.Files
20 changes: 16 additions & 4 deletions javascript/ql/lib/semmle/javascript/AMD.qll
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Provides classes for working with
* [Asynchronous Module Definitions](https://github.com/amdjs/amdjs-api/wiki/AMD).
*/
overlay[local]
module;

import javascript
private import semmle.javascript.internal.CachedStages
Expand Down Expand Up @@ -62,9 +64,11 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
}

/** DEPRECATED. Use `getDependencyExpr` instead. */
overlay[global]
deprecated PathExpr getDependency(int i) { result = this.getDependencyExpr(i) }

/** DEPRECATED. Use `getADependencyExpr` instead. */
overlay[global]
deprecated PathExpr getADependency() { result = this.getADependencyExpr() }

/** Gets the `i`th dependency of this module definition. */
Expand Down Expand Up @@ -194,16 +198,19 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
* Gets an abstract value representing one or more values that may flow
* into this module's `module.exports` property.
*/
overlay[global]
DefiniteAbstractValue getAModuleExportsValue() {
result = [this.getAnImplicitExportsValue(), this.getAnExplicitExportsValue()]
}

overlay[global]
pragma[noinline, nomagic]
private AbstractValue getAnImplicitExportsValue() {
// implicit exports: anything that is returned from the factory function
result = this.getModuleExpr().analyze().getAValue()
}

overlay[global]
pragma[noinline]
private AbstractValue getAnExplicitExportsValue() {
// explicit exports: anything assigned to `module.exports`
Expand All @@ -227,6 +234,7 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
private predicate isPseudoDependency(string s) { s = ["exports", "require", "module"] }

/** An AMD dependency, considered as a path expression. */
overlay[global]
private class AmdDependencyPath extends PathExprCandidate {
AmdDependencyPath() {
exists(AmdModuleDefinition amd |
Expand All @@ -239,6 +247,7 @@ private class AmdDependencyPath extends PathExprCandidate {
}

/** A constant path element appearing in an AMD dependency expression. */
overlay[global]
deprecated private class ConstantAmdDependencyPathElement extends PathExpr, ConstantString {
ConstantAmdDependencyPathElement() { this = any(AmdDependencyPath amd).getAPart() }

Expand Down Expand Up @@ -281,6 +290,7 @@ private class AmdDependencyImport extends Import {
* Specifically, we look for files whose absolute path ends with the imported path, possibly
* adding well-known JavaScript file extensions like `.js`.
*/
overlay[global]
private File guessTarget() {
exists(FilePath imported, string abspath, string dirname, string basename |
this.targetCandidate(result, abspath, imported, dirname, basename)
Expand All @@ -303,6 +313,7 @@ private class AmdDependencyImport extends Import {
* Additionally, `abspath` is bound to the absolute path of `f`, `imported` to the imported path, and
* `dirname` and `basename` to the dirname and basename (respectively) of `imported`.
*/
overlay[global]
private predicate targetCandidate(
File f, string abspath, FilePath imported, string dirname, string basename
) {
Expand All @@ -316,10 +327,12 @@ private class AmdDependencyImport extends Import {
/**
* Gets the module whose absolute path matches this import, if there is only a single such module.
*/
overlay[global]
private Module resolveByAbsolutePath() {
result.getFile() = unique(File file | file = this.guessTarget())
}

overlay[global]
override Module getImportedModule() {
result = super.getImportedModule()
or
Expand Down Expand Up @@ -348,21 +361,20 @@ private class AmdDependencyImport extends Import {
*/
class AmdModule extends Module {
cached
AmdModule() {
Stages::DataFlowStage::ref() and
exists(unique(AmdModuleDefinition def | amdModuleTopLevel(def, this)))
}
AmdModule() { exists(unique(AmdModuleDefinition def | amdModuleTopLevel(def, this))) }

/** Gets the definition of this module. */
AmdModuleDefinition getDefine() { amdModuleTopLevel(result, this) }

overlay[global]
override DataFlow::Node getAnExportedValue(string name) {
exists(DataFlow::PropWrite pwn | result = pwn.getRhs() |
pwn.getBase().analyze().getAValue() = this.getDefine().getAModuleExportsValue() and
name = pwn.getPropertyName()
)
}

overlay[global]
override DataFlow::Node getABulkExportedNode() {
// Assigned to `module.exports` via the factory's `module` parameter
exists(AbstractModuleObject m, DataFlow::PropWrite write |
Expand Down
8 changes: 8 additions & 0 deletions javascript/ql/lib/semmle/javascript/AST.qll
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Provides classes for working with the AST-based representation of JavaScript programs.
*/
overlay[local]
module;

import javascript
private import internal.StmtContainers
Expand Down Expand Up @@ -172,6 +174,7 @@ class AstNode extends @ast_node, NodeInStmtContainer {
* The TypeScript compiler emits no code for ambient declarations, but they
* can affect name resolution and type checking at compile-time.
*/
overlay[caller?]
pragma[inline]
predicate isAmbient() {
this.isAmbientInternal()
Expand Down Expand Up @@ -470,9 +473,12 @@ module AST {
*/
class ValueNode extends AstNode, @dataflownode {
/** Gets type inference results for this element. */
overlay[global]
DataFlow::AnalyzedNode analyze() { result = DataFlow::valueNode(this).analyze() }

/** Gets the data flow node associated with this program element. */
overlay[caller]
pragma[inline]
DataFlow::ValueNode flow() { result = DataFlow::valueNode(this) }

/**
Expand All @@ -481,6 +487,7 @@ module AST {
* This can be used to map an expression to the class it refers to, or
* associate it with a named value coming from an dependency.
*/
overlay[global]
ExprNameBindingNode getNameBinding() { result = this }

/**
Expand All @@ -490,6 +497,7 @@ module AST {
* (according to the type system), or to associate it with a named type coming
* from a dependency.
*/
overlay[global]
TypeNameBindingNode getTypeBinding() { TypeResolution::valueHasType(this, result) }
}
}
2 changes: 2 additions & 0 deletions javascript/ql/lib/semmle/javascript/Actions.qll
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Libraries for modeling GitHub Actions workflow files written in YAML.
* See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions.
*/
overlay[local?]
module;

import javascript

Expand Down
2 changes: 2 additions & 0 deletions javascript/ql/lib/semmle/javascript/Aliases.qll
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Provides aliases for commonly used classes that have different names
* in the QL libraries for other languages.
*/
overlay[local?]
module;

import javascript

Expand Down
Loading
Loading