File tree Expand file tree Collapse file tree 3 files changed +29
-24
lines changed
csharp/ql/lib/semmle/code/csharp Expand file tree Collapse file tree 3 files changed +29
-24
lines changed Original file line number Diff line number Diff line change @@ -132,27 +132,3 @@ private module FrameworkDataFlowAdaptor {
132
132
override predicate required ( SummaryComponent c ) { c = head }
133
133
}
134
134
}
135
-
136
- /** Data flow for `System.Text.StringBuilder`. */
137
- class SystemTextStringBuilderFlow extends LibraryTypeDataFlow , SystemTextStringBuilderClass {
138
- override predicate clearsContent (
139
- CallableFlowSource source , Content content , SourceDeclarationCallable callable
140
- ) {
141
- source = TCallableFlowSourceQualifier ( ) and
142
- callable = this .getAMethod ( "Clear" ) and
143
- content instanceof ElementContent
144
- }
145
- }
146
-
147
- /** Data flow for `System.Collections.IEnumerable` (and sub types). */
148
- class IEnumerableFlow extends LibraryTypeDataFlow , RefType {
149
- IEnumerableFlow ( ) { this .getABaseType * ( ) instanceof SystemCollectionsIEnumerableInterface }
150
-
151
- override predicate clearsContent (
152
- CallableFlowSource source , Content content , SourceDeclarationCallable callable
153
- ) {
154
- source = TCallableFlowSourceQualifier ( ) and
155
- callable = this .getAMethod ( "Clear" ) and
156
- content instanceof ElementContent
157
- }
158
- }
Original file line number Diff line number Diff line change 3
3
import csharp
4
4
private import semmle.code.csharp.frameworks.System
5
5
private import semmle.code.csharp.dataflow.ExternalFlow
6
+ private import semmle.code.csharp.dataflow.FlowSummary
6
7
7
8
/** The `System.Collections` namespace. */
8
9
class SystemCollectionsNamespace extends Namespace {
@@ -45,6 +46,20 @@ private class SystemCollectionIEnumerableFlowModelCsv extends SummaryModelCsv {
45
46
}
46
47
}
47
48
49
+ /** Clear content for Clear methods in all subtypes of `System.Collections.IEnumerable`. */
50
+ private class SystemCollectionsIEnumerableClearFlow extends SummarizedCallable {
51
+ SystemCollectionsIEnumerableClearFlow ( ) {
52
+ this .getDeclaringType ( ) .( RefType ) .getABaseType * ( ) instanceof
53
+ SystemCollectionsIEnumerableInterface and
54
+ this .hasName ( "Clear" )
55
+ }
56
+
57
+ override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
58
+ pos .getPosition ( ) = - 1 and
59
+ content instanceof DataFlow:: ElementContent
60
+ }
61
+ }
62
+
48
63
/** The `System.Collections.IEnumerator` interface. */
49
64
class SystemCollectionsIEnumeratorInterface extends SystemCollectionsInterface {
50
65
SystemCollectionsIEnumeratorInterface ( ) { this .hasName ( "IEnumerator" ) }
Original file line number Diff line number Diff line change 3
3
import csharp
4
4
private import semmle.code.csharp.frameworks.System
5
5
private import semmle.code.csharp.dataflow.ExternalFlow
6
+ private import semmle.code.csharp.dataflow.FlowSummary
6
7
7
8
/** The `System.Text` namespace. */
8
9
class SystemTextNamespace extends Namespace {
@@ -25,6 +26,19 @@ class SystemTextStringBuilderClass extends SystemTextClass {
25
26
Method getAppendFormatMethod ( ) { result = this .getAMethod ( "AppendFormat" ) }
26
27
}
27
28
29
+ /** Clear content for `System.Text.StringBuilder.Clear`. */
30
+ private class SystemTextStringBuilderClearFlow extends SummarizedCallable {
31
+ SystemTextStringBuilderClearFlow ( ) {
32
+ this .getDeclaringType ( ) instanceof SystemTextStringBuilderClass and
33
+ this .hasName ( "Clear" )
34
+ }
35
+
36
+ override predicate clearsContent ( ParameterPosition pos , DataFlow:: Content content ) {
37
+ pos .getPosition ( ) = - 1 and
38
+ content instanceof DataFlow:: ElementContent
39
+ }
40
+ }
41
+
28
42
/** Data flow for `System.Text.StringBuilder`. */
29
43
private class SystemTextStringBuilderFlowModelCsv extends SummaryModelCsv {
30
44
override predicate row ( string row ) {
You can’t perform that action at this time.
0 commit comments