Merge pull request #625 from smowton/smowton/fix/minor-perf-improvements

Improve performance: join-order AllocationSizeOverflow's source and use `matches` not `regexpFind`
This commit is contained in:
Chris Smowton
2021-12-13 10:36:02 +00:00
committed by GitHub
5 changed files with 13 additions and 5 deletions

View File

@@ -49,7 +49,8 @@ module AllocationSizeOverflow {
class MarshalingSource extends Source {
MarshalingSource() {
exists(MarshalingFunction marshal, DataFlow::CallNode call |
call = marshal.getACall() and
// Binding order tweak: start with marshalling function calls then work outwards:
pragma[only_bind_into](call) = marshal.getACall() and
// rule out cases where we can tell that the result will always be small
exists(FunctionInput inp | inp = marshal.getAnInput() | isBig(inp.getNode(call).asExpr())) and
this = marshal.getOutput().getNode(call)

View File

@@ -26,7 +26,10 @@ class DebugModeFlag extends FlagKind {
bindingset[result]
override string getAFlagName() {
result.regexpMatch("(?i).*(trace|debug|devel|(enable|disable|print)stack).*")
result
.toLowerCase()
.matches("%" + ["trace", "debug", "devel", "enablestack", "disablestack", "printstack"] +
"%")
}
}

View File

@@ -45,7 +45,7 @@ class InsecureCertificateFlag extends FlagKind {
bindingset[result]
override string getAFlagName() {
result.regexpMatch("(?i).*(selfCert|selfSign|validat|verif|trust).*")
result.toLowerCase().matches("%" + ["selfcert", "selfsign", "validat", "verif", "trust"] + "%")
}
}

View File

@@ -243,7 +243,9 @@ class LegacyTlsVersionFlag extends FlagKind {
LegacyTlsVersionFlag() { this = "legacyTlsVersion" }
bindingset[result]
override string getAFlagName() { result.regexpMatch("(?i).*(old|intermediate|legacy).*") }
override string getAFlagName() {
result.toLowerCase().matches("%" + ["old", "intermediate", "legacy"] + "%")
}
}
/**

View File

@@ -22,7 +22,9 @@ class AllowedFlag extends FlagKind {
bindingset[result]
override string getAFlagName() {
result.regexpMatch("(?i).*(allow|match|check|debug|devel|insecure).*")
result
.toLowerCase()
.matches("%" + ["allow", "match", "check", "debug", "devel", "insecure"] + "%")
}
}