Skip to content

Adding two vulnerabilities to demonstrate blocking pipeline #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
WEB_APP_ADDRESS: https://app.code-intelligence.com
# Directory in which the repository will be cloned.
CHECKOUT_DIR: checkout-dir/
CIFUZZ_DOWNLOAD_URL: "https://github.com/CodeIntelligenceTesting/cifuzz/releases/latest/download/cifuzz_installer_linux_amd64"
CIFUZZ_DOWNLOAD_URL: "https://github.com/CodeIntelligenceTesting/cifuzz/releases/download/v2.18.0/cifuzz_installer_linux_amd64"
CIFUZZ_INSTALL_DIR: ./cifuzz
FUZZING_ARTIFACT: fuzzing-artifact.tar.gz
jobs:
Expand All @@ -42,7 +42,7 @@ jobs:
cd $CHECKOUT_DIR/
$GITHUB_WORKSPACE/$CIFUZZ_INSTALL_DIR/bin/cifuzz bundle \
--commit $GITHUB_SHA \
--branch $GITHUB_REF_NAME \
--branch $GITHUB_HEAD_REF \
--output $GITHUB_WORKSPACE/$CHECKOUT_DIR/$FUZZING_ARTIFACT
shell: "bash"
- id: start-fuzzing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public String greet(@RequestParam(required = false, defaultValue = "World") Stri
conn.createStatement().execute(query);
conn.close();
}
} catch (SQLException ignored) {}
} catch (SQLException ignored) {
}
}

return "Greetings " + name + "!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public String hello(@RequestParam(required = false, defaultValue = "World") Stri
String className = name.substring(8);
try {
Class.forName(className).getConstructor().newInstance();
} catch (Exception ignored){}
} catch (Exception ignored) {
}
}
return "Hello " + name + "!";
}
Expand Down
35 changes: 18 additions & 17 deletions src/test/java/com/example/app/GreetEndpointTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,23 @@

@WebMvcTest()
public class GreetEndpointTests {
@Autowired private MockMvc mockMvc;

@Test
public void unitTestGreetDeveloper() throws Exception {
mockMvc.perform(get("/greet").param("name", "Developer"));
}

@Test
public void unitTestGreetContributor() throws Exception {
mockMvc.perform(get("/greet").param("name", "Contributor"));
}

@FuzzTest
public void fuzzTestGreet(FuzzedDataProvider data) throws Exception {
String name = data.consumeRemainingAsString();
mockMvc.perform(get("/greet").param("name", name));
}
@Autowired
private MockMvc mockMvc;

@Test
public void unitTestGreetDeveloper() throws Exception {
mockMvc.perform(get("/greet").param("name", "Developer"));
}

@Test
public void unitTestGreetContributor() throws Exception {
mockMvc.perform(get("/greet").param("name", "Contributor"));
}

@FuzzTest
public void fuzzTestGreet(FuzzedDataProvider data) throws Exception {
String name = data.consumeRemainingAsString();
mockMvc.perform(get("/greet").param("name", name));
}

}
35 changes: 18 additions & 17 deletions src/test/java/com/example/app/HelloEndpointTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,23 @@

@WebMvcTest()
public class HelloEndpointTests {
@Autowired private MockMvc mockMvc;

@Test
public void unitTestHelloDeveloper() throws Exception {
mockMvc.perform(get("/hello").param("name", "Developer"));
}

@Test
public void unitTestHelloContributor() throws Exception {
mockMvc.perform(get("/hello").param("name", "Contributor"));
}

@FuzzTest
public void fuzzTestHello(FuzzedDataProvider data) throws Exception {
String name = data.consumeRemainingAsString();
mockMvc.perform(get("/hello").param("name", name));
}
@Autowired
private MockMvc mockMvc;

@Test
public void unitTestHelloDeveloper() throws Exception {
mockMvc.perform(get("/hello").param("name", "Developer"));
}

@Test
public void unitTestHelloContributor() throws Exception {
mockMvc.perform(get("/hello").param("name", "Contributor"));
}

@FuzzTest
public void fuzzTestHello(FuzzedDataProvider data) throws Exception {
String name = data.consumeRemainingAsString();
mockMvc.perform(get("/hello").param("name", name));
}

}