Skip to content

Commit 1f2d9dc

Browse files
authored
Merge pull request github#14862 from igfoo/igfoo/test-kotlin1
Kotlin: Move tests from test/kotlin to test-kotlin1
2 parents 979bcf4 + 45bbccc commit 1f2d9dc

File tree

633 files changed

+161
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

633 files changed

+161
-1
lines changed

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/swift/ @github/codeql-swift
99
/misc/codegen/ @github/codeql-swift
1010
/java/kotlin-extractor/ @github/codeql-kotlin
11-
/java/ql/test/kotlin/ @github/codeql-kotlin
11+
/java/ql/test-kotlin1/ @github/codeql-kotlin
1212
/java/ql/test-kotlin2/ @github/codeql-kotlin
1313

1414
# ML-powered queries
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Inline expectation tests for Java.
3+
* See `shared/util/codeql/util/test/InlineExpectationsTest.qll`
4+
*/
5+
6+
private import codeql.util.test.InlineExpectationsTest
7+
private import internal.InlineExpectationsTestImpl
8+
import Make<Impl>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Inline flow tests for Java.
3+
* See `shared/util/codeql/dataflow/test/InlineFlowTest.qll`
4+
*/
5+
6+
import java
7+
import semmle.code.java.dataflow.DataFlow
8+
private import codeql.dataflow.test.InlineFlowTest
9+
private import semmle.code.java.dataflow.internal.DataFlowImplSpecific
10+
private import semmle.code.java.dataflow.internal.TaintTrackingImplSpecific
11+
private import internal.InlineExpectationsTestImpl
12+
13+
private module FlowTestImpl implements InputSig<JavaDataFlow> {
14+
predicate defaultSource(DataFlow::Node source) {
15+
source.asExpr().(MethodCall).getMethod().getName() = ["source", "taint"]
16+
}
17+
18+
predicate defaultSink(DataFlow::Node sink) {
19+
exists(MethodCall ma | ma.getMethod().hasName("sink") | sink.asExpr() = ma.getAnArgument())
20+
}
21+
22+
private string getSourceArgString(DataFlow::Node src) {
23+
defaultSource(src) and
24+
src.asExpr().(MethodCall).getAnArgument().(StringLiteral).getValue() = result
25+
}
26+
27+
string getArgString(DataFlow::Node src, DataFlow::Node sink) {
28+
(if exists(getSourceArgString(src)) then result = getSourceArgString(src) else result = "") and
29+
exists(sink)
30+
}
31+
}
32+
33+
import InlineFlowTestMake<JavaDataFlow, JavaTaintTracking, Impl, FlowTestImpl>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
private import java as J
2+
private import codeql.util.test.InlineExpectationsTest
3+
4+
module Impl implements InlineExpectationsTestSig {
5+
/**
6+
* A class representing line comments in Java, which is simply Javadoc restricted
7+
* to EOL comments, with an extra accessor used by the InlineExpectations core code
8+
*/
9+
abstract class ExpectationComment extends J::Top {
10+
/** Gets the contents of the given comment, _without_ the preceding comment marker (`//`). */
11+
abstract string getContents();
12+
}
13+
14+
private class JavadocExpectationComment extends J::Javadoc, ExpectationComment {
15+
JavadocExpectationComment() { isEolComment(this) }
16+
17+
override string getContents() { result = this.getChild(0).toString() }
18+
}
19+
20+
private class KtExpectationComment extends J::KtComment, ExpectationComment {
21+
KtExpectationComment() { this.isEolComment() }
22+
23+
override string getContents() { result = this.getText().suffix(2).trim() }
24+
}
25+
26+
private class XmlExpectationComment extends ExpectationComment instanceof J::XmlComment {
27+
override string getContents() { result = super.getText().trim() }
28+
29+
override Location getLocation() { result = J::XmlComment.super.getLocation() }
30+
31+
override string toString() { result = J::XmlComment.super.toString() }
32+
}
33+
34+
class Location = J::Location;
35+
}

0 commit comments

Comments
 (0)