Move modules to the library packs.

This commit is contained in:
Michael Nebel
2024-12-12 09:54:10 +01:00
parent 864c34fc03
commit 941b0abbf6
53 changed files with 9 additions and 9 deletions

View 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>

View 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>

View 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>

View 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>
}

View File

@@ -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;
}