diff --git a/jacodb-taint-configuration/src/main/kotlin/org/jacodb/configuration/TaintConfigurationItem.kt b/jacodb-taint-configuration/src/main/kotlin/org/jacodb/configuration/TaintConfigurationItem.kt index 474594a16..fedfe2fd4 100644 --- a/jacodb-taint-configuration/src/main/kotlin/org/jacodb/configuration/TaintConfigurationItem.kt +++ b/jacodb-taint-configuration/src/main/kotlin/org/jacodb/configuration/TaintConfigurationItem.kt @@ -33,22 +33,11 @@ data class TaintMethodSource( val actionsAfter: List, ) : TaintConfigurationItem -data class TaintFieldSource( - val fieldInfo: JcField, - val condition: Condition, - val actionsAfter: List, -) : TaintConfigurationItem - data class TaintMethodSink( val condition: Condition, val methodInfo: JcMethod, ) : TaintConfigurationItem -data class TaintFieldSink( - val condition: Condition, - val fieldInfo: JcField, -) : TaintConfigurationItem - data class TaintPassThrough( val methodInfo: JcMethod, val condition: Condition, diff --git a/jacodb-taint-configuration/src/test/kotlin/org/jacodb/configuration/ConfigurationTest.kt b/jacodb-taint-configuration/src/test/kotlin/org/jacodb/configuration/ConfigurationTest.kt index 9d4590a94..9d3cb3b42 100644 --- a/jacodb-taint-configuration/src/test/kotlin/org/jacodb/configuration/ConfigurationTest.kt +++ b/jacodb-taint-configuration/src/test/kotlin/org/jacodb/configuration/ConfigurationTest.kt @@ -18,6 +18,7 @@ package org.jacodb.configuration import kotlinx.coroutines.runBlocking import org.jacodb.api.JcClasspath +import org.jacodb.api.ext.constructors import org.jacodb.api.ext.findClass import org.jacodb.api.ext.methods import org.jacodb.api.ext.objectType @@ -98,4 +99,14 @@ class ConfigurationTest : BaseTest() { assertTrue(rules.singleOrNull() != null) } + + @Test + fun testParametersMatches() { + val method = cp.findClass().constructors.first { + it.parameters.singleOrNull()?.type?.typeName == java.lang.String::class.qualifiedName + } + val rules = taintFeature.getConfigForMethod(method) + + assertTrue(rules.singleOrNull() != null) + } } diff --git a/jacodb-taint-configuration/src/test/resources/testJsonConfig.json b/jacodb-taint-configuration/src/test/resources/testJsonConfig.json index 55a995049..02462a9dd 100644 --- a/jacodb-taint-configuration/src/test/resources/testJsonConfig.json +++ b/jacodb-taint-configuration/src/test/resources/testJsonConfig.json @@ -347,5 +347,63 @@ } } ] + }, + { + "_": "PassThrough", + "methodInfo": { + "cls": { + "packageMatcher": { + "_": "NameIsEqualTo", + "name": "java.util" + }, + "classNameMatcher": { + "_": "NameIsEqualTo", + "name": "Scanner" + } + }, + "functionName": { + "_": "NameIsEqualTo", + "name": "init^" + }, + "parametersMatchers": [ + { + "index": 0, + "typeMatcher": { + "_": "ClassMatcher", + "packageMatcher": { + "_": "NameIsEqualTo", + "name": "java.lang" + }, + "classNameMatcher": { + "_": "NameIsEqualTo", + "name": "String" + } + } + } + ], + "returnTypeMatcher": { + "_": "AnyTypeMatches" + }, + "applyToOverrides": true, + "functionLabel": null, + "modifier": -1, + "exclude": [ + ] + }, + "condition": { + "_": "ConstantTrue" + }, + "actionsAfter": [ + { + "_": "CopyAllMarks", + "from": { + "_": "Argument", + "number": 0 + }, + "to": { + "_": "This" + } + } + ] } ] \ No newline at end of file