Skip to content

Go: fix models through redefined types #19653

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ module SourceSinkInterpretationInput implements
or
n2.asExpr() = n.asInstruction().(IR::EvalImplicitDerefInstruction).getOperand()
|
result = lookThroughPointerType(skipImplicitFieldReads(n2).getType())
result =
maybeLookThroughNamedType(lookThroughPointerType(skipImplicitFieldReads(n2).getType()))
)
}

Expand All @@ -395,6 +396,12 @@ module SourceSinkInterpretationInput implements
.getBaseInstruction()
}

private DefinedType maybeLookThroughNamedType(DefinedType t) {
// We do not have information on what a defined type is defined to be, only
// the underlying type, so we have to be a bit imprecise.
result.getBaseType() = t.getBaseType()
}

/** Provides additional sink specification logic. */
bindingset[c]
predicate interpretOutput(string c, InterpretNode mid, InterpretNode node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,13 @@ func TestFieldsSEmbedS1AndSEmbedS1(t test.SEmbedS1AndSEmbedS1) {
a := t.SourceField
t.SinkField = a // $ S1[t] ql_S1
}

func TestFieldsRedefinedP1(t test.RedefinedP1) {
a := t.SourceField
t.SinkField = a // $ P1[f] P1[t] ql_P1
}

func TestFieldsRedefinedS1(t test.RedefinedS1) {
a := t.SourceField
t.SinkField = a // $ S1[f] S1[t] ql_S1
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,9 @@ func TestMethodsSEmbedS1AndSEmbedS1(t test.SEmbedS1AndSEmbedS1) {
y := t.Step(x)
t.Sink(y) // $ I1[t] S1[t] ql_S1
}

func TestMethodsRedefinedI1(t test.RedefinedI1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[f] I1[t] ql_I1 SPURIOUS: ql_P1 ql_S1
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.