Skip to content

Commit

Permalink
working on supporting Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
arcuri82 committed Dec 11, 2024
1 parent e47637b commit ebec868
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 10 deletions.
38 changes: 32 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
FROM amazoncorretto:17-alpine-jdk
FROM amazoncorretto:21-alpine-jdk

COPY core/target/evomaster.jar .

#Keep --add-opens in sync with makeExecutable.sh
ENTRYPOINT [ \
"java", \
"-Xmx4G", \
"--add-opens", "java.base/java.net=ALL-UNNAMED", \
"-jar", "evomaster.jar", \
"-jar", "evomaster.jar" \
# see https://www.howtogeek.com/devops/how-to-connect-to-localhost-within-a-docker-container/
"--sutControllerHost", "host.docker.internal" \
]
#"--sutControllerHost", "host.docker.internal" \
]


###################
###### NOTES ######
###################
# Build
# docker build -t webfuzzing/evomaster .
#
# Run
# docker run webfuzzing/evomaster <options>
#
# Example remote BB
# docker run -v "/$(pwd)/generated_tests":/generated_tests webfuzzing/evomaster --blackBox true --bbSwaggerUrl https://api.apis.guru/v2/openapi.yaml --outputFormat JAVA_JUNIT_4 --maxTime 10s --ratePerMinute 60
#
# Example local BB
# docker run -v "/$(pwd)/generated_tests":/generated_tests webfuzzing/evomaster --blackBox true --bbSwaggerUrl http://host.docker.internal:8080/v3/api-docs --maxTime 5s
#
# TODO WB, and em.yaml, EMConfig param + info logs
#
# Debugging
# docker run -it --entrypoint sh webfuzzing/evomaster
#
#
#
#
#
#
#
21 changes: 19 additions & 2 deletions core/src/main/kotlin/org/evomaster/core/EMConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,15 @@ class EMConfig {
throw ConfigProblemException("The use of 'prematureStop' is meaningful only if the stopping criterion" +
" 'stoppingCriterion' is based on time")
}

if(blackBox){
if(sutControllerHost != ControllerConstants.DEFAULT_CONTROLLER_HOST){
throw ConfigProblemException("Changing 'sutControllerHost' has no meaning in black-box testing, as no controller is used")
}
if(!overrideOpenAPIUrl.isNullOrBlank()){
throw ConfigProblemException("Changing 'overrideOpenAPIUrl' has no meaning in black-box testing, as no controller is used")
}
}
}

private fun checkPropertyConstraints(m: KMutableProperty<*>) {
Expand Down Expand Up @@ -1048,6 +1057,16 @@ class EMConfig {
" If no tag is specified here, then such filter is not applied.")
var endpointTagFilter: String? = null

@Important(6.0)
@Cfg("Host name or IP address of where the SUT EvoMaster Controller Driver is listening on." +
" This option is only needed for white-box testing.")
var sutControllerHost = ControllerConstants.DEFAULT_CONTROLLER_HOST

@Important(6.1)
@Url
@Cfg("If specified, override the OpenAPI URL location given by the EvoMaster Driver." +
" This option is only needed for white-box testing.")
var overrideOpenAPIUrl = ""

//-------- other options -------------

Expand Down Expand Up @@ -1142,8 +1161,6 @@ class EMConfig {
@Max(maxTcpPort)
var sutControllerPort = ControllerConstants.DEFAULT_CONTROLLER_PORT

@Cfg("Host name or IP address of where the SUT REST controller is listening on")
var sutControllerHost = ControllerConstants.DEFAULT_CONTROLLER_HOST

@Cfg("Limit of number of individuals per target to keep in the archive")
@Min(1.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ abstract class AbstractRestSampler : HttpWsSampler<RestIndividual>() {
// set up authentications moved up since we are going to get authentication info from HttpWsSampler
setupAuthentication(infoDto)

if(!openApiURL.isNullOrBlank()) {
if(!config.overrideOpenAPIUrl.isNullOrBlank()){
retrieveSwagger(config.overrideOpenAPIUrl)
}else if(!openApiURL.isNullOrBlank()) {
retrieveSwagger(openApiURL)
} else if(! openApiSchema.isNullOrBlank()){
swagger = OpenApiAccess.getOpenApi(openApiSchema)
Expand Down
3 changes: 2 additions & 1 deletion docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ There are 3 types of options:
|`endpointFocus`| __String__. Concentrate search on only one single REST endpoint. *Default value*: `null`.|
|`endpointPrefix`| __String__. Concentrate search on a set of REST endpoints defined by a common prefix. *Default value*: `null`.|
|`endpointTagFilter`| __String__. Comma-separated list of OpenAPI/Swagger 'tags' definitions. Only the REST endpoints having at least one of such tags will be fuzzed. If no tag is specified here, then such filter is not applied. *Default value*: `null`.|
|`sutControllerHost`| __String__. Host name or IP address of where the SUT EvoMaster Controller Driver is listening on. This option is only needed for white-box testing. *Default value*: `localhost`.|
|`overrideOpenAPIUrl`| __String__. If specified, override the OpenAPI URL location given by the EvoMaster Driver. This option is only needed for white-box testing. *Constraints*: `URL`. *Default value*: `""`.|

## Internal Command-Line Options

Expand Down Expand Up @@ -194,7 +196,6 @@ There are 3 types of options:
|`statisticsFile`| __String__. Where the statistics file (if any) is going to be written (in CSV format). *Default value*: `statistics.csv`.|
|`stoppingCriterion`| __Enum__. Stopping criterion for the search. *Valid values*: `TIME, ACTION_EVALUATIONS, INDIVIDUAL_EVALUATIONS`. *Default value*: `TIME`.|
|`structureMutationProbability`| __Double__. Probability of applying a mutation that can change the structure of a test. *Constraints*: `probability 0.0-1.0`. *Default value*: `0.5`.|
|`sutControllerHost`| __String__. Host name or IP address of where the SUT REST controller is listening on. *Default value*: `localhost`.|
|`sutControllerPort`| __Int__. TCP port of where the SUT REST controller is listening on. *Constraints*: `min=0.0, max=65535.0`. *Default value*: `40100`.|
|`taintAnalysisForMapsAndArrays`| __Boolean__. Apply taint analysis to handle special cases of Maps and Arrays. *Default value*: `true`.|
|`taintApplySpecializationProbability`| __Double__. Probability of applying a discovered specialization for a tainted value. *Constraints*: `probability 0.0-1.0`. *Default value*: `0.5`.|
Expand Down

0 comments on commit ebec868

Please sign in to comment.