Skip to content

Commit b071cf5

Browse files
authored
Rename taint configuration classes (#1955)
1 parent 7230073 commit b071cf5

19 files changed

+354
-354
lines changed

utbot-framework-test/src/test/kotlin/org/utbot/taint/parser/TaintAnalysisConfigurationParserTest.kt

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test
66
import org.junit.jupiter.api.assertThrows
77
import org.utbot.taint.parser.constants.*
88
import org.utbot.taint.parser.model.*
9-
import org.utbot.taint.parser.yaml.ConfigurationParseError
9+
import org.utbot.taint.parser.yaml.TaintParseError
1010

1111
class TaintAnalysisConfigurationParserTest {
1212

@@ -27,7 +27,7 @@ class TaintAnalysisConfigurationParserTest {
2727
@Test
2828
fun `parse should throw exception on incorrect yaml`() {
2929
val incorrectYamlInput = yamlInput.replace(k_not, "net")
30-
assertThrows<ConfigurationParseError> {
30+
assertThrows<TaintParseError> {
3131
TaintAnalysisConfigurationParser.parse(incorrectYamlInput)
3232
}
3333
}
@@ -72,50 +72,50 @@ class TaintAnalysisConfigurationParserTest {
7272
$k_marks: environment
7373
""".trimIndent()
7474

75-
private val expectedConfiguration = Configuration(
75+
private val expectedConfiguration = DtoTaintConfiguration(
7676
sources = listOf(
77-
Source(
78-
methodFqn = MethodFqn(listOf("java", "lang"), "System", "getenv"),
79-
addTo = TaintEntitiesSet(setOf(ReturnValue)),
80-
marks = TaintMarksSet(setOf(TaintMark("environment"))),
81-
signature = SignatureList(listOf(ArgumentTypeString("java.lang.String"))),
82-
conditions = NoConditions
77+
DtoTaintSource(
78+
methodFqn = DtoMethodFqn(listOf("java", "lang"), "System", "getenv"),
79+
addTo = DtoTaintEntitiesSet(setOf(DtoTaintEntityReturn)),
80+
marks = DtoTaintMarksSet(setOf(DtoTaintMark("environment"))),
81+
signature = DtoTaintSignatureList(listOf(DtoArgumentTypeString("java.lang.String"))),
82+
conditions = DtoNoTaintConditions
8383
)
8484
),
8585
passes = listOf(
86-
Pass(
87-
methodFqn = MethodFqn(listOf("java", "lang"), "String", "concat"),
88-
getFrom = TaintEntitiesSet(setOf(ThisObject)),
89-
addTo = TaintEntitiesSet(setOf(ReturnValue)),
90-
marks = TaintMarksSet(setOf(TaintMark("sensitive-data"))),
91-
signature = AnySignature,
92-
conditions = ConditionsMap(mapOf(ThisObject to NotCondition(ValueCondition(ArgumentValueString("")))))
86+
DtoTaintPass(
87+
methodFqn = DtoMethodFqn(listOf("java", "lang"), "String", "concat"),
88+
getFrom = DtoTaintEntitiesSet(setOf(DtoTaintEntityThis)),
89+
addTo = DtoTaintEntitiesSet(setOf(DtoTaintEntityReturn)),
90+
marks = DtoTaintMarksSet(setOf(DtoTaintMark("sensitive-data"))),
91+
signature = DtoTaintSignatureAny,
92+
conditions = DtoTaintConditionsMap(mapOf(DtoTaintEntityThis to DtoTaintConditionNot(DtoTaintConditionEqualValue(DtoArgumentValueString("")))))
9393
),
94-
Pass(
95-
methodFqn = MethodFqn(listOf("java", "lang"), "String", "concat"),
96-
getFrom = TaintEntitiesSet(setOf(MethodArgument(1u))),
97-
addTo = TaintEntitiesSet(setOf(ReturnValue)),
98-
marks = TaintMarksSet(setOf(TaintMark("sensitive-data"))),
99-
signature = AnySignature,
100-
conditions = ConditionsMap(mapOf(MethodArgument(1u) to NotCondition(ValueCondition(ArgumentValueString("")))))
94+
DtoTaintPass(
95+
methodFqn = DtoMethodFqn(listOf("java", "lang"), "String", "concat"),
96+
getFrom = DtoTaintEntitiesSet(setOf(DtoTaintEntityArgument(1u))),
97+
addTo = DtoTaintEntitiesSet(setOf(DtoTaintEntityReturn)),
98+
marks = DtoTaintMarksSet(setOf(DtoTaintMark("sensitive-data"))),
99+
signature = DtoTaintSignatureAny,
100+
conditions = DtoTaintConditionsMap(mapOf(DtoTaintEntityArgument(1u) to DtoTaintConditionNot(DtoTaintConditionEqualValue(DtoArgumentValueString("")))))
101101
)
102102
),
103103
cleaners = listOf(
104-
Cleaner(
105-
methodFqn = MethodFqn(listOf("java", "lang"), "String", "isEmpty"),
106-
removeFrom = TaintEntitiesSet(setOf(ThisObject)),
107-
marks = TaintMarksSet(setOf(TaintMark("sql-injection"), TaintMark("xss"))),
108-
signature = AnySignature,
109-
conditions = ConditionsMap(mapOf(ReturnValue to ValueCondition(ArgumentValueBoolean(true))))
104+
DtoTaintCleaner(
105+
methodFqn = DtoMethodFqn(listOf("java", "lang"), "String", "isEmpty"),
106+
removeFrom = DtoTaintEntitiesSet(setOf(DtoTaintEntityThis)),
107+
marks = DtoTaintMarksSet(setOf(DtoTaintMark("sql-injection"), DtoTaintMark("xss"))),
108+
signature = DtoTaintSignatureAny,
109+
conditions = DtoTaintConditionsMap(mapOf(DtoTaintEntityReturn to DtoTaintConditionEqualValue(DtoArgumentValueBoolean(true))))
110110
)
111111
),
112112
sinks = listOf(
113-
Sink(
114-
methodFqn = MethodFqn(listOf("org", "example"), "util", "unsafe"),
115-
check = TaintEntitiesSet(setOf(MethodArgument(2u))),
116-
marks = TaintMarksSet(setOf(TaintMark("environment"))),
117-
signature = SignatureList(argumentTypes = listOf(ArgumentTypeAny, ArgumentTypeString("java.lang.Integer"))),
118-
conditions = ConditionsMap(mapOf(MethodArgument(2u) to ValueCondition(ArgumentValueLong(0L))))
113+
DtoTaintSink(
114+
methodFqn = DtoMethodFqn(listOf("org", "example"), "util", "unsafe"),
115+
check = DtoTaintEntitiesSet(setOf(DtoTaintEntityArgument(2u))),
116+
marks = DtoTaintMarksSet(setOf(DtoTaintMark("environment"))),
117+
signature = DtoTaintSignatureList(argumentTypes = listOf(DtoArgumentTypeAny, DtoArgumentTypeString("java.lang.Integer"))),
118+
conditions = DtoTaintConditionsMap(mapOf(DtoTaintEntityArgument(2u) to DtoTaintConditionEqualValue(DtoArgumentValueLong(0L))))
119119
)
120120
)
121121
)

utbot-framework-test/src/test/kotlin/org/utbot/taint/parser/yaml/MethodArgumentParserTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class MethodArgumentParserTest {
7373
@Test
7474
fun `should parse underscore as ArgumentTypeAny`() {
7575
val yamlScalar = Yaml.default.parseToYamlNode(k__)
76-
val expectedArgumentType = ArgumentTypeAny
76+
val expectedArgumentType = DtoArgumentTypeAny
7777

7878
val actualArgumentType = MethodArgumentParser.parseArgumentType(yamlScalar)
7979
assertEquals(expectedArgumentType, actualArgumentType)
@@ -82,7 +82,7 @@ class MethodArgumentParserTest {
8282
@Test
8383
fun `should parse type fqn in brackets`() {
8484
val yamlScalar = Yaml.default.parseToYamlNode("${k_lt}double${k_gt}")
85-
val expectedArgumentType = ArgumentTypeString("double")
85+
val expectedArgumentType = DtoArgumentTypeString("double")
8686

8787
val actualArgumentType = MethodArgumentParser.parseArgumentType(yamlScalar)
8888
assertEquals(expectedArgumentType, actualArgumentType)
@@ -92,7 +92,7 @@ class MethodArgumentParserTest {
9292
fun `should fail on another yaml type`() {
9393
val yamlMap = Yaml.default.parseToYamlNode("type: ${k_lt}double${k_gt}")
9494

95-
assertThrows<ConfigurationParseError> {
95+
assertThrows<TaintParseError> {
9696
MethodArgumentParser.parseArgumentType(yamlMap)
9797
}
9898
}
@@ -104,7 +104,7 @@ class MethodArgumentParserTest {
104104
@Test
105105
fun `should parse yaml null as ArgumentValueNull`() {
106106
val yamlNull = Yaml.default.parseToYamlNode("null")
107-
val expectedArgumentValue = ArgumentValueNull
107+
val expectedArgumentValue = DtoArgumentValueNull
108108

109109
val actualArgumentValue = MethodArgumentParser.parseArgumentValue(yamlNull)
110110
assertEquals(expectedArgumentValue, actualArgumentValue)
@@ -113,7 +113,7 @@ class MethodArgumentParserTest {
113113
@Test
114114
fun `should parse boolean yaml scalar`() {
115115
val yamlScalar = Yaml.default.parseToYamlNode("false")
116-
val expectedArgumentValue = ArgumentValueBoolean(false)
116+
val expectedArgumentValue = DtoArgumentValueBoolean(false)
117117

118118
val actualArgumentValue = MethodArgumentParser.parseArgumentValue(yamlScalar)
119119
assertEquals(expectedArgumentValue, actualArgumentValue)
@@ -122,7 +122,7 @@ class MethodArgumentParserTest {
122122
@Test
123123
fun `should parse long yaml scalar`() {
124124
val yamlScalar = Yaml.default.parseToYamlNode("17")
125-
val expectedArgumentValue = ArgumentValueLong(17L)
125+
val expectedArgumentValue = DtoArgumentValueLong(17L)
126126

127127
val actualArgumentValue = MethodArgumentParser.parseArgumentValue(yamlScalar)
128128
assertEquals(expectedArgumentValue, actualArgumentValue)
@@ -131,7 +131,7 @@ class MethodArgumentParserTest {
131131
@Test
132132
fun `should parse double yaml scalar`() {
133133
val yamlScalar = Yaml.default.parseToYamlNode("1.2")
134-
val expectedArgumentValue = ArgumentValueDouble(1.2)
134+
val expectedArgumentValue = DtoArgumentValueDouble(1.2)
135135

136136
val actualArgumentValue = MethodArgumentParser.parseArgumentValue(yamlScalar)
137137
assertEquals(expectedArgumentValue, actualArgumentValue)
@@ -140,7 +140,7 @@ class MethodArgumentParserTest {
140140
@Test
141141
fun `should parse string yaml scalar`() {
142142
val yamlScalar = Yaml.default.parseToYamlNode("some-string")
143-
val expectedArgumentValue = ArgumentValueString("some-string")
143+
val expectedArgumentValue = DtoArgumentValueString("some-string")
144144

145145
val actualArgumentValue = MethodArgumentParser.parseArgumentValue(yamlScalar)
146146
assertEquals(expectedArgumentValue, actualArgumentValue)
@@ -150,7 +150,7 @@ class MethodArgumentParserTest {
150150
fun `should fail on another yaml type`() {
151151
val yamlList = Yaml.default.parseToYamlNode("[ some-string ]")
152152

153-
assertThrows<ConfigurationParseError> {
153+
assertThrows<TaintParseError> {
154154
MethodArgumentParser.parseArgumentValue(yamlList)
155155
}
156156
}

utbot-framework-test/src/test/kotlin/org/utbot/taint/parser/yaml/ConditionParserTest.kt renamed to utbot-framework-test/src/test/kotlin/org/utbot/taint/parser/yaml/TaintConditionParserTest.kt

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,97 +9,97 @@ import org.junit.jupiter.api.assertThrows
99
import org.utbot.taint.parser.constants.*
1010
import org.utbot.taint.parser.model.*
1111

12-
class ConditionParserTest {
12+
class TaintConditionParserTest {
1313

1414
@Nested
1515
@DisplayName("parseCondition")
1616
inner class ParseConditionTest {
1717
@Test
1818
fun `should parse yaml null as ValueCondition`() {
1919
val yamlNull = Yaml.default.parseToYamlNode("null")
20-
val expectedCondition = ValueCondition(ArgumentValueNull)
20+
val expectedCondition = DtoTaintConditionEqualValue(DtoArgumentValueNull)
2121

22-
val actualCondition = ConditionParser.parseCondition(yamlNull)
22+
val actualCondition = TaintConditionParser.parseCondition(yamlNull)
2323
assertEquals(expectedCondition, actualCondition)
2424
}
2525

2626
@Test
2727
fun `should parse yaml scalar with argument value as ValueCondition`() {
2828
val yamlScalar = Yaml.default.parseToYamlNode("some-string")
29-
val expectedCondition = ValueCondition(ArgumentValueString("some-string"))
29+
val expectedCondition = DtoTaintConditionEqualValue(DtoArgumentValueString("some-string"))
3030

31-
val actualCondition = ConditionParser.parseCondition(yamlScalar)
31+
val actualCondition = TaintConditionParser.parseCondition(yamlScalar)
3232
assertEquals(expectedCondition, actualCondition)
3333
}
3434

3535
@Test
3636
fun `should parse yaml scalar with argument type as TypeCondition`() {
3737
val yamlScalar = Yaml.default.parseToYamlNode("${k_lt}java.lang.Integer${k_gt}")
38-
val expectedCondition = TypeCondition(ArgumentTypeString("java.lang.Integer"))
38+
val expectedCondition = DtoTaintConditionIsType(DtoArgumentTypeString("java.lang.Integer"))
3939

40-
val actualCondition = ConditionParser.parseCondition(yamlScalar)
40+
val actualCondition = TaintConditionParser.parseCondition(yamlScalar)
4141
assertEquals(expectedCondition, actualCondition)
4242
}
4343

4444
@Test
4545
fun `should parse yaml list as OrCondition`() {
4646
val yamlList = Yaml.default.parseToYamlNode("[ 1, true, ${k_lt}java.lang.Integer${k_gt} ]")
47-
val expectedCondition = OrCondition(listOf(
48-
ValueCondition(ArgumentValueLong(1L)),
49-
ValueCondition(ArgumentValueBoolean(true)),
50-
TypeCondition(ArgumentTypeString("java.lang.Integer")),
47+
val expectedCondition = DtoTaintConditionOr(listOf(
48+
DtoTaintConditionEqualValue(DtoArgumentValueLong(1L)),
49+
DtoTaintConditionEqualValue(DtoArgumentValueBoolean(true)),
50+
DtoTaintConditionIsType(DtoArgumentTypeString("java.lang.Integer")),
5151
))
5252

53-
val actualCondition = ConditionParser.parseCondition(yamlList)
53+
val actualCondition = TaintConditionParser.parseCondition(yamlList)
5454
assertEquals(expectedCondition, actualCondition)
5555
}
5656

5757
@Test
5858
fun `should parse yaml map with a key 'not' as NotCondition`() {
5959
val yamlMap = Yaml.default.parseToYamlNode("$k_not: ${k_lt}int${k_gt}")
60-
val expectedCondition = NotCondition(TypeCondition(ArgumentTypeString("int")))
60+
val expectedCondition = DtoTaintConditionNot(DtoTaintConditionIsType(DtoArgumentTypeString("int")))
6161

62-
val actualCondition = ConditionParser.parseCondition(yamlMap)
62+
val actualCondition = TaintConditionParser.parseCondition(yamlMap)
6363
assertEquals(expectedCondition, actualCondition)
6464
}
6565

6666
@Test
6767
fun `should fail on yaml map without a key 'not'`() {
6868
val yamlMap = Yaml.default.parseToYamlNode("net: ${k_lt}int${k_gt}")
6969

70-
assertThrows<ConfigurationParseError> {
71-
ConditionParser.parseCondition(yamlMap)
70+
assertThrows<TaintParseError> {
71+
TaintConditionParser.parseCondition(yamlMap)
7272
}
7373
}
7474

7575
@Test
7676
fun `should fail on yaml map with unknown keys`() {
7777
val yamlMap = Yaml.default.parseToYamlNode("{ $k_not: ${k_lt}int${k_gt}, unknown-key: 0 }")
7878

79-
assertThrows<ConfigurationParseError> {
80-
ConditionParser.parseCondition(yamlMap)
79+
assertThrows<TaintParseError> {
80+
TaintConditionParser.parseCondition(yamlMap)
8181
}
8282
}
8383

8484
@Test
8585
fun `should parse complicated yaml node`() {
8686
val yamlMap = Yaml.default.parseToYamlNode("$k_not: [ { $k_not: 0 }, ${k_lt}int${k_gt}, { $k_not: null } ]")
87-
val expectedCondition = NotCondition(OrCondition(listOf(
88-
NotCondition(ValueCondition(ArgumentValueLong(0L))),
89-
TypeCondition(ArgumentTypeString("int")),
90-
NotCondition(ValueCondition(ArgumentValueNull))
87+
val expectedCondition = DtoTaintConditionNot(DtoTaintConditionOr(listOf(
88+
DtoTaintConditionNot(DtoTaintConditionEqualValue(DtoArgumentValueLong(0L))),
89+
DtoTaintConditionIsType(DtoArgumentTypeString("int")),
90+
DtoTaintConditionNot(DtoTaintConditionEqualValue(DtoArgumentValueNull))
9191
)))
9292

93-
val actualCondition = ConditionParser.parseCondition(yamlMap)
93+
val actualCondition = TaintConditionParser.parseCondition(yamlMap)
9494
assertEquals(expectedCondition, actualCondition)
9595
}
9696

9797
@Test
9898
fun `should fail on another yaml type`() {
9999
val yamlTaggedNode = YamlTaggedNode("some-tag", YamlNull(YamlPath.root))
100100

101-
assertThrows<ConfigurationParseError> {
102-
ConditionParser.parseCondition(yamlTaggedNode)
101+
assertThrows<TaintParseError> {
102+
TaintConditionParser.parseCondition(yamlTaggedNode)
103103
}
104104
}
105105
}
@@ -110,31 +110,31 @@ class ConditionParserTest {
110110
@Test
111111
fun `should parse correct yaml map as Conditions`() {
112112
val yamlMap = Yaml.default.parseToYamlNode("{ $k_this: \"\", ${k_arg}2: { $k_not: ${k_lt}int${k_gt} }, $k_return: [ 0, 1 ] }")
113-
val expectedConditions = ConditionsMap(mapOf(
114-
ThisObject to ValueCondition(ArgumentValueString("")),
115-
MethodArgument(2u) to NotCondition(TypeCondition(ArgumentTypeString("int"))),
116-
ReturnValue to OrCondition(listOf(ValueCondition(ArgumentValueLong(0L)), ValueCondition(ArgumentValueLong(1L))))
113+
val expectedConditions = DtoTaintConditionsMap(mapOf(
114+
DtoTaintEntityThis to DtoTaintConditionEqualValue(DtoArgumentValueString("")),
115+
DtoTaintEntityArgument(2u) to DtoTaintConditionNot(DtoTaintConditionIsType(DtoArgumentTypeString("int"))),
116+
DtoTaintEntityReturn to DtoTaintConditionOr(listOf(DtoTaintConditionEqualValue(DtoArgumentValueLong(0L)), DtoTaintConditionEqualValue(DtoArgumentValueLong(1L))))
117117
))
118118

119-
val actualConditions = ConditionParser.parseConditions(yamlMap)
119+
val actualConditions = TaintConditionParser.parseConditions(yamlMap)
120120
assertEquals(expectedConditions, actualConditions)
121121
}
122122

123123
@Test
124124
fun `should parse empty yaml map as NoConditions`() {
125125
val yamlMap = Yaml.default.parseToYamlNode("{}")
126-
val expectedConditions = NoConditions
126+
val expectedConditions = DtoNoTaintConditions
127127

128-
val actualConditions = ConditionParser.parseConditions(yamlMap)
128+
val actualConditions = TaintConditionParser.parseConditions(yamlMap)
129129
assertEquals(expectedConditions, actualConditions)
130130
}
131131

132132
@Test
133133
fun `should fail on another yaml type`() {
134134
val yamlList = Yaml.default.parseToYamlNode("[]")
135135

136-
assertThrows<ConfigurationParseError> {
137-
ConditionParser.parseConditions(yamlList)
136+
assertThrows<TaintParseError> {
137+
TaintConditionParser.parseConditions(yamlList)
138138
}
139139
}
140140
}
@@ -145,18 +145,18 @@ class ConditionParserTest {
145145
@Test
146146
fun `should parse yaml map with a key 'conditions'`() {
147147
val yamlMap = Yaml.default.parseToYamlNode("$k_conditions: { $k_return: null }").yamlMap
148-
val expectedConditions = ConditionsMap(mapOf(ReturnValue to ValueCondition(ArgumentValueNull)))
148+
val expectedConditions = DtoTaintConditionsMap(mapOf(DtoTaintEntityReturn to DtoTaintConditionEqualValue(DtoArgumentValueNull)))
149149

150-
val actualConditions = ConditionParser.parseConditionsKey(yamlMap)
150+
val actualConditions = TaintConditionParser.parseConditionsKey(yamlMap)
151151
assertEquals(expectedConditions, actualConditions)
152152
}
153153

154154
@Test
155155
fun `should parse yaml map without a key 'conditions' as NoConditions`() {
156156
val yamlMap = Yaml.default.parseToYamlNode("$k_marks: []").yamlMap
157-
val expectedConditions = NoConditions
157+
val expectedConditions = DtoNoTaintConditions
158158

159-
val actualConditions = ConditionParser.parseConditionsKey(yamlMap)
159+
val actualConditions = TaintConditionParser.parseConditionsKey(yamlMap)
160160
assertEquals(expectedConditions, actualConditions)
161161
}
162162
}

0 commit comments

Comments
 (0)