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

C#: Default subtypes to true. #18060

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
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
*/

import csharp
import ExternalFlowExtensions
private import ExternalFlowExtensions as ExternalFlowExtensions
private import DataFlowDispatch
private import DataFlowPrivate
private import DataFlowPublic
Expand All @@ -102,6 +102,35 @@ private import semmle.code.csharp.frameworks.System
private import codeql.dataflow.internal.AccessPathSyntax as AccessPathSyntax
private import codeql.mad.ModelValidation as SharedModelVal

private predicate sourceModel(
string namespace, string type, boolean subtypes, string name, string signature, string ext,
string output, string kind, string provenance, QlBuiltins::ExtensionId madId
) {
subtypes = true and
ExternalFlowExtensions::sourceModel(namespace, type, _, name, signature, ext, output, kind,
provenance, madId)
}

private predicate sinkModel(
string namespace, string type, boolean subtypes, string name, string signature, string ext,
string input, string kind, string provenance, QlBuiltins::ExtensionId madId
) {
subtypes = true and
ExternalFlowExtensions::sinkModel(namespace, type, _, name, signature, ext, input, kind,
provenance, madId)
}

private predicate summaryModel(
string namespace, string type, boolean subtypes, string name, string signature, string ext,
string input, string output, string kind, string provenance, QlBuiltins::ExtensionId madId
) {
subtypes = true and
ExternalFlowExtensions::summaryModel(namespace, type, _, name, signature, ext, input, output,
kind, provenance, madId)
}

private predicate neutralModel = ExternalFlowExtensions::neutralModel/6;

/**
* Holds if the given extension tuple `madId` should pretty-print as `model`.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ private import DataFlowImplSpecific as DataFlowImplSpecific
private import DataFlowImplSpecific::Private
private import DataFlowImplSpecific::Public
private import semmle.code.csharp.Unification
private import semmle.code.csharp.dataflow.internal.ExternalFlowExtensions as ExternalFlowExtensions
private import semmle.code.csharp.dataflow.internal.ExternalFlow

module Input implements InputSig<Location, DataFlowImplSpecific::CsharpDataFlow> {
Expand Down Expand Up @@ -198,7 +199,8 @@ module SourceSinkInterpretationInput implements
string namespace, string type, boolean subtypes, string name, string signature, string ext,
QlBuiltins::ExtensionId madId
|
sourceModel(namespace, type, subtypes, name, signature, ext, output, kind, provenance, madId) and
ExternalFlowExtensions::sourceModel(namespace, type, _, name, signature, ext, output, kind,
provenance, madId) and
model = "MaD:" + madId.toString() and
e = interpretElement(namespace, type, subtypes, name, signature, ext)
)
Expand All @@ -211,7 +213,8 @@ module SourceSinkInterpretationInput implements
string namespace, string type, boolean subtypes, string name, string signature, string ext,
QlBuiltins::ExtensionId madId
|
sinkModel(namespace, type, subtypes, name, signature, ext, input, kind, provenance, madId) and
ExternalFlowExtensions::sinkModel(namespace, type, _, name, signature, ext, input, kind,
provenance, madId) and
model = "MaD:" + madId.toString() and
e = interpretElement(namespace, type, subtypes, name, signature, ext)
)
Expand Down
1 change: 1 addition & 0 deletions csharp/ql/src/utils/modelconverter/InterpretModel.qll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import csharp
import semmle.code.csharp.dataflow.internal.ExternalFlowExtensions
import semmle.code.csharp.dataflow.internal.ExternalFlow

bindingset[namespace0, type0, name0, signature0]
Expand Down
Loading