-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
C#: Correctly parse operator names in MaD #14678
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,27 +87,45 @@ | |
*/ | ||
|
||
import csharp | ||
private import ExternalFlowExtensions as Extensions | ||
private import internal.AccessPathSyntax | ||
private import internal.DataFlowDispatch | ||
private import internal.DataFlowPrivate | ||
private import internal.DataFlowPublic | ||
private import internal.FlowSummaryImpl::Public | ||
private import internal.FlowSummaryImpl::Private::External | ||
private import internal.FlowSummaryImplSpecific | ||
private import AccessPathSyntax | ||
private import DataFlowDispatch | ||
private import DataFlowPrivate | ||
private import DataFlowPublic | ||
private import FlowSummaryImpl::Public | ||
private import FlowSummaryImpl::Private::External | ||
private import FlowSummaryImplSpecific | ||
private import codeql.mad.ModelValidation as SharedModelVal | ||
|
||
/** Holds if a source model exists for the given parameters. */ | ||
predicate sourceModel = Extensions::sourceModel/9; | ||
/** | ||
* Holds if a source model exists for the given parameters. | ||
*/ | ||
extensible predicate sourceModel( | ||
string namespace, string type, boolean subtypes, string name, string signature, string ext, | ||
string output, string kind, string provenance | ||
); | ||
|
||
/** Holds if a sink model exists for the given parameters. */ | ||
predicate sinkModel = Extensions::sinkModel/9; | ||
/** | ||
* Holds if a sink model exists for the given parameters. | ||
*/ | ||
extensible predicate sinkModel( | ||
string namespace, string type, boolean subtypes, string name, string signature, string ext, | ||
string input, string kind, string provenance | ||
); | ||
|
||
/** Holds if a summary model exists for the given parameters. */ | ||
predicate summaryModel = Extensions::summaryModel/10; | ||
/** | ||
* Holds if a summary model exists for the given parameters. | ||
*/ | ||
extensible predicate summaryModel( | ||
string namespace, string type, boolean subtypes, string name, string signature, string ext, | ||
string input, string output, string kind, string provenance | ||
); | ||
|
||
/** Holds if a neutral model exists for the given parameters. */ | ||
predicate neutralModel = Extensions::neutralModel/6; | ||
/** | ||
* Holds if a neutral model exists for the given parameters. | ||
*/ | ||
extensible predicate neutralModel( | ||
string namespace, string type, string name, string signature, string kind, string provenance | ||
); | ||
|
||
private predicate relevantNamespace(string namespace) { | ||
sourceModel(namespace, _, _, _, _, _, _, _, _) or | ||
|
@@ -310,10 +328,17 @@ class UnboundCallable extends Callable { | |
} | ||
} | ||
|
||
private predicate hasName(Declaration d, string name) { | ||
d.(Operator).getFunctionName() = name | ||
or | ||
not d instanceof Operator and | ||
d.hasName(name) | ||
} | ||
|
||
pragma[nomagic] | ||
private predicate callableSpecInfo(Callable c, string namespace, string type, string name) { | ||
c.getDeclaringType().hasQualifiedName(namespace, type) and | ||
c.getName() = name | ||
hasName(c, name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙀 So was it the case, that even though the models existed they were not applied correctly to the operator? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
} | ||
|
||
pragma[nomagic] | ||
|
@@ -326,7 +351,7 @@ private predicate subtypeSpecCandidate(string name, UnboundValueOrRefType t) { | |
|
||
pragma[nomagic] | ||
private predicate callableInfo(Callable c, string name, UnboundValueOrRefType decl) { | ||
name = c.getName() and | ||
hasName(c, name) and | ||
decl = c.getDeclaringType() | ||
} | ||
|
||
|
@@ -387,7 +412,7 @@ private Element interpretElement0( | |
subtypes = true and result.(UnboundCallable).overridesOrImplementsUnbound(m) | ||
) and | ||
m.getDeclaringType() = t and | ||
m.hasName(name) | ||
hasName(m, name) | ||
| | ||
signature = "" | ||
or | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we keep this in the
ExternalFlowExtensions
file instead - to make sure this is streamlined with other languages (for java - the model related predicates inExternalFlow
are not just aliases)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means those predicates are exposed; do we really want/need that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe then move the entire ExternalFlowExtensions file as well (also for Java)?