Skip to content

Commit bf5ba33

Browse files
committed
Improve join orders for top 5 perf regressions in QA
1 parent 365ccf4 commit bf5ba33

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

go/ql/lib/semmle/go/frameworks/Afero.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ module Afero {
6565
exists(Function f |
6666
f.hasQualifiedName(aferoPackage(),
6767
["WriteReader", "SafeWriteReader", "WriteFile", "ReadFile", "ReadDir"]) and
68-
this = f.getACall() and
68+
this = pragma[only_bind_out](f.getACall()) and
6969
pathArg = 1 and
7070
not aferoSanitizer(this.getArgument(0))
7171
)
7272
or
7373
exists(Method m |
7474
m.hasQualifiedName(aferoPackage(), "Afero",
7575
["WriteReader", "SafeWriteReader", "WriteFile", "ReadFile", "ReadDir"]) and
76-
this = m.getACall() and
76+
this = pragma[only_bind_out](m.getACall()) and
7777
pathArg = 0 and
7878
not aferoSanitizer(this.getReceiver())
7979
)

go/ql/lib/semmle/go/frameworks/GoMicro.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ module GoMicro {
9898
}
9999
}
100100

101+
bindingset[m]
102+
pragma[inline_late]
103+
private predicate implementsServiceType(Method m) {
104+
m.implements(any(ServiceInterfaceType i).getNamedType().getMethod(_))
105+
}
106+
101107
/**
102108
* A service handler.
103109
*/
@@ -106,7 +112,7 @@ module GoMicro {
106112
exists(DataFlow::CallNode call |
107113
call.getTarget() instanceof ServiceRegisterHandler and
108114
this = call.getArgument(1).getType().getMethod(_) and
109-
this.implements(any(ServiceInterfaceType i).getNamedType().getMethod(_))
115+
implementsServiceType(this)
110116
)
111117
}
112118
}

go/ql/lib/semmle/go/frameworks/Twirp.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,19 @@ module Twirp {
118118
override string getKind() { result = "URL" }
119119
}
120120

121+
bindingset[m]
122+
pragma[inline_late]
123+
private predicate implementsServiceType(Method m) {
124+
m.implements(any(ServiceInterfaceType i).getNamedType().getMethod(_))
125+
}
126+
121127
/** A service handler. */
122128
class ServiceHandler extends Method {
123129
ServiceHandler() {
124130
exists(DataFlow::CallNode call |
125131
call.getTarget() instanceof ServerConstructor and
126132
this = call.getArgument(0).getType().getMethod(_) and
127-
this.implements(any(ServiceInterfaceType i).getNamedType().getMethod(_))
133+
implementsServiceType(this)
128134
)
129135
}
130136
}

go/ql/src/Security/CWE-798/HardcodedCredentials.ql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ import go
1717
import semmle.go.security.HardcodedCredentials
1818
import semmle.go.security.SensitiveActions
1919

20+
bindingset[write]
21+
pragma[inline_late]
22+
private predicate isWriteRhs(Write write, DataFlow::Node rhs) { write.getRhs() = rhs }
23+
2024
/**
2125
* Holds if `sink` is used in a context that suggests it may hold sensitive data of
2226
* the given `type`.
2327
*/
2428
predicate isSensitive(DataFlow::Node sink, SensitiveExpr::Classification type) {
2529
exists(Write write, string name |
26-
write.getRhs() = sink and
30+
isWriteRhs(write, sink) and
2731
name = write.getLhs().getName() and
2832
// allow obvious test password variables
2933
not name.regexpMatch(HeuristicNames::notSensitive())

0 commit comments

Comments
 (0)