Skip to content

Commit

Permalink
SOme new bambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
intrudir committed Jul 11, 2024
1 parent 2f2e277 commit 9a1d3c5
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CustomColumn/Proxy/HTTP/BadCSP.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if (requestResponse.response() != null) {
if(!requestResponse.response().hasHeader("Content-Security-Policy")) {
return "No CSP";
}

String csp = requestResponse.response().headerValue("Content-Security-Policy");
ArrayList<String> vulnerableDirectives = new ArrayList<>();
String[] directivesToCheck = new String[]{"unsafe-inline", "unsafe-eval"};

for(int i=0;i<directivesToCheck.length;i++) {
if(csp.contains(directivesToCheck[i])) {
vulnerableDirectives.add(directivesToCheck[i]);
}
}

return String.join(", ", vulnerableDirectives);
} else {
return false;
}
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions Filter/Proxy/HTTP/CSP Misconfigured.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
StringBuilder cspNotes = new StringBuilder();

// Only show reqs in scope
if (!requestResponse.request().isInScope()) {
return false;
}

if(requestResponse.response() == null) {
return false;
}

// Check if no CSP
if(!requestResponse.response().hasHeader("Content-Security-Policy")) {
cspNotes.append("No CSP in response").append("\n");
requestResponse.annotations().setNotes(cspNotes.toString());
return true;
}

// Check if bad directives in CSP
String csp = requestResponse.response().headerValue("Content-Security-Policy");
ArrayList<String> vulnerableDirectives = new ArrayList<>();
String[] directivesToCheck = new String[]{"unsafe-inline", "unsafe-eval"};

for(int i=0;i<directivesToCheck.length;i++) {
if(csp.contains(directivesToCheck[i])) {
vulnerableDirectives.add(directivesToCheck[i]);
}
}

String.join(", ", vulnerableDirectives);
cspNotes.append(vulnerableDirectives).append("\n");

if (cspNotes.length() > 0) {
requestResponse.annotations().setNotes(cspNotes.toString());
}
return cspNotes.length() > 0;
22 changes: 22 additions & 0 deletions Filter/Proxy/HTTP/HSTS Misconfigured.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
StringBuilder hstsNotes = new StringBuilder();

// Only show reqs in scope
if (!requestResponse.request().isInScope()) {
return false;
}

if(requestResponse.response() == null) {
return false;
}

// Check if no HSTS
if(!requestResponse.response().hasHeader("Strict-Transport-Security")) {
hstsNotes.append("No HSTS in response").append("\n");
requestResponse.annotations().setNotes(hstsNotes.toString());
return true;
}

if (hstsNotes.length() > 0) {
requestResponse.annotations().setNotes(hstsNotes.toString());
}
return hstsNotes.length() > 0;

0 comments on commit 9a1d3c5

Please sign in to comment.