Skip to content

Commit 3e4a182

Browse files
authored
Merge pull request #7450 from erik-krogh/missDocParam
QL: Add query detecting suspiciously missing parameters from the QLDoc of a predicate
2 parents 2aaedac + cd5fbe6 commit 3e4a182

Some content is hidden

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

44 files changed

+199
-87
lines changed

javascript/ql/examples/queries/dataflow/TemplateInjection/TemplateInjection.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import DataFlow::PathGraph
1414
/**
1515
* Gets the name of an unescaped placeholder in a lodash template.
1616
*
17-
* For example, the string `<h1><%= title %></h1>` contains the placeholder `title`.
17+
* For example, the string `"<h1><%= title %></h1>"` contains the placeholder "title".
1818
*/
1919
bindingset[s]
2020
string getAPlaceholderInString(string s) {

javascript/ql/lib/definitions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private predicate variableDefLookup(VarAccess va, AstNode def, string kind) {
4545

4646
/**
4747
* Holds if variable access `va` is of kind `kind` and refers to the
48-
* variable declaration.
48+
* variable declaration `decl`.
4949
*
5050
* For example, in the statement `var x = 42, y = x;`, the initializing
5151
* expression of `y` is a variable access `x` of kind `"V"` that refers to

javascript/ql/lib/semmle/javascript/BasicBlocks.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class BasicBlock extends @cfg_node, NodeInStmtContainer {
146146
/** Holds if this basic block uses variable `v` in its `i`th node `u`. */
147147
predicate useAt(int i, Variable v, VarUse u) { useAt(this, i, v, u) }
148148

149-
/** Holds if this basic block defines variable `v` in its `i`th node `u`. */
149+
/** Holds if this basic block defines variable `v` in its `i`th node `d`. */
150150
predicate defAt(int i, Variable v, VarDef d) { defAt(this, i, v, d) }
151151

152152
/**

javascript/ql/lib/semmle/javascript/CharacterEscapes.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module CharacterEscapes {
7575
}
7676

7777
/**
78-
* Gets a character in `n` that is preceded by a single useless backslash, resulting in a likely regular expression mistake explained by `mistake`.
78+
* Gets a character in `src` that is preceded by a single useless backslash, resulting in a likely regular expression mistake explained by `mistake`.
7979
*
8080
* The character is the `i`th character of the raw string value of `rawStringNode`.
8181
*/

javascript/ql/lib/semmle/javascript/Classes.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class ClassDefinition extends @class_definition, ClassOrInterface, AST::ValueNod
172172
/** Gets the expression denoting the super class of the defined class, if any. */
173173
override Expr getSuperClass() { result = this.getChildExpr(1) }
174174

175-
/** Gets the `n`th type from the `implements` clause of this class, starting at 0. */
175+
/** Gets the `i`th type from the `implements` clause of this class, starting at 0. */
176176
override TypeExpr getSuperInterface(int i) {
177177
// AST indices for super interfaces: -1, -4, -7, ...
178178
exists(int astIndex | typeexprs(result, _, this, astIndex, _) |

javascript/ql/lib/semmle/javascript/ES2015Modules.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private predicate hasNamedExports(ES2015Module mod) {
5454
}
5555

5656
/**
57-
* Holds if this module contains a `default` export.
57+
* Holds if this module contains a default export.
5858
*/
5959
private predicate hasDefaultExport(ES2015Module mod) {
6060
// export default foo;
@@ -337,7 +337,7 @@ class BulkReExportDeclaration extends ReExportDeclaration, @export_all_declarati
337337
}
338338

339339
/**
340-
* Holds if the given bulk export should not re-export `name` because there is an explicit export
340+
* Holds if the given bulk export `reExport` should not re-export `name` because there is an explicit export
341341
* of that name in the same module.
342342
*
343343
* At compile time, shadowing works across declaration spaces.

javascript/ql/lib/semmle/javascript/Paths.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private Path resolveUpTo(PathString p, int n, Folder root, boolean inTS) {
180180
}
181181

182182
/**
183-
* Gets the `i`th component of the path `str`, where `base` is the resolved path one level up.
183+
* Gets the `n`th component of the path `str`, where `base` is the resolved path one level up.
184184
* Supports that the root directory might be compiled output from TypeScript.
185185
* `inTS` is true if the result is TypeScript that is compiled into the path specified by `str`.
186186
*/
@@ -227,7 +227,7 @@ private module TypeScriptOutDir {
227227
}
228228

229229
/**
230-
* Gets the `outDir` option from a tsconfig file from the folder `parent`.
230+
* Gets the "outDir" option from a `tsconfig` file from the folder `parent`.
231231
*/
232232
private string getOutDir(JsonObject tsconfig, Folder parent) {
233233
tsconfig.getFile().getBaseName().regexpMatch("tsconfig.*\\.json") and

javascript/ql/lib/semmle/javascript/PrintAst.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private module PrintJavaScript {
195195
* Gets the `i`th child of `element`.
196196
* Can be overridden in subclasses to get more specific behavior for `getChild()`.
197197
*/
198-
AstNode getChildNode(int childIndex) { result = getLocationSortedChild(element, childIndex) }
198+
AstNode getChildNode(int i) { result = getLocationSortedChild(element, i) }
199199
}
200200

201201
/** Provides predicates for pretty printing `AstNode`s. */

javascript/ql/lib/semmle/javascript/RangeAnalysis.qll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ module RangeAnalysis {
260260
}
261261

262262
/**
263-
* Holds if the given comparison can be modeled as `A <op> B + bias` where `<op>` is the comparison operator,
263+
* Holds if the given `comparison` can be modeled as `A <op> B + bias` where `<op>` is the comparison operator,
264264
* and `A` is `a * asign` and likewise `B` is `b * bsign`.
265265
*/
266266
predicate linearComparison(
@@ -310,18 +310,18 @@ module RangeAnalysis {
310310
* Holds if `guard` asserts that the outcome of `A <op> B + bias` is true, where `<op>` is a comparison operator.
311311
*/
312312
predicate linearComparisonGuard(
313-
ConditionGuardNode guard, DataFlow::Node a, int asign, string operator, DataFlow::Node b,
314-
int bsign, Bias bias
313+
ConditionGuardNode guard, DataFlow::Node a, int asign, string op, DataFlow::Node b, int bsign,
314+
Bias bias
315315
) {
316316
exists(Comparison compare |
317317
compare = guard.getTest().flow().getImmediatePredecessor*().asExpr() and
318318
linearComparison(compare, a, asign, b, bsign, bias) and
319319
(
320-
guard.getOutcome() = true and operator = compare.getOperator()
320+
guard.getOutcome() = true and op = compare.getOperator()
321321
or
322322
not hasNaNIndicator(guard.getContainer()) and
323323
guard.getOutcome() = false and
324-
operator = negateOperator(compare.getOperator())
324+
op = negateOperator(compare.getOperator())
325325
)
326326
)
327327
}
@@ -657,13 +657,13 @@ module RangeAnalysis {
657657
*/
658658
pragma[noopt]
659659
private predicate reachableByNegativeEdges(
660-
DataFlow::Node a, int asign, DataFlow::Node b, int bsign, ControlFlowNode cfg
660+
DataFlow::Node src, int asign, DataFlow::Node dst, int bsign, ControlFlowNode cfg
661661
) {
662-
negativeEdge(a, asign, b, bsign, cfg)
662+
negativeEdge(src, asign, dst, bsign, cfg)
663663
or
664664
exists(DataFlow::Node mid, int midx, ControlFlowNode midcfg |
665-
reachableByNegativeEdges(a, asign, mid, midx, cfg) and
666-
negativeEdge(mid, midx, b, bsign, midcfg) and
665+
reachableByNegativeEdges(src, asign, mid, midx, cfg) and
666+
negativeEdge(mid, midx, dst, bsign, midcfg) and
667667
exists(BasicBlock bb, int i, int j |
668668
bb.getNode(i) = midcfg and
669669
bb.getNode(j) = cfg and
@@ -676,8 +676,8 @@ module RangeAnalysis {
676676
DataFlow::Node mid, int midx, ControlFlowNode midcfg, BasicBlock midBB,
677677
ReachableBasicBlock midRBB, BasicBlock cfgBB
678678
|
679-
reachableByNegativeEdges(a, asign, mid, midx, cfg) and
680-
negativeEdge(mid, midx, b, bsign, midcfg) and
679+
reachableByNegativeEdges(src, asign, mid, midx, cfg) and
680+
negativeEdge(mid, midx, dst, bsign, midcfg) and
681681
midBB = midcfg.getBasicBlock() and
682682
midRBB = midBB.(ReachableBasicBlock) and
683683
cfgBB = cfg.getBasicBlock() and

javascript/ql/lib/semmle/javascript/Routing.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ module Routing {
229229
}
230230

231231
/**
232-
* Holds if `node` has processed the incoming request strictly prior to this node.
232+
* Holds if `guard` has processed the incoming request strictly prior to this node.
233233
*/
234234
pragma[inline]
235235
private predicate isGuardedByNodeInternal(Node guard) {

0 commit comments

Comments
 (0)