-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from joe-ds/main
Bambda to Filter Authenticated Requests
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Filters authenticated 200 OK requests in Proxy HTTP history. See four config values below. | ||
* | ||
* @author joe-ds (https://github.com/joe-ds) | ||
**/ | ||
|
||
var configNoFilter = true; // If set to false, won't show JS, GIF, JPG, PNG, CSS. | ||
var configNotInScopeOnly = true; // If set to false, won't show out-of-scope items. | ||
var sessionCookieName = ""; // If given, will look for a cookie with that name. | ||
var sessionCookieValue = ""; // If given, will check if cookie with sessionCookieName has this value. | ||
|
||
if (!requestResponse.hasResponse()) { | ||
return false; | ||
} | ||
|
||
var request = requestResponse.request(); | ||
var response = requestResponse.response(); | ||
|
||
if (!response.isStatusCodeClass(StatusCodeClass.CLASS_2XX_SUCCESS)) { | ||
return false; | ||
} | ||
|
||
var authHeader = request.hasHeader("Authorization"); | ||
|
||
boolean sessionCookie = request.headerValue("Cookie") != null | ||
&& !sessionCookieName.isEmpty() | ||
&& request.hasParameter(sessionCookieName, HttpParameterType.COOKIE) | ||
&& (sessionCookieValue.isEmpty() || sessionCookieValue.equals(request.parameter(sessionCookieName, HttpParameterType.COOKIE).value())); | ||
|
||
var path = request.pathWithoutQuery().toLowerCase(); | ||
var mimeType = requestResponse.mimeType(); | ||
var filterDenyList = mimeType != MimeType.CSS | ||
&& mimeType != MimeType.IMAGE_UNKNOWN | ||
&& mimeType != MimeType.IMAGE_JPEG | ||
&& mimeType != MimeType.IMAGE_GIF | ||
&& mimeType != MimeType.IMAGE_PNG | ||
&& mimeType != MimeType.IMAGE_BMP | ||
&& mimeType != MimeType.IMAGE_TIFF | ||
&& mimeType != MimeType.UNRECOGNIZED | ||
&& mimeType != MimeType.SOUND | ||
&& mimeType != MimeType.VIDEO | ||
&& mimeType != MimeType.FONT_WOFF | ||
&& mimeType != MimeType.FONT_WOFF2 | ||
&& mimeType != MimeType.APPLICATION_UNKNOWN | ||
&& !path.endsWith(".js") | ||
&& !path.endsWith(".gif") | ||
&& !path.endsWith(".jpg") | ||
&& !path.endsWith(".png") | ||
&& !path.endsWith(".css"); | ||
|
||
return (authHeader || sessionCookie) && (configNoFilter || filterDenyList) && (configNotInScopeOnly || request.isInScope()); |