Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed amends to MaD subtypes promoted methods PR #2

Prev Previous commit
Document elementAppliesToQualifier
smowton committed Oct 23, 2024
commit c944f1d0bd6bf39d32df2c576bc71701fae3f47d
8 changes: 8 additions & 0 deletions go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll
Original file line number Diff line number Diff line change
@@ -271,6 +271,14 @@ module SourceSinkInterpretationInput implements
}
}

/**
* Holds if method or field spec `sse` applies in the context of qualifier `qual`.
*
* Note that naively checking `sse.asEntity()`'s qualified name is not correct, because
* `Method`s and `Field`s may have multiple qualified names due to embedding. We must instead
* check that the specific name given be `sse.hasTypeInfo` refers to either `qual`'s type
* or to a type it embeds.
*/
private predicate elementAppliesToQualifier(SourceOrSinkElement sse, DataFlow::Node qual) {
(
exists(DataFlow::CallNode cn | cn.getReceiver() = qual and cn.getTarget() = sse.asEntity())