Skip to content

Commit b631bfc

Browse files
author
Esben Sparre Andreasen
authored
Merge branch 'master' into node-js-classification
2 parents f8eff06 + 9b805c0 commit b631bfc

File tree

107 files changed

+1462
-3757
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1462
-3757
lines changed

change-notes/1.23/analysis-javascript.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@
2323
| Incomplete string escaping or encoding (`js/incomplete-sanitization`) | Fewer false-positive results | This rule now recognizes additional ways delimiters can be stripped away. |
2424
| Client-side cross-site scripting (`js/xss`) | More results | More potential vulnerabilities involving functions that manipulate DOM attributes are now recognized. |
2525
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving functions that manipulate DOM event handler attributes are now recognized. |
26+
| Hard-coded credentials (`js/hardcoded-credentials`) | Fewer false-positive results | This rule now flags fewer password examples. |
27+
| Incorrect suffix check (`js/incorrect-suffix-check`) | Fewer false-positive results | The query recognizes valid checks in more cases.
28+
| Network data written to file (`js/http-to-file-access`) | Fewer false-positive results | This query has been renamed to better match its intended purpose, and now only considers network data untrusted. |
29+
| Password in configuration file (`js/password-in-configuration-file`) | Fewer false-positive results | This rule now flags fewer password examples. |
2630
| Prototype pollution (`js/prototype-pollution`) | More results | The query now highlights vulnerable uses of jQuery and Angular, and the results are shown on LGTM by default. |
27-
| Incorrect suffix check (`js/incorrect-suffix-check`) | Fewer false-positive results | The query recognizes valid checks in more cases. |
31+
| Uncontrolled command line (`js/command-line-injection`) | More results | This query now treats responses from servers as untrusted. |
2832

2933
## Changes to QL libraries
3034

change-notes/1.23/extractor-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
## Changes to code extraction
66

77
* Asynchronous generator methods are now parsed correctly and no longer cause a spurious syntax error.
8-
98
* Recognition of CommonJS modules has improved. As a result, some files that were previously extracted as
109
global scripts are now extracted as modules.
10+
* Top-level `await` is now supported.

