Skip to content

Commit 2dd42f7

Browse files
authored
Merge pull request github#16509 from owen-mc/go/fix-missing-underlying-types
Go: make two barriers recognise named types whose underlying types are integer types
2 parents 2b7394c + 8cc118f commit 2dd42f7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* A bug has been fixed which meant that the query `go/incorrect-integer-conversion` did not consider type assertions and type switches which use a defined type whose underlying type is an integer type. This may lead to fewer false positive alerts.

go/ql/lib/semmle/go/security/IncorrectIntegerConversionLib.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class TypeAssertionCheck extends DataFlow::ExprNode, FlowStateTransformer {
422422
TypeAssertionCheck() {
423423
exists(TypeAssertExpr tae |
424424
this = DataFlow::exprNode(tae.getExpr()) and
425-
it = tae.getTypeExpr().getType()
425+
it = tae.getTypeExpr().getType().getUnderlyingType()
426426
)
427427
}
428428

@@ -442,7 +442,7 @@ class TypeSwitchVarFlowStateTransformer extends DataFlow::SsaNode, FlowStateTran
442442
TypeSwitchVarFlowStateTransformer() {
443443
exists(IR::TypeSwitchImplicitVariableInstruction insn, LocalVariable lv | insn.writes(lv, _) |
444444
this.getSourceVariable() = lv and
445-
it = lv.getType()
445+
it = lv.getType().getUnderlyingType()
446446
)
447447
}
448448

0 commit comments

Comments
 (0)