Skip to content

Commit ee83305

Browse files
authored
Merge pull request #146 from WebFuzzing/http-patch-spring-drivers
Http patch spring drivers
2 parents d34206f + 600a633 commit ee83305

File tree

18 files changed

+758
-3
lines changed

18 files changed

+758
-3
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,7 @@ jdk_8_maven/em/external/rest/spring-batch-rest/target
364364
/jdk_8_maven/cs/rest/original/swagger-petstore/target
365365
/jdk_8_maven/em/embedded/rest/swagger-petstore/target
366366
/jdk_8_maven/em/external/rest/swagger-petstore/target
367+
368+
/jdk_11_maven/cs/rest/http-patch-spring/target
369+
/jdk_11_maven/em/embedded/rest/http-patch-spring/target
370+
/jdk_11_maven/em/external/rest/http-patch-spring/target

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ For simplicity, all schemas are also available as JSON/YML files under the folde
7070
> **IMPORTANT**: More details (e.g., #LOCs and used databases) on these APIs can be found [in this table](statistics/table_emb.md).
7171
7272

73-
### REST: Java/Kotlin (32)
73+
### REST: Java/Kotlin (33)
7474

7575
* **Bibliothek** (MIT), [jdk_17_gradle/cs/rest/bibliothek](jdk_17_gradle/cs/rest/bibliothek), from [https://github.com/PaperMC/bibliothek](https://github.com/PaperMC/bibliothek)
7676

@@ -90,6 +90,8 @@ For simplicity, all schemas are also available as JSON/YML files under the folde
9090

9191
* **Gestao Hospital** (not-known license), [jdk_8_maven/cs/rest-gui/gestaohospital](jdk_8_maven/cs/rest-gui/gestaohospital), from [https://github.com/ValchanOficial/GestaoHospital](https://github.com/ValchanOficial/GestaoHospital)
9292

93+
* **HTTP Patch Spring** (MIT), [jdk_11_maven/cs/rest/http-patch-spring](jdk_11_maven/cs/rest/http-patch-spring), from [https://github.com/cassiomolin/http-patch-spring](https://github.com/cassiomolin/http-patch-spring)
94+
9395
* **Languagetool** (LGPL), [jdk_8_maven/cs/rest/original/languagetool](jdk_8_maven/cs/rest/original/languagetool), from [https://github.com/languagetool-org/languagetool](https://github.com/languagetool-org/languagetool)
9496

9597
* **Market** (MIT), [jdk_11_maven/cs/rest-gui/market](jdk_11_maven/cs/rest-gui/market), from [https://github.com/aleksey-lukyanets/market](https://github.com/aleksey-lukyanets/market)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM amazoncorretto:11-alpine-jdk
2+
3+
COPY ./dist/http-patch-spring-sut.jar .
4+
COPY ./dist/jacocoagent.jar .
5+
6+
7+
8+
#ENV TOOL="undefined"
9+
#ENV RUN="0"
10+
11+
ENTRYPOINT \
12+
java \
13+
# unfortunately dumponexit is completely unreliable in Docker :(
14+
# -javaagent:jacocoagent.jar=destfile=./jacoco/http-patch-spring__${TOOL}__${RUN}__jacoco.exec,append=false,dumponexit=true \
15+
-javaagent:jacocoagent.jar=output=tcpserver,address=*,port=6300,append=false,dumponexit=false \
16+
-jar http-patch-spring-sut.jar \
17+
--server.port=8080

dockerfiles/http-patch-spring.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
sut-http-patch-spring:
3+
build:
4+
dockerfile: ./dockerfiles/http-patch-spring.dockerfile
5+
context: ..
6+
# environment:
7+
# TOOL: ${TOOL:-undefined}
8+
# RUN: ${RUN:-0}
9+
ports:
10+
- "${HOST_PORT:-8080}:8080"
11+
- "${JACOCO_PORT:-6300}:6300"
12+
# volumes:
13+
# default env does not work on volumes
14+
# - ${JACOCODIR}:/jacoco
15+

jdk_11_maven/cs/rest/http-patch-spring/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
</dependencyManagement>
3939

4040
<dependencies>
41+
<!--MODIFIED-->
42+
<dependency>
43+
<groupId>org.springdoc</groupId>
44+
<artifactId>springdoc-openapi-ui</artifactId>
45+
<version>1.6.14</version>
46+
</dependency>
47+
<!--MODIFIED-->
4148

4249
<!-- Spring Boot Starter Web -->
4350
<dependency>
@@ -130,6 +137,10 @@
130137
<goals>
131138
<goal>repackage</goal>
132139
</goals>
140+
<configuration>
141+
<finalName>http-patch-spring</finalName>
142+
<classifier>sut</classifier>
143+
</configuration>
133144
</execution>
134145
</executions>
135146
</plugin>

jdk_11_maven/cs/rest/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<module>cwa-verification-server</module>
1717
<module>pay-publicapi</module>
1818
<module>tracking-system</module>
19+
<module>http-patch-spring</module>
1920
</modules>
2021

2122

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<artifactId>evomaster-benchmark-jdk11-em-embedded-rest-http-patch-spring</artifactId>
8+
<packaging>jar</packaging>
9+
10+
<parent>
11+
<groupId>org.evomaster</groupId>
12+
<artifactId>evomaster-benchmark-jdk11-em-embedded-rest</artifactId>
13+
<version>3.4.1-SNAPSHOT</version>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>com.cassiomolin</groupId>
19+
<artifactId>patch-example</artifactId>
20+
<version>1.0-SNAPSHOT</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>com.fasterxml.jackson.core</groupId>
24+
<artifactId>jackson-core</artifactId>
25+
<version>2.13.4</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>com.fasterxml.jackson.core</groupId>
29+
<artifactId>jackson-databind</artifactId>
30+
<version>2.13.4</version>
31+
</dependency>
32+
</dependencies>
33+
34+
35+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package em.embedded.http.patch.spring;
2+
3+
4+
import com.cassiomolin.patch.PatchApplication;
5+
import org.evomaster.client.java.controller.AuthUtils;
6+
import org.evomaster.client.java.controller.EmbeddedSutController;
7+
import org.evomaster.client.java.controller.InstrumentedSutStarter;
8+
import org.evomaster.client.java.controller.api.dto.SutInfoDto;
9+
import org.evomaster.client.java.controller.api.dto.auth.AuthenticationDto;
10+
import org.evomaster.client.java.controller.api.dto.database.schema.DatabaseType;
11+
import org.evomaster.client.java.controller.problem.ProblemInfo;
12+
import org.evomaster.client.java.controller.problem.RestProblem;
13+
import org.evomaster.client.java.sql.DbCleaner;
14+
import org.evomaster.client.java.sql.DbSpecification;
15+
import org.springframework.boot.SpringApplication;
16+
import org.springframework.context.ConfigurableApplicationContext;
17+
18+
import java.util.List;
19+
import java.util.Map;
20+
21+
/**
22+
* Class used to start/stop the SUT. This will be controller by the EvoMaster process
23+
*/
24+
public class EmbeddedEvoMasterController extends EmbeddedSutController {
25+
26+
public static void main(String[] args) {
27+
28+
int port = 40100;
29+
if (args.length > 0) {
30+
port = Integer.parseInt(args[0]);
31+
}
32+
33+
EmbeddedEvoMasterController controller = new EmbeddedEvoMasterController(port);
34+
InstrumentedSutStarter starter = new InstrumentedSutStarter(controller);
35+
36+
starter.start();
37+
}
38+
39+
40+
private ConfigurableApplicationContext ctx;
41+
private List<DbSpecification> dbSpecification;
42+
43+
44+
public EmbeddedEvoMasterController() {
45+
this(40100);
46+
}
47+
48+
public EmbeddedEvoMasterController(int port) {
49+
setControllerPort(port);
50+
}
51+
52+
@Override
53+
public String startSut() {
54+
55+
ctx = SpringApplication.run(PatchApplication.class, new String[]{
56+
"--server.port=0"
57+
});
58+
59+
return "http://localhost:" + getSutPort();
60+
}
61+
62+
protected int getSutPort() {
63+
return (Integer) ((Map) ctx.getEnvironment()
64+
.getPropertySources().get("server.ports").getSource())
65+
.get("local.server.port");
66+
}
67+
68+
69+
@Override
70+
public boolean isSutRunning() {
71+
return ctx != null && ctx.isRunning();
72+
}
73+
74+
@Override
75+
public void stopSut() {
76+
ctx.stop();
77+
}
78+
79+
@Override
80+
public String getPackagePrefixesToCover() {
81+
return "com.cassiomolin.patch.";
82+
}
83+
84+
@Override
85+
public void resetStateOfSUT() {
86+
}
87+
88+
@Override
89+
public ProblemInfo getProblemInfo() {
90+
91+
return new RestProblem(
92+
"http://localhost:" + getSutPort() + "/v3/api-docs",
93+
null,
94+
null
95+
);
96+
}
97+
98+
@Override
99+
public SutInfoDto.OutputFormat getPreferredOutputFormat() {
100+
return SutInfoDto.OutputFormat.JAVA_JUNIT_5;
101+
}
102+
103+
@Override
104+
public List<AuthenticationDto> getInfoForAuthentication() {
105+
return null;
106+
}
107+
108+
@Override
109+
public List<DbSpecification> getDbSpecifications() {
110+
return dbSpecification;
111+
}
112+
}

jdk_11_maven/em/embedded/rest/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<module>market</module>
1818
<module>pay-publicapi</module>
1919
<module>tracking-system</module>
20+
<module>http-patch-spring</module>
2021
</modules>
2122

2223
</project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<artifactId>evomaster-benchmark-jdk11-em-external-rest-http-patch-spring</artifactId>
8+
<packaging>jar</packaging>
9+
10+
<parent>
11+
<groupId>org.evomaster</groupId>
12+
<artifactId>evomaster-benchmark-jdk11-em-external-rest</artifactId>
13+
<version>3.4.1-SNAPSHOT</version>
14+
</parent>
15+
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>org.apache.maven.plugins</groupId>
20+
<artifactId>maven-shade-plugin</artifactId>
21+
<executions>
22+
<execution>
23+
<phase>package</phase>
24+
<goals>
25+
<goal>shade</goal>
26+
</goals>
27+
<configuration>
28+
<finalName>http-patch-spring-evomaster-runner</finalName>
29+
<transformers>
30+
<transformer
31+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
32+
<manifestEntries>
33+
<Main-Class>em.external.http.patch.spring.ExternalEvoMasterController
34+
</Main-Class>
35+
<Premain-Class>org.evomaster.client.java.instrumentation.InstrumentingAgent
36+
</Premain-Class>
37+
<Agent-Class>org.evomaster.client.java.instrumentation.InstrumentingAgent
38+
</Agent-Class>
39+
<Can-Redefine-Classes>true</Can-Redefine-Classes>
40+
<Can-Retransform-Classes>true</Can-Retransform-Classes>
41+
</manifestEntries>
42+
</transformer>
43+
</transformers>
44+
</configuration>
45+
</execution>
46+
</executions>
47+
</plugin>
48+
</plugins>
49+
</build>
50+
51+
52+
</project>

0 commit comments

Comments
 (0)