Skip to content

Commit 85c4daa

Browse files
committed
Address comments
1 parent 65f8f56 commit 85c4daa

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

ruby/ql/lib/codeql/ruby/InclusionTests.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ private import codeql.ruby.controlflow.CfgNodes
1919
*/
2020
class InclusionTest extends DataFlow::Node instanceof InclusionTest::Range {
2121
/** Gets the `A` in `A.include?(B)`. */
22-
DataFlow::Node getContainerNode() { result = super.getContainerNode() }
22+
final DataFlow::Node getContainerNode() { result = super.getContainerNode() }
2323

2424
/** Gets the `B` in `A.include?(B)`. */
25-
DataFlow::Node getContainedNode() { result = super.getContainedNode() }
25+
final DataFlow::Node getContainedNode() { result = super.getContainedNode() }
2626

2727
/**
2828
* Gets the polarity of the check.
2929
*
3030
* If the polarity is `false` the check returns `true` if the container does not contain
3131
* the given element.
3232
*/
33-
boolean getPolarity() { result = super.getPolarity() }
33+
final boolean getPolarity() { result = super.getPolarity() }
3434
}
3535

3636
/**
@@ -65,7 +65,7 @@ module InclusionTest {
6565
private class Includes_Native extends Range, DataFlow::CallNode {
6666
Includes_Native() {
6767
this.getMethodName() = "include?" and
68-
count(this.getArgument(_)) = 1
68+
strictcount(this.getArgument(_)) = 1
6969
}
7070

7171
override DataFlow::Node getContainerNode() { result = this.getReceiver() }
@@ -91,7 +91,7 @@ module InclusionTest {
9191
(
9292
value = index.getConstantValue().getInt() and value = 0
9393
or
94-
index.getExpr() instanceof NilLiteral and value = -1
94+
index.getConstantValue().isNil() and value = -1
9595
)
9696
|
9797
value = -1 and polarity = false and comparison.getExpr() instanceof CaseEqExpr

ruby/ql/lib/codeql/ruby/StringOps.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ module StringOps {
1818
/**
1919
* Gets the `A` in `A.start_with?(B)`.
2020
*/
21-
DataFlow::Node getBaseString() { result = super.getBaseString() }
21+
final DataFlow::Node getBaseString() { result = super.getBaseString() }
2222

2323
/**
2424
* Gets the `B` in `A.start_with?(B)`.
2525
*/
26-
DataFlow::Node getSubstring() { result = super.getSubstring() }
26+
final DataFlow::Node getSubstring() { result = super.getSubstring() }
2727

2828
/**
2929
* Gets the polarity of the check.
3030
*
3131
* If the polarity is `false` the check returns `true` if the string does not start
3232
* with the given substring.
3333
*/
34-
boolean getPolarity() { result = super.getPolarity() }
34+
final boolean getPolarity() { result = super.getPolarity() }
3535
}
3636

3737
/**
@@ -75,15 +75,15 @@ module StringOps {
7575
/**
7676
* An expression of form `A.index(B) == 0` or `A.index(B) != 0`.
7777
*/
78-
private class StartsWith_IndexOfEquals extends Range, DataFlow::Node {
78+
private class StartsWith_IndexOfEquals extends Range {
7979
private DataFlow::CallNode indexOf;
8080
private boolean polarity;
8181

8282
StartsWith_IndexOfEquals() {
8383
exists(ExprNodes::ComparisonOperationCfgNode comparison |
8484
this.asExpr() = comparison and
8585
indexOf.getMethodName() = "index" and
86-
count(indexOf.getArgument(_)) = 1 and
86+
strictcount(indexOf.getArgument(_)) = 1 and
8787
indexOf.flowsTo(any(DataFlow::Node n | n.asExpr() = comparison.getAnOperand())) and
8888
comparison.getAnOperand().getConstantValue().getInt() = 0
8989
|
@@ -110,10 +110,10 @@ module StringOps {
110110
*/
111111
class Includes extends InclusionTest {
112112
/** Gets the `A` in `A.include?(B)`. */
113-
DataFlow::Node getBaseString() { result = super.getContainerNode() }
113+
final DataFlow::Node getBaseString() { result = super.getContainerNode() }
114114

115115
/** Gets the `B` in `A.include?(B)`. */
116-
DataFlow::Node getSubstring() { result = super.getContainedNode() }
116+
final DataFlow::Node getSubstring() { result = super.getContainedNode() }
117117
}
118118

119119
/**
@@ -123,20 +123,20 @@ module StringOps {
123123
/**
124124
* Gets the `A` in `A.start_with?(B)`.
125125
*/
126-
DataFlow::Node getBaseString() { result = super.getBaseString() }
126+
final DataFlow::Node getBaseString() { result = super.getBaseString() }
127127

128128
/**
129129
* Gets the `B` in `A.start_with?(B)`.
130130
*/
131-
DataFlow::Node getSubstring() { result = super.getSubstring() }
131+
final DataFlow::Node getSubstring() { result = super.getSubstring() }
132132

133133
/**
134134
* Gets the polarity if the check.
135135
*
136136
* If the polarity is `false` the check returns `true` if the string does not end
137137
* with the given substring.
138138
*/
139-
boolean getPolarity() { result = super.getPolarity() }
139+
final boolean getPolarity() { result = super.getPolarity() }
140140
}
141141

142142
/**

ruby/ql/src/queries/security/cwe-020/IncompleteUrlSubstringSanitizationSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import codeql.ruby.security.performance.RegExpTreeView::RegExpPatterns as RegExp
44

55
/** Holds if `node` may evaluate to `value` */
66
predicate mayHaveStringValue(DataFlow::Node node, string value) {
7-
node.asExpr().getExpr().getConstantValue().getString() = value
7+
node.asExpr().getConstantValue().getString() = value
88
}

0 commit comments

Comments
 (0)