GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #5227 from erik-krogh/infTest · optionalg/codeql@3f7f963

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • javascript/ql/src/semmle/javascript
    • AMD.qll
    • NodeJS.qll
    • dataflow
      • TypeInference.qll
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎javascript/ql/src/semmle/javascript/AMD.qll‎

Copy file name to clipboardExpand all lines: javascript/ql/src/semmle/javascript/AMD.qll
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,17 @@ class AmdModuleDefinition extends CallExpr {
155155
* into this module's `module.exports` property.
156156
*/
157157
DefiniteAbstractValue getAModuleExportsValue() {
158+
result = [getAnImplicitExportsValue(), getAnExplicitExportsValue()]
159+
}
160+
161+
pragma[noinline]
162+
private AbstractValue getAnImplicitExportsValue() {
158163
// implicit exports: anything that is returned from the factory function
159164
result = getModuleExpr().analyze().getAValue()
160-
or
165+
}
166+
167+
pragma[noinline]
168+
private AbstractValue getAnExplicitExportsValue() {
161169
// explicit exports: anything assigned to `module.exports`
162170
exists(AbstractProperty moduleExports, AmdModule m |
163171
this = m.getDefine() and
Collapse file

‎javascript/ql/src/semmle/javascript/NodeJS.qll‎

Copy file name to clipboardExpand all lines: javascript/ql/src/semmle/javascript/NodeJS.qll
+27-18Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,25 @@ class NodeModule extends Module {
3333
* Gets an abstract value representing one or more values that may flow
3434
* into this module's `module.exports` property.
3535
*/
36+
pragma[noinline]
3637
DefiniteAbstractValue getAModuleExportsValue() {
37-
exists(AbstractProperty moduleExports |
38-
moduleExports.getBase().(AbstractModuleObject).getModule() = this and
39-
moduleExports.getPropertyName() = "exports"
40-
|
41-
result = moduleExports.getAValue()
42-
)
38+
result = getAModuleExportsProperty().getAValue()
39+
}
40+
41+
pragma[noinline]
42+
private AbstractProperty getAModuleExportsProperty() {
43+
result.getBase().(AbstractModuleObject).getModule() = this and
44+
result.getPropertyName() = "exports"
4345
}
4446

4547
/**
4648
* Gets an expression that is an alias for `module.exports`.
47-
* For performance this predicate only computes relevant expressions.
49+
* For performance this predicate only computes relevant expressions (in `getAModuleExportsCandidate`).
4850
* So if using this predicate - consider expanding the list of relevant expressions.
4951
*/
50-
pragma[noinline]
51-
DataFlow::Node getAModuleExportsNode() {
52-
(
53-
// A bit of manual magic
54-
result = any(DataFlow::PropWrite w | exists(w.getPropertyName())).getBase()
55-
or
56-
result = DataFlow::valueNode(any(PropAccess p | exists(p.getPropertyName())).getBase())
57-
or
58-
result = DataFlow::valueNode(any(ObjectExpr obj))
59-
) and
60-
result.analyze().getAValue() = getAModuleExportsValue()
52+
DataFlow::AnalyzedNode getAModuleExportsNode() {
53+
result = getAModuleExportsCandidate() and
54+
result.getAValue() = getAModuleExportsValue()
6155
}
6256

6357
/** Gets a symbol exported by this module. */
@@ -148,6 +142,21 @@ class NodeModule extends Module {
148142
}
149143
}
150144

145+
/**
146+
* Gets an expression that syntactically could be a alias for `module.exports`.
147+
* This predicate exists to reduce the size of `getAModuleExportsNode`,
148+
* while keeping all the tuples that could be relevant in later computations.
149+
*/
150+
pragma[noinline]
151+
private DataFlow::Node getAModuleExportsCandidate() {
152+
// A bit of manual magic
153+
result = any(DataFlow::PropWrite w | exists(w.getPropertyName())).getBase()
154+
or
155+
result = DataFlow::valueNode(any(PropAccess p | exists(p.getPropertyName())).getBase())
156+
or
157+
result = DataFlow::valueNode(any(ObjectExpr obj))
158+
}
159+
151160
/**
152161
* Holds if `nodeModules` is a folder of the form `<prefix>/node_modules`, where
153162
* `<prefix>` is a (not necessarily proper) prefix of `f` and does not end in `/node_modules`,
Collapse file

‎javascript/ql/src/semmle/javascript/dataflow/TypeInference.qll‎

Copy file name to clipboardExpand all lines: javascript/ql/src/semmle/javascript/dataflow/TypeInference.qll
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class AnalyzedNode extends DataFlow::Node {
8585
}
8686

8787
/** Gets a type inferred for this node. */
88-
pragma[nomagic]
88+
cached
8989
InferredType getAType() { result = getAValue().getType() }
9090

9191
/**

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.