### Initialize the EvoMaster Driver Source: https://github.com/webfuzzing/evomaster/blob/master/docs/write_driver.md Implement a main method to instantiate your controller and start the InstrumentedSutStarter. ```java public static void main(String[] args){ SutController controller = new X(); InstrumentedSutStarter starter = new InstrumentedSutStarter(controller); starter.start(); } ``` -------------------------------- ### Install EvoMaster via Pip Source: https://github.com/webfuzzing/evomaster/blob/master/pypi-distribution/README.md Install the EvoMaster wrapper using pip. Use pip3 if on a Mac. ```bash pip install evomaster ``` -------------------------------- ### Build Driver Library from Source Source: https://github.com/webfuzzing/evomaster/blob/master/docs/download.md When building the driver library from source, use the Maven install option to copy it to your local .m2 repository. The -DskipTests option can be used to skip running tests. ```bash mvn install -DskipTests ``` -------------------------------- ### Install Python dependencies Source: https://github.com/webfuzzing/evomaster/blob/master/docs/library_dependencies.md Commands to upgrade pip and install the required libraries from the requirements file. ```bash python -m pip install --upgrade pip --user pip install -r ./requirements.txt --user ``` -------------------------------- ### Standalone Application Entry Point Source: https://github.com/webfuzzing/evomaster/blob/master/docs/write_driver.md A basic main method to verify that the application can be started programmatically outside of the EvoMaster environment. ```java public static void main(String[] args) { SpringApplication.run(Application.class, args); } ``` -------------------------------- ### Running EvoMaster from the command line Source: https://github.com/webfuzzing/evomaster/blob/master/docs/whitebox.md This command executes the EvoMaster JAR file. By default, it connects to a controller server on port 40100 to start the SUT with necessary instrumentations and then begins the evolutionary algorithm for test case generation. ```bash java -jar evomaster.jar ``` -------------------------------- ### Run EvoMaster from command line Source: https://github.com/webfuzzing/evomaster/blob/master/README.md Execute EvoMaster from the command line, specifying the schema URL for the API to be fuzzed. This example fuzzes the PetClinic API for 60 seconds. ```bash evomaster --schema https://petstore.swagger.io/v2/swagger.json ``` -------------------------------- ### EvoMaster Embedded Controller Setup Source: https://github.com/webfuzzing/evomaster/blob/master/docs/example.md This Java code configures the embedded REST server for testing purposes. It includes methods for starting the server before all tests, stopping it after all tests, and resetting the SUT's state before each test. RestAssured's URL encoding is also disabled. ```java private static SutHandler controller = new em.embedded.se.devscout.scoutapi.EmbeddedEvoMasterController(); private static String baseUrlOfSut; @BeforeClass public static void initClass() { baseUrlOfSut = controller.startSut(); assertNotNull(baseUrlOfSut); RestAssured.urlEncodingEnabled = false; } @AfterClass public static void tearDown() { controller.stopSut(); } @Before public void initTest() { controller.resetStateOfSUT(); } ``` -------------------------------- ### Execute Experiment Script Source: https://github.com/webfuzzing/evomaster/blob/master/docs/replicating_studies.md Example command to generate 10 Bash scripts in the 'foo' directory with specific search budget and repetition settings. ```bash exp.py false 12345 foo 0 4 100000 1 10 ``` -------------------------------- ### Display EvoMaster Help Source: https://github.com/webfuzzing/evomaster/blob/master/docs/options.md Use the `--help` flag to list all available command-line options for EvoMaster. This is useful for understanding the full range of configurable parameters. ```bash java -jar evomaster.jar --help ``` -------------------------------- ### Execute EvoMaster from Command Line Source: https://github.com/webfuzzing/evomaster/blob/master/pypi-distribution/README.md Run the EvoMaster wrapper from the command line with specified arguments. ```bash evomaster ``` -------------------------------- ### Initialize SQL Database with Script Source: https://github.com/webfuzzing/evomaster/blob/master/docs/write_driver.md Registers an SQL initialization script for a database specification to ensure consistent state during fuzzing. ```java new DbSpecification(DatabaseType.H2,sqlConnection) .withInitSqlOnResourcePath(INIT_DB_SCRIPT_PATH) ``` -------------------------------- ### Check Maven Version with Specific JDK on Windows (Bash) Source: https://github.com/webfuzzing/evomaster/blob/master/docs/for_developers.md This command demonstrates how to check the Maven version while explicitly using JDK 11, useful for ensuring correct environment setup on Windows via a bash shell. ```shell JAVA_HOME=$JAVA_HOME_11 mvn --version ``` -------------------------------- ### Run EvoMaster with Docker in Windows Command Prompt (Cmd.exe) Source: https://github.com/webfuzzing/evomaster/blob/master/README.md In a Windows Command Prompt (Cmd.exe), use '%CD%' to refer to the current directory when mounting volumes with Docker. ```bash docker run -v %CD%/generated_tests:/generated_tests webfuzzing/evomaster --schema https://petstore.swagger.io/v2/swagger.json ``` -------------------------------- ### Example of a complex conditional in white-box testing Source: https://github.com/webfuzzing/evomaster/blob/master/docs/whitebox.md This snippet illustrates a conditional statement where a black-box approach would have a very low probability of covering the 'then' branch. Static/dynamic analysis, as used by EvoMaster, can directly identify the required input (42) to cover this branch. ```java if(x==42){//... ``` -------------------------------- ### Deploy to Maven Central Source: https://github.com/webfuzzing/evomaster/blob/master/docs/release.md Execute the Maven deployment command from the project root. ```bash mvn clean -Pdeployment -DskipTests deploy ``` -------------------------------- ### Configure Maven settings.xml Source: https://github.com/webfuzzing/evomaster/blob/master/docs/release.md Create or update the ~/.m2/settings.xml file with credentials for Maven Central deployment. ```xml central ??? ??? ``` -------------------------------- ### Configure Experiment Parameters Source: https://github.com/webfuzzing/evomaster/blob/master/docs/replicating_studies.md Defines the command-line interface for the experiment configuration script. ```bash exp.py ``` -------------------------------- ### Configure Initialization SQL Script in DbSpecification Source: https://github.com/webfuzzing/evomaster/blob/master/docs/auth.md When delegating SQL database resetting to EvoMaster, initialize scripts directly on the DbSpecification object using withInitSqlOnResourcePath. This method allows specifying the path to the initialization SQL script. ```Java new DbSpecification(DatabaseType.H2,sqlConnection) .withInitSqlOnResourcePath("/init_db.sql") ``` -------------------------------- ### Define Python requirements Source: https://github.com/webfuzzing/evomaster/blob/master/docs/library_dependencies.md List these dependencies in a requirements.txt file for Python test execution. ```text rfc3986==2.0.0 urllib3==1.26.5 requests==2.25.1 timeout-decorator==0.5.0 ``` -------------------------------- ### Run EvoMaster with Docker in MSYS/Git Bash on Windows Source: https://github.com/webfuzzing/evomaster/blob/master/README.md When using Docker in shells like MSYS or Git Bash on Windows, the volume mount syntax requires an extra '/' before the '$'. ```bash docker run -v "/$(pwd)/generated_tests":/generated_tests webfuzzing/evomaster --schema https://petstore.swagger.io/v2/swagger.json ``` -------------------------------- ### Manage GPG keys Source: https://github.com/webfuzzing/evomaster/blob/master/docs/release.md Commands for generating, listing, and uploading GPG keys required for signing release files. ```bash gpg --gen-key ``` ```bash gpg --list-keys ``` ```bash gpg --keyserver https://keys.openpgp.org --send-keys ??? ``` -------------------------------- ### Import EvoMaster client controller for white-box testing Source: https://github.com/webfuzzing/evomaster/blob/master/docs/library_dependencies.md Necessary dependency for white-box driver implementation in JVM projects. ```xml org.evomaster evomaster-client-java-controller test LATEST ``` -------------------------------- ### Execute Java with Specific JDK Version on Windows (Bash) Source: https://github.com/webfuzzing/evomaster/blob/master/docs/for_developers.md This command shows how to execute the Java runtime with JDK 17, specifying the path to the JDK home directory, useful for testing or running specific Java applications. ```shell $JAVA_HOME_17/bin/java -version ``` -------------------------------- ### Configure Basic Authentication Credentials Source: https://github.com/webfuzzing/evomaster/blob/master/docs/auth.md Implement the getInfoForAuthentication method to provide a list of AuthenticationDto objects for Basic authentication. This allows EvoMaster to generate valid HTTP headers for different users. ```Java @Override public List getInfoForAuthentication() { return Arrays.asList( AuthUtils.getForBasic("admin","master","1234"), AuthUtils.getForBasic("consumer","joao","1234"), AuthUtils.getForBasic("manager","joaquim","1234"), AuthUtils.getForBasic("employee","mafalda","1234") ); } ``` -------------------------------- ### Run EvoMaster with Docker in PowerShell Source: https://github.com/webfuzzing/evomaster/blob/master/README.md For PowerShell on Windows, use '${PWD}' to reference the current directory when mounting volumes with Docker. ```bash docker run -v ${PWD}/generated_tests:/generated_tests webfuzzing/evomaster --schema https://petstore.swagger.io/v2/swagger.json ``` -------------------------------- ### SMTLib Class Overview Source: https://github.com/webfuzzing/evomaster/blob/master/core-extra/solver/README.md The SMTLib class provides an abstraction for constructing and managing SMT-LIB files, designed to work with the Z3 solver. ```APIDOC ## SMTLib Class ### Description Manages a collection of SMTNode objects and produces the final SMT-LIB file as a string. ### Key Components - **`SMTLib`**: Manages SMT nodes and generates SMT-LIB output. - **`SMTNode`**: Abstract base class for SMT-LIB constructs. - **`CheckSatSMTNode`**: Represents the `check-sat` command. - **`DeclareConstSMTNode`**: Represents the `declare-const` command. - **`DeclareDatatypeSMTNode`**: Represents the `declare-datatype` command. - **`GetValueSMTNode`**: Represents the `get-value` command. - **`AssertSMTNode`**: Represents an assertion. - **`Assertion`**: Abstract concept for SMT-LIB assertions. - **`AndAssertion`**: Logical AND of assertions. - **`DistinctAssertion`**: Ensures distinct values. - **`EqualsAssertion`**: Equality assertion. - **`GreaterThanAssertion`**: Greater than assertion. - **`GreaterThanOrEqualsAssertion`**: Greater than or equal to assertion. - **`LessThanAssertion`**: Less than assertion. - **`LessThanOrEqualsAssertion`**: Less than or equal to assertion. - **`OrAssertion`**: Logical OR of assertions. ``` -------------------------------- ### Execute SQL Script for Database Initialization Source: https://github.com/webfuzzing/evomaster/blob/master/docs/auth.md Use SqlScriptRunnerCached to run SQL scripts from resource files for database initialization, including recreating login/password credentials. This is useful when resetting the SUT state. ```Java DbCleaner.clearDatabase_H2(connection); SqlScriptRunnerCached.runScriptFromResourceFile(connection,"/init_db.sql"); ``` -------------------------------- ### Run EvoMaster using Docker Source: https://github.com/webfuzzing/evomaster/blob/master/README.md Run EvoMaster via Docker, mounting a local directory for generated tests. This command uses the webfuzzing/evomaster image and targets the PetClinic API. ```bash docker run -v "$(pwd)/generated_tests":/generated_tests webfuzzing/evomaster --schema https://petstore.swagger.io/v2/swagger.json ``` -------------------------------- ### Configure SQL Database Specifications Source: https://github.com/webfuzzing/evomaster/blob/master/docs/write_driver.md Override getDbSpecifications to define database types and connections for the SUT. ```java @Override public List getDbSpecifications() { return Arrays.asList(new DbSpecification(DatabaseType.H2, sqlConnection)); } ``` -------------------------------- ### Extract SQL Connection Object Source: https://github.com/webfuzzing/evomaster/blob/master/docs/write_driver.md Use DriverManager to establish a database connection within the startSut method. ```java connection = java.sql.DriverManager.getConnection(url,user,password); ``` -------------------------------- ### Configure Zsh for Multiple JDK Versions on Mac Source: https://github.com/webfuzzing/evomaster/blob/master/docs/for_developers.md This configuration for `~/.zprofile` allows easy switching between different JDK versions on macOS using aliases for Java and Maven commands. ```shell export JAVA_HOME_8=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/ export JAVA_HOME_11=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/ export JAVA_HOME=$JAVA_HOME_11 export PATH=$JAVA_HOME/bin:$PATH alias java8='$JAVA_HOME_8/bin/java' alias java11='$JAVA_HOME_11/bin/java' alias mvn8='JAVA_HOME=$JAVA_HOME_8 && mvn' alias mvn11='JAVA_HOME=$JAVA_HOME_11 && mvn' ```