mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Move modules to the library packs.
This commit is contained in:
8
csharp/ql/lib/utils/test/InlineExpectationsTest.qll
Normal file
8
csharp/ql/lib/utils/test/InlineExpectationsTest.qll
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Inline expectation tests for C#.
|
||||
* See `shared/util/codeql/util/test/InlineExpectationsTest.qll`
|
||||
*/
|
||||
|
||||
private import codeql.util.test.InlineExpectationsTest
|
||||
private import internal.InlineExpectationsTestImpl
|
||||
import Make<Impl>
|
||||
41
csharp/ql/lib/utils/test/InlineFlowTest.qll
Normal file
41
csharp/ql/lib/utils/test/InlineFlowTest.qll
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Inline flow tests for CSharp.
|
||||
* See `shared/util/codeql/dataflow/test/InlineFlowTest.qll`
|
||||
*/
|
||||
|
||||
import csharp
|
||||
private import codeql.dataflow.test.InlineFlowTest
|
||||
private import semmle.code.csharp.dataflow.internal.DataFlowImplSpecific
|
||||
private import semmle.code.csharp.dataflow.internal.TaintTrackingImplSpecific
|
||||
private import semmle.code.csharp.dataflow.internal.ExternalFlow as ExternalFlow
|
||||
private import internal.InlineExpectationsTestImpl
|
||||
|
||||
private module FlowTestImpl implements InputSig<Location, CsharpDataFlow> {
|
||||
predicate defaultSource(DataFlow::Node source) {
|
||||
source.asExpr().(MethodCall).getTarget().getUndecoratedName() = ["Source", "Taint"]
|
||||
}
|
||||
|
||||
predicate defaultSink(DataFlow::Node sink) {
|
||||
exists(MethodCall mc | mc.getTarget().hasUndecoratedName("Sink") |
|
||||
sink.asExpr() = mc.getAnArgument()
|
||||
)
|
||||
}
|
||||
|
||||
private string getSourceArgString(DataFlow::Node src) {
|
||||
defaultSource(src) and
|
||||
src.asExpr().(MethodCall).getAnArgument().getValue() = result
|
||||
}
|
||||
|
||||
string getArgString(DataFlow::Node src, DataFlow::Node sink) {
|
||||
(
|
||||
result = getSourceArgString(src)
|
||||
or
|
||||
not exists(getSourceArgString(src)) and result = "line:" + src.getLocation().getStartLine()
|
||||
) and
|
||||
exists(sink)
|
||||
}
|
||||
|
||||
predicate interpretModelForTest = ExternalFlow::interpretModelForTest/2;
|
||||
}
|
||||
|
||||
import InlineFlowTestMake<Location, CsharpDataFlow, CsharpTaintTracking, Impl, FlowTestImpl>
|
||||
18
csharp/ql/lib/utils/test/InlineMadTest.qll
Normal file
18
csharp/ql/lib/utils/test/InlineMadTest.qll
Normal file
@@ -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>
|
||||
8
csharp/ql/lib/utils/test/ProvenancePathGraph.qll
Normal file
8
csharp/ql/lib/utils/test/ProvenancePathGraph.qll
Normal file
@@ -0,0 +1,8 @@
|
||||
private import codeql.dataflow.DataFlow as DF
|
||||
private import codeql.dataflow.test.ProvenancePathGraph as Graph
|
||||
private import semmle.code.csharp.dataflow.internal.ExternalFlow
|
||||
|
||||
/** Transforms a `PathGraph` by printing the provenance information. */
|
||||
module ShowProvenance<Graph::PathNodeSig PathNode, DF::PathGraphSig<PathNode> PathGraph> {
|
||||
import Graph::ShowProvenance<interpretModelForTest/2, PathNode, PathGraph>
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
private import csharp as CS
|
||||
private import codeql.util.test.InlineExpectationsTest
|
||||
|
||||
module Impl implements InlineExpectationsTestSig {
|
||||
/**
|
||||
* A class representing line comments in C# used by the InlineExpectations core code
|
||||
*/
|
||||
class ExpectationComment extends CS::SinglelineComment {
|
||||
/** Gets the contents of the given comment, _without_ the preceding comment marker (`//`). */
|
||||
string getContents() { result = this.getText() }
|
||||
}
|
||||
|
||||
class Location = CS::Location;
|
||||
}
|
||||
Reference in New Issue
Block a user