Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 951d597

Browse files
committed
Address review comments 7
1 parent 2e60d40 commit 951d597

File tree

3 files changed

+73
-75
lines changed

3 files changed

+73
-75
lines changed

ql/src/Security/CWE-681/IncorrectIntegerConversion.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ from
196196
DataFlow::PathNode source, DataFlow::PathNode sink, ConversionWithoutBoundsCheckConfig cfg,
197197
DataFlow::CallNode call
198198
where cfg.hasFlowPath(source, sink) and call.getResult(0) = source.getNode()
199-
select source.getNode(), source, sink,
199+
select sink.getNode(), source, sink,
200200
"Incorrect conversion of " +
201201
describeBitSize(cfg.getSourceBitSize(), getIntTypeBitSize(source.getNode().getFile())) +
202-
" from " + call.getTarget().getQualifiedName() + " to a lower bit size type " +
203-
sink.getNode().getType().getUnderlyingType().getName() + " without an upper bound check."
202+
" from $@ to a lower bit size type " + sink.getNode().getType().getUnderlyingType().getName() +
203+
" without an upper bound check.", source, call.getTarget().getQualifiedName()

ql/src/semmle/go/Files.qll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ class File extends Container, @file, Documentable, ExprParent, GoModExprParent,
219219
* which can be 32 or 64.
220220
*/
221221
predicate explicitlyConstrainsIntBitSize(int bitSize) {
222-
exists(BuildConstraintComment bcc, string bc |
223-
this = bcc.getFile() and bc = bcc.getText().splitAt("+build ", 1)
224-
|
222+
exists(BuildConstraintComment bcc | this = bcc.getFile() |
225223
forex(string disjunct | disjunct = bcc.getADisjunct() |
226224
disjunct.splitAt(",").(Architecture).getBitSize() = bitSize
227225
)
@@ -234,9 +232,9 @@ class File extends Container, @file, Documentable, ExprParent, GoModExprParent,
234232
* architecture of bit size `bitSize`, which can be 32 or 64.
235233
*/
236234
predicate implicitlyConstrainsIntBitSize(int bitSize) {
237-
this
238-
.getStem()
239-
.regexpMatch(".*_" + any(Architecture arch | arch.getBitSize() = bitSize) + "(_test)?")
235+
exists(Architecture arch | arch.getBitSize() = bitSize |
236+
this.getStem().regexpMatch("(?i).*_\\Q" + arch + "\\E(_test)?")
237+
)
240238
}
241239

242240
override string toString() { result = Container.super.toString() }

0 commit comments

Comments
 (0)