Skip to content
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
26 changes: 26 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
workflow_dispatch: {}
pull_request: {}
push:
branches:
- main
- master
paths:
- .github/workflows/semgrep.yml
schedule:
# random HH:MM to avoid a load spike on GitHub Actions at 00:00
- cron: 7 11 * * *
name: Semgrep
jobs:
semgrep:
name: semgrep/ci
runs-on: ubuntu-latest
permissions:
contents: read
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
container:
image: semgrep/semgrep
steps:
- uses: actions/checkout@v4
- run: semgrep ci
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public ResponseEntity<List<XMLMessage>> getAll(
org.owasp.benchmark.helpers.DatabaseHelper.printResults(statement, sql, resp);
} catch (java.sql.SQLException e) {
if (org.owasp.benchmark.helpers.DatabaseHelper.hideSQLErrors) {
e.printStackTrace();
//e.printStackTrace();
resp.add(new XMLMessage("Error processing request: " + e.getMessage()));
return new ResponseEntity<List<XMLMessage>>(resp, HttpStatus.OK);
} else throw new ServletException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void initData() {
tx.commit();
} catch (HibernateException e) {
if (tx != null) tx.rollback();
e.printStackTrace();
//e.printStackTrace();
} finally {

}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/owasp/benchmark/helpers/LDAPServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private void initDirectoryService(File workDir) {
service.startup();
} catch (Exception e) {
System.out.println("Error at LDAP startup: " + e.getMessage());
e.printStackTrace();
//e.printStackTrace();
}

// Inject the foo root entry if it does not already exist
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/owasp/benchmark/helpers/Startup.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public void contextInitialized(ServletContextEvent sce) {

} catch (ClassNotFoundException e) {
System.out.println("ERROR: Could not find expected DatabaseHelper class.");
e.printStackTrace();
//e.printStackTrace();
} catch (Exception e) {
System.out.println("ERROR: Could not find or add BouncyCastle as crypto provider.");
e.printStackTrace();
//e.printStackTrace();
}

if (Security.getProvider("BC") == null)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/owasp/benchmark/helpers/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class Utils {
} catch (ParserConfigurationException e) {
System.out.println(
"ERROR: couldn't set http://apache.org/xml/features/disallow-doctype-decl");
e.printStackTrace();
//e.printStackTrace();
}

File tempDir = new File(TESTFILES_DIR);
Expand All @@ -116,7 +116,7 @@ public class Utils {
out.write("Test is a test file.\n");
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
//e.printStackTrace();
}
File testFile2 = new File(TESTFILES_DIR + "SafeText");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
argList.add("sh");
argList.add("-c");
}
argList.add("echo " + param);
//argList.add("echo " + param);
// Sanitize param to only allow alphanumeric characters and spaces.
// Adjust the regex as needed depending on allowed input.
param = param.replaceAll("[^a-zA-Z0-9 ]", "");

argList.add("echo");
argList.add(param); // Pass param as a separate argument to avoid command injection

ProcessBuilder pb = new ProcessBuilder();

Expand Down