Resolve namespace of object stored in variable (Ruby) #16114
Unanswered
0x73746F70626F74686572696E676D65
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I'd personally approach this by using API graphs to find module instances ( private import codeql.ruby.typetracking.TypeTracking
private DataFlow::LocalSourceNode trackModuleInstance(DataFlow::ModuleNode m, TypeTracker t) {
t.start() and
result.track() = m.trackInstance()
or
exists(TypeTracker t2 | result = trackModuleInstance(m, t2).track(t2, t))
}
private DataFlow::Node trackModuleInstance(DataFlow::ModuleNode m) {
trackModuleInstance(m, TypeTracker::end()).flowsTo(result)
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How can I resolve
var
toScope1::Scope2::Object
givenvar = Scope1::Scope2::Object.new
? Since this has to be interprocedural, the most obvious way seems to use the global DataFlow library and construct a configuration for this but I think it's odd that it's proven this difficult to do this a simpler, shorter way. Why isn't there a simple predicate in the API or DataFlow nodes that allows just resolving the receiver object? Not the direct receiver expression like the variable or a return value (Object.new.method
and you want to resolve the receiver of method to the Object constant access, not the return value of new). Can anyone help?Beta Was this translation helpful? Give feedback.
All reactions