cpp/ql/src/semmle/code/cpp/Variable.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class ParameterDeclarationEntry extends VariableDeclarationEntry {
315315
* static int c;
316316
* }
317317
* ```
318-
*
318+
*
319319
* Local variables can be static; use the `isStatic` member predicate to
320320
* detect those.
321321
*/
@@ -343,7 +343,7 @@ deprecated class StackVariable extends Variable {
343343
* static int c;
344344
* }
345345
* ```
346-
*
346+
*
347347
* Local variables can be static; use the `isStatic` member predicate to detect
348348
* those.
349349
*
@@ -512,9 +512,9 @@ class TemplateVariable extends Variable {
512512
* void myTemplateFunction() {
513513
* T b;
514514
* }
515-
*
515+
*
516516
* ...
517-
*
517+
*
518518
* myTemplateFunction<int>();
519519
* ```
520520
*/

cpp/ql/src/semmle/code/cpp/commons/CommonType.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ class MicrosoftInt64Type extends IntegralType {
174174
* `__builtin_va_copy` and `__builtin_va_arg` expressions.
175175
*/
176176
class BuiltInVarArgsList extends Type {
177-
BuiltInVarArgsList() {
178-
this.hasName("__builtin_va_list")
179-
}
177+
BuiltInVarArgsList() { this.hasName("__builtin_va_list") }
180178

181179
override string getCanonicalQLClass() { result = "BuiltInVarArgsList" }
182180
}

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,9 @@ abstract class PathNode extends TPathNode {
16181618
/** Gets a successor of this node, if any. */
16191619
abstract PathNode getASuccessor();
16201620

1621+
/** Holds if this node is a source. */
1622+
abstract predicate isSource();
1623+
16211624
private string ppAp() {
16221625
this instanceof PathNodeSink and result = ""
16231626
or
@@ -1683,12 +1686,6 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
16831686
// an intermediate step to another intermediate node
16841687
result = getSuccMid()
16851688
or
1686-
// a final step to a sink via one or more local steps
1687-
localFlowStepPlus(node, result.getNode(), _, config) and
1688-
ap instanceof AccessPathNil and
1689-
result instanceof PathNodeSink and
1690-
result.getConfiguration() = unbind(this.getConfiguration())
1691-
or
16921689
// a final step to a sink via zero steps means we merge the last two steps to prevent trivial-looking edges
16931690
exists(PathNodeMid mid |
16941691
mid = getSuccMid() and
@@ -1697,23 +1694,12 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
16971694
result instanceof PathNodeSink and
16981695
result.getConfiguration() = unbind(mid.getConfiguration())
16991696
)
1700-
or
1701-
// a direct step from a source to a sink if a node is both
1702-
this instanceof PathNodeSource and
1703-
result instanceof PathNodeSink and
1704-
this.getNode() = result.getNode() and
1705-
result.getConfiguration() = unbind(this.getConfiguration())
17061697
}
1707-
}
17081698

1709-
/**
1710-
* A flow graph node corresponding to a source.
1711-
*/
1712-
private class PathNodeSource extends PathNodeMid {
1713-
PathNodeSource() {
1714-
getConfiguration().isSource(getNode()) and
1715-
getCallContext() instanceof CallContextAny and
1716-
getAp() instanceof AccessPathNil
1699+
override predicate isSource() {
1700+
config.isSource(node) and
1701+
cc instanceof CallContextAny and
1702+
ap instanceof AccessPathNil
17171703
}
17181704
}
17191705

@@ -1733,6 +1719,8 @@ private class PathNodeSink extends PathNode, TPathNodeSink {
17331719
override Configuration getConfiguration() { result = config }
17341720

17351721
override PathNode getASuccessor() { none() }
1722+
1723+
override predicate isSource() { config.isSource(node) }
17361724
}
17371725

17381726
/**
@@ -1967,12 +1955,12 @@ private predicate valuePathThroughCallable(PathNodeMid mid, OutNode out, CallCon
19671955
* sinks.
19681956
*/
19691957
private predicate flowsTo(
1970-
PathNodeSource flowsource, PathNodeSink flowsink, Node source, Node sink,
1971-
Configuration configuration
1958+
PathNode flowsource, PathNodeSink flowsink, Node source, Node sink, Configuration configuration
19721959
) {
1960+
flowsource.isSource() and
19731961
flowsource.getConfiguration() = configuration and
19741962
flowsource.getNode() = source and
1975-
pathSuccPlus(flowsource, flowsink) and
1963+
(flowsource = flowsink or pathSuccPlus(flowsource, flowsink)) and
19761964
flowsink.getNode() = sink
19771965
}
19781966

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,9 @@ abstract class PathNode extends TPathNode {
16181618
/** Gets a successor of this node, if any. */
16191619
abstract PathNode getASuccessor();
16201620

1621+
/** Holds if this node is a source. */
1622+
abstract predicate isSource();
1623+
16211624
private string ppAp() {
16221625
this instanceof PathNodeSink and result = ""
16231626
or
@@ -1683,12 +1686,6 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
16831686
// an intermediate step to another intermediate node
16841687
result = getSuccMid()
16851688
or
1686-
// a final step to a sink via one or more local steps
1687-
localFlowStepPlus(node, result.getNode(), _, config) and
1688-
ap instanceof AccessPathNil and
1689-
result instanceof PathNodeSink and
1690-
result.getConfiguration() = unbind(this.getConfiguration())
1691-
or
16921689
// a final step to a sink via zero steps means we merge the last two steps to prevent trivial-looking edges
16931690
exists(PathNodeMid mid |
16941691
mid = getSuccMid() and
@@ -1697,23 +1694,12 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
16971694
result instanceof PathNodeSink and
16981695
result.getConfiguration() = unbind(mid.getConfiguration())
16991696
)
1700-
or
1701-
// a direct step from a source to a sink if a node is both
1702-
this instanceof PathNodeSource and
1703-
result instanceof PathNodeSink and
1704-
this.getNode() = result.getNode() and
1705-
result.getConfiguration() = unbind(this.getConfiguration())
17061697
}
1707-
}
17081698

1709-
/**
1710-
* A flow graph node corresponding to a source.
1711-
*/
1712-
private class PathNodeSource extends PathNodeMid {
1713-
PathNodeSource() {
1714-
getConfiguration().isSource(getNode()) and
1715-
getCallContext() instanceof CallContextAny and
1716-
getAp() instanceof AccessPathNil
1699+
override predicate isSource() {
1700+
config.isSource(node) and
1701+
cc instanceof CallContextAny and
1702+
ap instanceof AccessPathNil
17171703
}
17181704
}
17191705

@@ -1733,6 +1719,8 @@ private class PathNodeSink extends PathNode, TPathNodeSink {
17331719
override Configuration getConfiguration() { result = config }
17341720

17351721
override PathNode getASuccessor() { none() }
1722+
1723+
override predicate isSource() { config.isSource(node) }
17361724
}
17371725

17381726
/**
@@ -1967,12 +1955,12 @@ private predicate valuePathThroughCallable(PathNodeMid mid, OutNode out, CallCon
19671955
* sinks.
19681956
*/
19691957
private predicate flowsTo(
1970-
PathNodeSource flowsource, PathNodeSink flowsink, Node source, Node sink,
1971-
Configuration configuration
1958+
PathNode flowsource, PathNodeSink flowsink, Node source, Node sink, Configuration configuration
19721959
) {
1960+
flowsource.isSource() and
19731961
flowsource.getConfiguration() = configuration and
19741962
flowsource.getNode() = source and
1975-
pathSuccPlus(flowsource, flowsink) and
1963+
(flowsource = flowsink or pathSuccPlus(flowsource, flowsink)) and
19761964
flowsink.getNode() = sink
19771965
}
19781966

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,9 @@ abstract class PathNode extends TPathNode {
16181618
/** Gets a successor of this node, if any. */
16191619
abstract PathNode getASuccessor();
16201620

1621+
/** Holds if this node is a source. */
1622+
abstract predicate isSource();
1623+
16211624
private string ppAp() {
16221625
this instanceof PathNodeSink and result = ""
16231626
or
@@ -1683,12 +1686,6 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
16831686
// an intermediate step to another intermediate node
16841687
result = getSuccMid()
16851688
or
1686-
// a final step to a sink via one or more local steps
1687-
localFlowStepPlus(node, result.getNode(), _, config) and
1688-
ap instanceof AccessPathNil and
1689-
result instanceof PathNodeSink and
1690-
result.getConfiguration() = unbind(this.getConfiguration())
1691-
or
16921689
// a final step to a sink via zero steps means we merge the last two steps to prevent trivial-looking edges
16931690
exists(PathNodeMid mid |
16941691
mid = getSuccMid() and
@@ -1697,23 +1694,12 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
16971694
result instanceof PathNodeSink and
16981695
result.getConfiguration() = unbind(mid.getConfiguration())
16991696
)
1700-
or
1701-
// a direct step from a source to a sink if a node is both
1702-
this instanceof PathNodeSource and
1703-
result instanceof PathNodeSink and
1704-
this.getNode() = result.getNode() and
1705-
result.getConfiguration() = unbind(this.getConfiguration())
17061697
}
1707-
}
17081698

1709-
/**
1710-
* A flow graph node corresponding to a source.
1711-
*/
1712-
private class PathNodeSource extends PathNodeMid {
1713-
PathNodeSource() {
1714-
getConfiguration().isSource(getNode()) and
1715-
getCallContext() instanceof CallContextAny and
1716-
getAp() instanceof AccessPathNil
1699+
override predicate isSource() {
1700+
config.isSource(node) and
1701+
cc instanceof CallContextAny and
1702+
ap instanceof AccessPathNil
17171703
}
17181704
}
17191705

@@ -1733,6 +1719,8 @@ private class PathNodeSink extends PathNode, TPathNodeSink {
17331719
override Configuration getConfiguration() { result = config }
17341720

17351721
override PathNode getASuccessor() { none() }
1722+
1723+
override predicate isSource() { config.isSource(node) }
17361724
}
17371725

17381726
/**
@@ -1967,12 +1955,12 @@ private predicate valuePathThroughCallable(PathNodeMid mid, OutNode out, CallCon
19671955
* sinks.
19681956
*/
19691957
private predicate flowsTo(
1970-
PathNodeSource flowsource, PathNodeSink flowsink, Node source, Node sink,
1971-
Configuration configuration
1958+
PathNode flowsource, PathNodeSink flowsink, Node source, Node sink, Configuration configuration
19721959
) {
1960+
flowsource.isSource() and
19731961
flowsource.getConfiguration() = configuration and
19741962
flowsource.getNode() = source and
1975-
pathSuccPlus(flowsource, flowsink) and
1963+
(flowsource = flowsink or pathSuccPlus(flowsource, flowsink)) and
19761964
flowsink.getNode() = sink
19771965
}
19781966

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,9 @@ abstract class PathNode extends TPathNode {
16181618
/** Gets a successor of this node, if any. */
16191619
abstract PathNode getASuccessor();
16201620

1621+
/** Holds if this node is a source. */
1622+
abstract predicate isSource();
1623+
16211624
private string ppAp() {
16221625
this instanceof PathNodeSink and result = ""
16231626
or
@@ -1683,12 +1686,6 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
16831686
// an intermediate step to another intermediate node
16841687
result = getSuccMid()
16851688
or
1686-
// a final step to a sink via one or more local steps
1687-
localFlowStepPlus(node, result.getNode(), _, config) and
1688-
ap instanceof AccessPathNil and
1689-
result instanceof PathNodeSink and
1690-
result.getConfiguration() = unbind(this.getConfiguration())
1691-
or
16921689
// a final step to a sink via zero steps means we merge the last two steps to prevent trivial-looking edges
16931690
exists(PathNodeMid mid |
16941691
mid = getSuccMid() and
@@ -1697,23 +1694,12 @@ private class PathNodeMid extends PathNode, TPathNodeMid {
16971694
result instanceof PathNodeSink and
16981695
result.getConfiguration() = unbind(mid.getConfiguration())
16991696
)
1700-
or
1701-
// a direct step from a source to a sink if a node is both
1702-
this instanceof PathNodeSource and
1703-
result instanceof PathNodeSink and
1704-
this.getNode() = result.getNode() and
1705-
result.getConfiguration() = unbind(this.getConfiguration())
17061697
}
1707-
}
17081698

1709-
/**
1710-
* A flow graph node corresponding to a source.
1711-
*/
1712-
private class PathNodeSource extends PathNodeMid {
1713-
PathNodeSource() {
1714-
getConfiguration().isSource(getNode()) and
1715-
getCallContext() instanceof CallContextAny and
1716-
getAp() instanceof AccessPathNil
1699+
override predicate isSource() {
1700+
config.isSource(node) and
1701+
cc instanceof CallContextAny and
1702+
ap instanceof AccessPathNil
17171703
}
17181704
}
17191705

@@ -1733,6 +1719,8 @@ private class PathNodeSink extends PathNode, TPathNodeSink {
17331719
override Configuration getConfiguration() { result = config }
17341720

17351721
override PathNode getASuccessor() { none() }
1722+
1723+
override predicate isSource() { config.isSource(node) }
17361724
}
17371725

17381726
/**
@@ -1967,12 +1955,12 @@ private predicate valuePathThroughCallable(PathNodeMid mid, OutNode out, CallCon
19671955
* sinks.
19681956
*/
19691957
private predicate flowsTo(
1970-
PathNodeSource flowsource, PathNodeSink flowsink, Node source, Node sink,
1971-
Configuration configuration
1958+
PathNode flowsource, PathNodeSink flowsink, Node source, Node sink, Configuration configuration
19721959
) {
1960+
flowsource.isSource() and
19731961
flowsource.getConfiguration() = configuration and
19741962
flowsource.getNode() = source and
1975-
pathSuccPlus(flowsource, flowsink) and
1963+
(flowsource = flowsink or pathSuccPlus(flowsource, flowsink)) and
19761964
flowsink.getNode() = sink
19771965
}
19781966

0 commit comments

Comments
 (0)