Skip to content

Commit 20c1049

Browse files
committed
working on nested taint ids issue
1 parent d49eef6 commit 20c1049

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,14 @@ abstract class Individual(
521521

522522
duplicates.entries.forEach { d ->
523523
val same = taintableGenes.filter { it.getPossiblyTaintedValue() == d.key }.map { it as Gene }
524-
if(same.any{ x -> same.any { y -> y !=x && !y.hasAnyBindingRelationship(x)}}){
525-
errors.add("Taint id ${d.key} has duplicate genes that are not bound}")
524+
if(same.any{ x ->
525+
same.any { y ->
526+
y !=x
527+
&& !y.hasAnyBindingRelationship(x)
528+
&& !y.areAncestorDescendantRelated(x)
529+
}
530+
}){
531+
errors.add("Taint id ${d.key} has duplicate genes that are not related}")
526532
}
527533
}
528534
return errors

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,4 +475,21 @@ abstract class StructuralElement (
475475
fun <T:StructuralElement> getFirstParent(klass: Class<T>) : T? {
476476
return getFirstParent { klass.isAssignableFrom(it.javaClass) } as T?
477477
}
478+
479+
/**
480+
* Check if there is any ancestor-descendant relationship between
481+
* [this] and [other], or vice-versa
482+
*/
483+
fun areAncestorDescendantRelated(other: StructuralElement) : Boolean{
484+
if(this == other){
485+
return false
486+
}
487+
if(this.existAnyParent { it == other }){
488+
return true
489+
}
490+
if(other.existAnyParent { it == this }){
491+
return true
492+
}
493+
return false
494+
}
478495
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,11 @@ object TaintAnalysis {
466466
} else {
467467
if (genes.size > 1
468468
&& TaintInputName.isTaintInput(taintedInput)
469-
&& genes.none { x -> genes.any { y -> y.hasAnyBindingRelationship(x) } }
469+
&& genes.none { x -> genes.any { y ->
470+
y.hasAnyBindingRelationship(x)
471+
|| y.areAncestorDescendantRelated(x)
472+
}
473+
}
470474
) {
471475
//shouldn't really be a problem... but let keep track for it, for now at least.
472476
// note, cannot really guarantee that a taint from regex is unique, as regex could generate
@@ -480,4 +484,4 @@ object TaintAnalysis {
480484
.forEach { it.addSpecializations(taintedInput, specializations, randomness, enableConstraintHandling = enableConstraintHandling) }
481485
}
482486
}
483-
}
487+
}

0 commit comments

Comments
 (0)