Skip to content

Commit 9dc19bd

Browse files
committed
forcing new taint on copy from
1 parent ebf2306 commit 9dc19bd

6 files changed

Lines changed: 18 additions & 9 deletions

File tree

core/src/main/kotlin/org/evomaster/core/problem/externalservice/httpws/service/HarvestActualHttpWsResponseHandler.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,11 @@ class HarvestActualHttpWsResponseHandler {
532532
try {
533533
val template = getACopyOfItsActualResponseIfExist(geneToMutate, probability)?.responseBody ?: return false
534534

535-
val v = ParamUtil.getValueGene(geneToMutate)
536-
val t = ParamUtil.getValueGene(template)
535+
val v = geneToMutate.getLeafGene()
536+
val t = template.getLeafGene()
537537
if (v::class.java == t::class.java) {
538538
v.copyValueFrom(t)
539+
v.forceNewTaints()
539540
return true
540541
} else if (v is StringGene) {
541542
// add template as part of specialization

core/src/main/kotlin/org/evomaster/core/problem/rest/data/RestCallAction.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ class RestCallAction(
191191
For example, they could be a ChoiceGene when dealing with "examples" or Regex when having patterns
192192
only defined on some endpoints
193193
*/
194-
parameters[i].primaryGene().copyValueFrom(k.primaryGene())
194+
val g = parameters[i].primaryGene()
195+
g.copyValueFrom(k.primaryGene())
196+
g.forceNewTaints()
195197
}
196198
}
197199
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ abstract class Individual(
527527
y !=x && !y.hasAnyBindingRelationship(x)
528528
}
529529
}){
530-
errors.add("Taint id ${d.key} has duplicate genes that are not related}")
530+
errors.add("Taint id ${d.key} has duplicate genes that are not related")
531531
}
532532
}
533533
return errors

core/src/main/kotlin/org/evomaster/core/search/action/Action.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ abstract class Action(children: List<StructuralElement>) : ActionComponent(
7979

8080
fun forceNewTaints(){
8181
seeTopGenes().forEach { g ->
82-
g.flatView().forEach { r ->
83-
if(r is TaintableGene && !r.isDependentTaint()){
84-
r.forceNewTaintId()
85-
}
86-
}
82+
g.forceNewTaints()
8783
}
8884
}
8985

core/src/main/kotlin/org/evomaster/core/search/gene/Gene.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.evomaster.core.Lazy
1515
import org.evomaster.core.problem.enterprise.EnterpriseIndividual
1616
import org.evomaster.core.problem.enterprise.SampleType
1717
import org.evomaster.core.search.RootElement
18+
import org.evomaster.core.search.gene.interfaces.TaintableGene
1819
import org.evomaster.core.search.gene.utils.GeneUtils
1920
import org.evomaster.core.search.gene.interfaces.WrapperGene
2021
import org.evomaster.core.search.service.SearchGlobalState
@@ -1133,6 +1134,14 @@ abstract class Gene(
11331134
abstract fun unsafeCopyValueFrom(other: Gene): Boolean
11341135

11351136

1137+
fun forceNewTaints(){
1138+
flatView().forEach { r ->
1139+
if(r is TaintableGene && !r.isDependentTaint()){
1140+
r.forceNewTaintId()
1141+
}
1142+
}
1143+
}
1144+
11361145
/**
11371146
* Update current value of this gene, base on [other] gene.
11381147
* If for any reason the update fails, there is not going to be any side-effects.

core/src/main/kotlin/org/evomaster/core/search/gene/wrapper/ChoiceGene.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ class ChoiceGene<T>(
209209
options even if not selected
210210
*/
211211
val updated = g.copyValueFrom(x)
212+
g.forceNewTaints()
212213
if(updated){
213214
this.activeGeneIndex = i
214215
return true

0 commit comments

Comments
 (0)