Skip to content

Commit 037056b

Browse files
committed
Adding two vulnerabilities
1 parent 7be2968 commit 037056b

File tree

5 files changed

+42
-38
lines changed

5 files changed

+42
-38
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616
WEB_APP_ADDRESS: https://app.code-intelligence.com
1717
# Directory in which the repository will be cloned.
1818
CHECKOUT_DIR: checkout-dir/
19-
CIFUZZ_DOWNLOAD_URL: "https://git.1-hub.cnCodeIntelligenceTesting/cifuzz/releases/latest/download/cifuzz_installer_linux_amd64"
19+
CIFUZZ_DOWNLOAD_URL: "https://git.1-hub.cnCodeIntelligenceTesting/cifuzz/releases/download/v2.18.0/cifuzz_installer_linux_amd64"
2020
CIFUZZ_INSTALL_DIR: ./cifuzz
2121
FUZZING_ARTIFACT: fuzzing-artifact.tar.gz
2222
jobs:
@@ -42,7 +42,7 @@ jobs:
4242
cd $CHECKOUT_DIR/
4343
$GITHUB_WORKSPACE/$CIFUZZ_INSTALL_DIR/bin/cifuzz bundle \
4444
--commit $GITHUB_SHA \
45-
--branch $GITHUB_REF_NAME \
45+
--branch $GITHUB_HEAD_REF \
4646
--output $GITHUB_WORKSPACE/$CHECKOUT_DIR/$FUZZING_ARTIFACT
4747
shell: "bash"
4848
- id: start-fuzzing

src/main/java/com/example/app/controller/GreetEndpointController.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public String greet(@RequestParam(required = false, defaultValue = "World") Stri
2020
conn.createStatement().execute(query);
2121
conn.close();
2222
}
23-
} catch (SQLException ignored) {}
23+
} catch (SQLException ignored) {
24+
}
2425
}
2526

2627
return "Greetings " + name + "!";

src/main/java/com/example/app/controller/HelloEndpointController.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public String hello(@RequestParam(required = false, defaultValue = "World") Stri
1414
String className = name.substring(8);
1515
try {
1616
Class.forName(className).getConstructor().newInstance();
17-
} catch (Exception ignored){}
17+
} catch (Exception ignored) {
18+
}
1819
}
1920
return "Hello " + name + "!";
2021
}

src/test/java/com/example/app/GreetEndpointTests.java

+18-17
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,23 @@
2727

2828
@WebMvcTest()
2929
public class GreetEndpointTests {
30-
@Autowired private MockMvc mockMvc;
31-
32-
@Test
33-
public void unitTestGreetDeveloper() throws Exception {
34-
mockMvc.perform(get("/greet").param("name", "Developer"));
35-
}
36-
37-
@Test
38-
public void unitTestGreetContributor() throws Exception {
39-
mockMvc.perform(get("/greet").param("name", "Contributor"));
40-
}
41-
42-
@FuzzTest
43-
public void fuzzTestGreet(FuzzedDataProvider data) throws Exception {
44-
String name = data.consumeRemainingAsString();
45-
mockMvc.perform(get("/greet").param("name", name));
46-
}
30+
@Autowired
31+
private MockMvc mockMvc;
32+
33+
@Test
34+
public void unitTestGreetDeveloper() throws Exception {
35+
mockMvc.perform(get("/greet").param("name", "Developer"));
36+
}
37+
38+
@Test
39+
public void unitTestGreetContributor() throws Exception {
40+
mockMvc.perform(get("/greet").param("name", "Contributor"));
41+
}
42+
43+
@FuzzTest
44+
public void fuzzTestGreet(FuzzedDataProvider data) throws Exception {
45+
String name = data.consumeRemainingAsString();
46+
mockMvc.perform(get("/greet").param("name", name));
47+
}
4748

4849
}

src/test/java/com/example/app/HelloEndpointTests.java

+18-17
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,23 @@
2727

2828
@WebMvcTest()
2929
public class HelloEndpointTests {
30-
@Autowired private MockMvc mockMvc;
31-
32-
@Test
33-
public void unitTestHelloDeveloper() throws Exception {
34-
mockMvc.perform(get("/hello").param("name", "Developer"));
35-
}
36-
37-
@Test
38-
public void unitTestHelloContributor() throws Exception {
39-
mockMvc.perform(get("/hello").param("name", "Contributor"));
40-
}
41-
42-
@FuzzTest
43-
public void fuzzTestHello(FuzzedDataProvider data) throws Exception {
44-
String name = data.consumeRemainingAsString();
45-
mockMvc.perform(get("/hello").param("name", name));
46-
}
30+
@Autowired
31+
private MockMvc mockMvc;
32+
33+
@Test
34+
public void unitTestHelloDeveloper() throws Exception {
35+
mockMvc.perform(get("/hello").param("name", "Developer"));
36+
}
37+
38+
@Test
39+
public void unitTestHelloContributor() throws Exception {
40+
mockMvc.perform(get("/hello").param("name", "Contributor"));
41+
}
42+
43+
@FuzzTest
44+
public void fuzzTestHello(FuzzedDataProvider data) throws Exception {
45+
String name = data.consumeRemainingAsString();
46+
mockMvc.perform(get("/hello").param("name", name));
47+
}
4748

4849
}

0 commit comments

Comments
 (0)