Merge pull request #19259 from hvitved/ruby/fix-bad-join

Ruby: Fix bad join in `DeadStoreOfLocal.ql`
This commit is contained in:
Tom Hvitved
2025-04-09 19:03:33 +02:00
committed by GitHub

View File

@@ -11,15 +11,20 @@
*/
import codeql.ruby.AST
import codeql.ruby.CFG
import codeql.ruby.dataflow.SSA
import codeql.ruby.ApiGraphs
pragma[nomagic]
private predicate hasErbResultCall(CfgScope scope) {
scope = API::getTopLevelMember("ERB").getInstance().getAMethodCall("result").asExpr().getScope()
}
class RelevantLocalVariableWriteAccess extends LocalVariableWriteAccess {
RelevantLocalVariableWriteAccess() {
not this.getVariable().getName().charAt(0) = "_" and
not this = any(Parameter p).getAVariable().getDefiningAccess() and
not API::getTopLevelMember("ERB").getInstance().getAMethodCall("result").asExpr().getScope() =
this.getCfgScope() and
not hasErbResultCall(this.getCfgScope()) and
not exists(RetryStmt r | r.getCfgScope() = this.getCfgScope()) and
not exists(MethodCall c |
c.getReceiver() instanceof SelfVariableAccess and