Skip to content

Commit

Permalink
Merge pull request #16477 from michaelnebel/csharp/madinlinetest
Browse files Browse the repository at this point in the history
C#: Inline expectation for model generator test.
  • Loading branch information
michaelnebel authored May 22, 2024
2 parents 855fe12 + e198d01 commit 84e412f
Show file tree
Hide file tree
Showing 25 changed files with 644 additions and 491 deletions.
18 changes: 18 additions & 0 deletions csharp/ql/test/TestUtilities/InlineMadTest.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
private import csharp as Cs
private import codeql.mad.test.InlineMadTest

private module InlineMadTestLang implements InlineMadTestLangSig {
class Callable = Cs::Callable;

string getComment(Callable c) {
exists(Cs::CommentBlock block, Cs::Element after | after = block.getAfter() |
(
after = c or
after = c.(Cs::Accessor).getDeclaration()
) and
result = block.getALine()
)
}
}

import InlineMadTestImpl<InlineMadTestLang>
Original file line number Diff line number Diff line change
@@ -1,24 +1,2 @@
| NoSummaries;BaseClass;M1;(System.String);summary;df-generated |
| NoSummaries;BaseClass;M2;(System.String);summary;df-generated |
| NoSummaries;CollectionFlow;ReturnSimpleTypeArray;(System.Int32[]);summary;df-generated |
| NoSummaries;CollectionFlow;ReturnSimpleTypeDictionary;(System.Collections.Generic.Dictionary<System.Int32,System.Int32>);summary;df-generated |
| NoSummaries;CollectionFlow;ReturnSimpleTypeList;(System.Collections.Generic.List<System.Int32>);summary;df-generated |
| NoSummaries;EquatableBound;Equals;(System.Object);summary;df-generated |
| NoSummaries;EquatableUnBound<T>;Equals;(T);summary;df-generated |
| NoSummaries;SimpleTypes;M1;(System.Boolean);summary;df-generated |
| NoSummaries;SimpleTypes;M2;(System.Boolean);summary;df-generated |
| NoSummaries;SimpleTypes;M3;(System.Int32);summary;df-generated |
| NoSummaries;SimpleTypes;M4;(System.Int32);summary;df-generated |
| Sinks;NewSinks;WrapFieldResponseWriteFile;();summary;df-generated |
| Sinks;NewSinks;WrapPrivateFieldResponseWriteFile;();summary;df-generated |
| Sinks;NewSinks;WrapPrivatePropResponseWriteFile;();summary;df-generated |
| Sinks;NewSinks;WrapPropPrivateSetResponseWriteFile;();summary;df-generated |
| Sinks;NewSinks;WrapPropResponseWriteFile;();summary;df-generated |
| Sinks;NewSinks;WrapResponseWrite;(System.Object);summary;df-generated |
| Sinks;NewSinks;WrapResponseWriteFile;(System.String);summary;df-generated |
| Sources;NewSources;WrapConsoleReadKey;();summary;df-generated |
| Sources;NewSources;WrapConsoleReadLine;();summary;df-generated |
| Sources;NewSources;WrapConsoleReadLineAndProcees;(System.String);summary;df-generated |
| Summaries;EqualsGetHashCodeNoFlow;Equals;(System.Object);summary;df-generated |
| Summaries;EqualsGetHashCodeNoFlow;GetHashCode;();summary;df-generated |
| Summaries;OperatorFlow;op_Increment;(Summaries.OperatorFlow);summary;df-generated |
unexpectedModel
expectedModel
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ extensions:
pack: codeql/csharp-all
extensible: neutralModel
data:
- [ "NoSummaries", "ManuallyModelled", "HasNeutralSummaryNoFlow", "(System.Object)", "summary", "manual"]
- [ "Models", "ManuallyModelled", "HasNeutralSummaryNoFlow", "(System.Object)", "summary", "manual"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import csharp
import utils.modelgenerator.internal.CaptureSummaryFlowQuery
import TestUtilities.InlineMadTest

module InlineMadTestConfig implements InlineMadTestConfigSig {
string getCapturedModel(Callable c) { result = captureNoFlow(c) }

string getKind() { result = "neutral" }
}

import InlineMadTest<InlineMadTestConfig>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
| Sinks;NewSinks;false;WrapFieldResponseWriteFile;();;Argument[this];html-injection;df-generated |
| Sinks;NewSinks;false;WrapPropResponseWriteFile;();;Argument[this];html-injection;df-generated |
| Sinks;NewSinks;false;WrapResponseWrite;(System.Object);;Argument[0];html-injection;df-generated |
| Sinks;NewSinks;false;WrapResponseWriteFile;(System.String);;Argument[0];html-injection;df-generated |
unexpectedModel
expectedModel
11 changes: 11 additions & 0 deletions csharp/ql/test/utils/modelgenerator/dataflow/CaptureSinkModels.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import csharp
import utils.modelgenerator.internal.CaptureModels
import TestUtilities.InlineMadTest

module InlineMadTestConfig implements InlineMadTestConfigSig {
string getCapturedModel(Callable c) { result = captureSink(c) }

string getKind() { result = "sink" }
}

import InlineMadTest<InlineMadTestConfig>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
| Sources;NewSources;false;WrapConsoleReadKey;();;ReturnValue;local;df-generated |
| Sources;NewSources;false;WrapConsoleReadLine;();;ReturnValue;local;df-generated |
| Sources;NewSources;false;WrapConsoleReadLineAndProcees;(System.String);;ReturnValue;local;df-generated |
unexpectedModel
expectedModel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import csharp
import utils.modelgenerator.internal.CaptureModels
import TestUtilities.InlineMadTest

module InlineMadTestConfig implements InlineMadTestConfigSig {
string getCapturedModel(Callable c) { result = captureSource(c) }

string getKind() { result = "source" }
}

import InlineMadTest<InlineMadTestConfig>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,40 +1,2 @@
| NoSummaries;PublicClassFlow;false;PublicReturn;(System.Object);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;BaseClassFlow;true;ReturnParam;(System.Object);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;BasicFlow;false;ReturnField;();;Argument[this];ReturnValue;taint;df-generated |
| Summaries;BasicFlow;false;ReturnParam0;(System.String,System.Object);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;BasicFlow;false;ReturnParam1;(System.String,System.Object);;Argument[1];ReturnValue;taint;df-generated |
| Summaries;BasicFlow;false;ReturnParamMultiple;(System.Object,System.Object);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;BasicFlow;false;ReturnParamMultiple;(System.Object,System.Object);;Argument[1];ReturnValue;taint;df-generated |
| Summaries;BasicFlow;false;ReturnSubstring;(System.String);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;BasicFlow;false;ReturnThis;(System.Object);;Argument[this];ReturnValue;value;df-generated |
| Summaries;BasicFlow;false;SetField;(System.String);;Argument[0];Argument[this];taint;df-generated |
| Summaries;CollectionFlow;false;AddFieldToList;(System.Collections.Generic.List<System.String>);;Argument[this];Argument[0].Element;taint;df-generated |
| Summaries;CollectionFlow;false;AddToList;(System.Collections.Generic.List<System.Object>,System.Object);;Argument[1];Argument[0].Element;taint;df-generated |
| Summaries;CollectionFlow;false;AssignFieldToArray;(System.Object[]);;Argument[this];Argument[0].Element;taint;df-generated |
| Summaries;CollectionFlow;false;AssignToArray;(System.Object,System.Object[]);;Argument[0];Argument[1].Element;taint;df-generated |
| Summaries;CollectionFlow;false;ReturnArrayElement;(System.Object[]);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;CollectionFlow;false;ReturnBulkTypeList;(System.Collections.Generic.List<System.Byte>);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;CollectionFlow;false;ReturnComplexTypeArray;(System.String[]);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;CollectionFlow;false;ReturnComplexTypeDictionary;(System.Collections.Generic.Dictionary<System.Int32,System.String>);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;CollectionFlow;false;ReturnFieldInAList;();;Argument[this];ReturnValue;taint;df-generated |
| Summaries;CollectionFlow;false;ReturnListElement;(System.Collections.Generic.List<System.Object>);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;CollectionFlow;false;ReturnUntypedArray;(System.Array);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;CollectionFlow;false;ReturnUntypedList;(System.Collections.IList);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;DerivedClass1Flow;false;ReturnParam1;(System.String,System.String);;Argument[1];ReturnValue;taint;df-generated |
| Summaries;DerivedClass2Flow;false;ReturnParam0;(System.String,System.Int32);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;DerivedClass2Flow;false;ReturnParam;(System.Object);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;EqualsGetHashCodeNoFlow;false;Equals;(System.String);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;GenericFlow<T>;false;AddFieldToGenericList;(System.Collections.Generic.List<T>);;Argument[this];Argument[0].Element;taint;df-generated |
| Summaries;GenericFlow<T>;false;AddToGenericList<S>;(System.Collections.Generic.List<S>,S);;Argument[1];Argument[0].Element;taint;df-generated |
| Summaries;GenericFlow<T>;false;ReturnFieldInGenericList;();;Argument[this];ReturnValue;taint;df-generated |
| Summaries;GenericFlow<T>;false;ReturnGenericElement<S>;(System.Collections.Generic.List<S>);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;GenericFlow<T>;false;ReturnGenericField;();;Argument[this];ReturnValue;taint;df-generated |
| Summaries;GenericFlow<T>;false;ReturnGenericParam<S>;(S);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;GenericFlow<T>;false;SetGenericField;(T);;Argument[0];Argument[this];taint;df-generated |
| Summaries;IEnumerableFlow;false;ReturnFieldInIEnumerable;();;Argument[this];ReturnValue;taint;df-generated |
| Summaries;IEnumerableFlow;false;ReturnIEnumerable;(System.Collections.Generic.IEnumerable<System.String>);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;IEnumerableFlow;false;ReturnIEnumerableElement;(System.Collections.Generic.IEnumerable<System.Object>);;Argument[0].Element;ReturnValue;taint;df-generated |
| Summaries;OperatorFlow;false;OperatorFlow;(System.Object);;Argument[0];Argument[this];taint;df-generated |
| Summaries;OperatorFlow;false;op_Addition;(Summaries.OperatorFlow,Summaries.OperatorFlow);;Argument[0];ReturnValue;taint;df-generated |
| Summaries;Properties;false;get_Prop1;();;Argument[this];ReturnValue;taint;df-generated |
| Summaries;Properties;false;set_Prop2;(System.String);;Argument[0];Argument[this];taint;df-generated |
unexpectedModel
expectedModel
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ extensions:
pack: codeql/csharp-all
extensible: summaryModel
data:
- [ "NoSummaries", "ManuallyModelled", False, "HasSummary", "(System.Object)", "", "Argument[0]", "ReturnValue", "value", "manual"]
- [ "Models", "ManuallyModelled", False, "HasSummary", "(System.Object)", "", "Argument[0]", "ReturnValue", "value", "manual"]

- addsTo:
pack: codeql/csharp-all
extensible: neutralModel
data:
- [ "NoSummaries", "ManuallyModelled", "HasNeutralSummary", "(System.Object)", "summary", "manual"]
- [ "Models", "ManuallyModelled", "HasNeutralSummary", "(System.Object)", "summary", "manual"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import csharp
import utils.modelgenerator.internal.CaptureSummaryFlowQuery
import TestUtilities.InlineMadTest

module InlineMadTestConfig implements InlineMadTestConfigSig {
string getCapturedModel(Callable c) { result = captureFlow(c) }

string getKind() { result = "summary" }
}

import InlineMadTest<InlineMadTestConfig>

This file was deleted.

174 changes: 0 additions & 174 deletions csharp/ql/test/utils/modelgenerator/dataflow/NoSummaries.cs

This file was deleted.

Loading

0 comments on commit 84e412f

Please sign in to comment.