Skip to content

Commit eccc932

Browse files
committed
introducing isDependentTaint()
1 parent 20c1049 commit eccc932

4 files changed

Lines changed: 22 additions & 14 deletions

File tree

core/src/main/kotlin/org/evomaster/core/search/Individual.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ abstract class Individual(
510510

511511
val taintableGenes = all.filterIsInstance<TaintableGene>()
512512
.filter { TaintInputName.isTaintInput(it.getPossiblyTaintedValue()) }
513+
.filter { !it.isDependentTaint() }
513514

514515
val duplicates = CollectionUtils.duplicates(taintableGenes.map { it.getPossiblyTaintedValue() })
515516

@@ -523,9 +524,7 @@ abstract class Individual(
523524
val same = taintableGenes.filter { it.getPossiblyTaintedValue() == d.key }.map { it as Gene }
524525
if(same.any{ x ->
525526
same.any { y ->
526-
y !=x
527-
&& !y.hasAnyBindingRelationship(x)
528-
&& !y.areAncestorDescendantRelated(x)
527+
y !=x && !y.hasAnyBindingRelationship(x)
529528
}
530529
}){
531530
errors.add("Taint id ${d.key} has duplicate genes that are not related}")

core/src/main/kotlin/org/evomaster/core/search/gene/interfaces/TaintableGene.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ interface TaintableGene {
2121
*/
2222
fun forceNewTaintId()
2323

24+
/**
25+
* Specify that this taint value is bound to another tainted value
26+
*/
27+
fun isDependentTaint() = false
28+
2429
/**
2530
* If the individual has any dormant gene, do evolve, ie., resolve the taint
2631
*/
2732
fun evolve()
28-
}
33+
}

core/src/main/kotlin/org/evomaster/core/search/gene/string/StringGene.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.evomaster.client.java.instrumentation.shared.RegexSharedUtils
55
import org.evomaster.client.java.instrumentation.shared.StringSpecialization
66
import org.evomaster.client.java.instrumentation.shared.StringSpecializationInfo
77
import org.evomaster.client.java.instrumentation.shared.TaintInputName
8+
import org.evomaster.client.java.instrumentation.shared.TaintInputName.TAINTED_MAP_EM_LABEL_IDENTIFIER
89
import org.evomaster.core.EMConfig
910
import org.evomaster.core.Lazy
1011
import org.evomaster.core.StaticCounter
@@ -1065,12 +1066,18 @@ class StringGene(
10651066
}
10661067

10671068
override fun forceNewTaintId() {
1068-
if(TaintInputName.isTaintInput(value) && verifyIfNewTaintWouldBeFine()){
1069+
if(!isDependentTaint()
1070+
&& TaintInputName.isTaintInput(value)
1071+
&& verifyIfNewTaintWouldBeFine()){
10691072
forceTaintedValue()
10701073
//note: selectedSpecialization is NOT modified here
10711074
}
10721075
}
10731076

1077+
override fun isDependentTaint(): Boolean{
1078+
return name == TAINTED_MAP_EM_LABEL_IDENTIFIER
1079+
}
1080+
10741081
override fun evolve() {
10751082
//TODO need refactoring
10761083
}

core/src/main/kotlin/org/evomaster/core/taint/TaintAnalysis.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,10 @@ object TaintAnalysis {
464464
*/
465465
//assert(false) // crash in tests, but not production
466466
} else {
467-
if (genes.size > 1
467+
val toModify = genes.filter { !it.isDependentTaint() }
468+
if (toModify.size > 1
468469
&& TaintInputName.isTaintInput(taintedInput)
469-
&& genes.none { x -> genes.any { y ->
470-
y.hasAnyBindingRelationship(x)
471-
|| y.areAncestorDescendantRelated(x)
472-
}
473-
}
470+
&& toModify.none { x -> toModify.any { y -> y.hasAnyBindingRelationship(x) } }
474471
) {
475472
//shouldn't really be a problem... but let keep track for it, for now at least.
476473
// note, cannot really guarantee that a taint from regex is unique, as regex could generate
@@ -479,9 +476,9 @@ object TaintAnalysis {
479476
log.warn("More than 2 genes have the taint '{}'", taintedInput)
480477
assert(false)
481478
}
482-
genes
483-
.filter { it.name != TaintInputName.TAINTED_MAP_EM_LABEL_IDENTIFIER /* should never be modified */ }
484-
.forEach { it.addSpecializations(taintedInput, specializations, randomness, enableConstraintHandling = enableConstraintHandling) }
479+
toModify.forEach {
480+
it.addSpecializations(taintedInput, specializations, randomness, enableConstraintHandling = enableConstraintHandling)
481+
}
485482
}
486483
}
487484
}

0 commit comments

Comments
 (0)