mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
C#: Implement ContentApprox
This commit is contained in:
@@ -904,6 +904,13 @@ private module Cached {
|
|||||||
TElementContent() or
|
TElementContent() or
|
||||||
TSyntheticFieldContent(SyntheticField f)
|
TSyntheticFieldContent(SyntheticField f)
|
||||||
|
|
||||||
|
cached
|
||||||
|
newtype TContentApprox =
|
||||||
|
TFieldApproxContent(string firstChar) { firstChar = approximateFieldContent(_) } or
|
||||||
|
TPropertyApproxContent(string firstChar) { firstChar = approximatePropertyContent(_) } or
|
||||||
|
TElementApproxContent() or
|
||||||
|
TSyntheticFieldApproxContent()
|
||||||
|
|
||||||
pragma[nomagic]
|
pragma[nomagic]
|
||||||
private predicate commonSubTypeGeneral(DataFlowTypeOrUnifiable t1, RelevantDataFlowType t2) {
|
private predicate commonSubTypeGeneral(DataFlowTypeOrUnifiable t1, RelevantDataFlowType t2) {
|
||||||
not t1 instanceof Gvn::TypeParameterGvnType and
|
not t1 instanceof Gvn::TypeParameterGvnType and
|
||||||
@@ -2246,6 +2253,46 @@ predicate allowParameterReturnInSelf(ParameterNode p) {
|
|||||||
FlowSummaryImpl::Private::summaryAllowParameterReturnInSelf(p)
|
FlowSummaryImpl::Private::summaryAllowParameterReturnInSelf(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** An approximated `Content`. */
|
||||||
|
class ContentApprox extends TContentApprox {
|
||||||
|
/** Gets a textual representation of this approximated `Content`. */
|
||||||
|
string toString() {
|
||||||
|
exists(string firstChar |
|
||||||
|
this = TFieldApproxContent(firstChar) and result = "approximated field " + firstChar
|
||||||
|
)
|
||||||
|
or
|
||||||
|
exists(string firstChar |
|
||||||
|
this = TPropertyApproxContent(firstChar) and result = "approximated property " + firstChar
|
||||||
|
)
|
||||||
|
or
|
||||||
|
this = TElementApproxContent() and result = "element"
|
||||||
|
or
|
||||||
|
this = TSyntheticFieldApproxContent() and result = "approximated synthetic field"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets a string for approximating the name of a field. */
|
||||||
|
private string approximateFieldContent(FieldContent fc) {
|
||||||
|
result = fc.getField().getName().prefix(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets a string for approximating the name of a property. */
|
||||||
|
private string approximatePropertyContent(PropertyContent pc) {
|
||||||
|
result = pc.getProperty().getName().prefix(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets an approximated value for content `c`. */
|
||||||
|
pragma[nomagic]
|
||||||
|
ContentApprox getContentApprox(Content c) {
|
||||||
|
result = TFieldApproxContent(approximateFieldContent(c))
|
||||||
|
or
|
||||||
|
result = TPropertyApproxContent(approximatePropertyContent(c))
|
||||||
|
or
|
||||||
|
c instanceof ElementContent and result = TElementApproxContent()
|
||||||
|
or
|
||||||
|
c instanceof SyntheticFieldContent and result = TSyntheticFieldApproxContent()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A module importing the modules that provide synthetic field declarations,
|
* A module importing the modules that provide synthetic field declarations,
|
||||||
* ensuring that they are visible to the taint tracking / data flow library.
|
* ensuring that they are visible to the taint tracking / data flow library.
|
||||||
|
|||||||
Reference in New Issue
Block a user