Skip to content

Commit 36a0318

Browse files
committed
Further optimisation
1 parent ab99509 commit 36a0318

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

go/ql/lib/semmle/go/Expr.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,7 @@ class LabelName extends Name {
20982098
* may be identified as such, so not all type expressions can be determined by
20992099
* a bottom-up analysis. In such cases, `isTypeExprTopDown` below is useful.
21002100
*/
2101+
pragma[nomagic]
21012102
private predicate isTypeExprBottomUp(Expr e) {
21022103
e instanceof TypeName
21032104
or

go/ql/lib/semmle/go/controlflow/IR.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,11 @@ module IR {
501501
override StructLit lit;
502502

503503
/** Gets the name of the initialized field. */
504+
pragma[nomagic]
504505
string getFieldName() {
505506
if elt instanceof KeyValueExpr
506507
then result = elt.(KeyValueExpr).getKey().(Ident).getName()
507-
else lit.getStructType().hasOwnField(i, result, _, _)
508+
else pragma[only_bind_out](lit.getStructType()).hasOwnField(i, result, _, _)
508509
}
509510

510511
/** Gets the initialized field. */

go/ql/lib/semmle/go/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ predicate sliceStep(DataFlow::Node pred, DataFlow::Node succ) {
190190
*/
191191
abstract class FunctionModel extends Function {
192192
/** Holds if taint propagates through this function from `input` to `output`. */
193+
pragma[nomagic]
193194
abstract predicate hasTaintFlow(FunctionInput input, FunctionOutput output);
194195

195196
/** Gets an input node for this model for the call `c`. */

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ module OpenUrlRedirect {
7575
}
7676
}
7777

78+
bindingset[var, w]
79+
pragma[inline_late]
80+
private predicate useIsDominated(
81+
SsaWithFields var, Write w, DataFlow::ReadNode sanitizedRead
82+
) {
83+
w.dominatesNode(sanitizedRead.asInstruction()) and
84+
sanitizedRead = var.getAUse()
85+
}
86+
7887
/**
7988
* An access to a variable that is preceded by an assignment to its `Path` field.
8089
*
@@ -83,13 +92,10 @@ module OpenUrlRedirect {
8392
*/
8493
class PathAssignmentBarrier extends Barrier, Read {
8594
PathAssignmentBarrier() {
86-
exists(Write w, Field f, SsaWithFields var |
87-
f.getName() = "Path" and
95+
exists(Write w, SsaWithFields var |
8896
hasHostnameSanitizingSubstring(w.getRhs()) and
89-
this = var.getAUse()
90-
|
91-
w.writesField(var.getAUse(), f, _) and
92-
w.dominatesNode(insn)
97+
w.writesField(var.getAUse(), any(Field f | f.getName() = "Path"), _) and
98+
useIsDominated(var, w, this)
9399
)
94100
}
95101
}

0 commit comments

Comments
 (0)