| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff 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> | ||
| Original file line number | Diff line number | Diff 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> | ||
| Original file line number | Diff line number | Diff 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 | + } | ||
| Original file line number | Diff line number | Diff 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> | ||
| Original file line number | Diff line number | Diff 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> | ||
| Original file line number | Diff line number | Diff 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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments