Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 72f1396

Browse files
authored
Merge pull request #337 from browserup/allowlist-blocklist
Rename: Whitelist-> Allowlist, BlackList -> BlockList
2 parents b1e038e + c6a77c7 commit 72f1396

File tree

23 files changed

+599
-599
lines changed

23 files changed

+599
-599
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ For more information on the features available in the REST API, see [the REST AP
6565

6666
The proxy is programmatically controlled via a REST interface or by being embedded directly inside Java-based programs and unit tests. It captures performance data in the [HAR format](http://groups.google.com/group/http-archive-specification). In addition it can actually control HTTP traffic, such as:
6767

68-
- blacklisting and whitelisting certain URL patterns
68+
- blocklisting and allowlisting certain URL patterns
6969
- simulating various bandwidth and latency
7070
- remapping DNS lookups
7171
- flushing DNS caching
@@ -107,12 +107,12 @@ Creates a new proxy to run requests off of | POST | */proxy* | <p>*port* - Integ
107107
Starts a new page on the existing HAR. *[port]* in request path it is port where your proxy was started | PUT | */proxy/[port]/har/pageRef* |<p>*pageRef* - The string name of the first page ref that should be used in the HAR. Optional, default to "Page N" where N is the next page number.</p><p>*pageTitle* - The title of new HAR page. Optional, default to `pageRef`.</p>
108108
Shuts down the proxy and closes the port. *[port]* in request path it is port where your proxy was started | DELETE | */proxy/[port]* ||
109109
Returns the JSON/HAR content representing all the HTTP traffic passed through the proxy (provided you have already created the HAR with [this method](#harcreate)) | GET | */proxy/[port]/har* ||
110-
Displays whitelisted items | GET | */proxy/[port]/whitelist* ||
111-
Sets a list of URL patterns to whitelist | PUT | */proxy/[port]/whitelist* |<p>*regex* - A comma separated list of regular expressions.</p><p>*status* - The HTTP status code to return for URLs that do not match the whitelist.</p>|
112-
Clears all URL patterns from the whitelist | DELETE | */proxy/[port]/whitelist* ||
113-
Displays blacklisted items | GET | */proxy/[port]/blacklist* ||
114-
Set a URL to blacklist | PUT | */proxy/[port]/blacklist* |<p>*regex* - The blacklist regular expression.</p><p>*status* - The HTTP status code to return for URLs that are blacklisted.</p><p>*method* - The regular expression for matching HTTP method (GET, POST, PUT, etc). Optional, by default processing all HTTP method.</p>|
115-
Clears all URL patterns from the blacklist | DELETE | */proxy/[port]/blacklist* ||
110+
Displays allowlisted items | GET | */proxy/[port]/allowlist* ||
111+
Sets a list of URL patterns to allowlist | PUT | */proxy/[port]/allowlist* |<p>*regex* - A comma separated list of regular expressions.</p><p>*status* - The HTTP status code to return for URLs that do not match the allowlist.</p>|
112+
Clears all URL patterns from the allowlist | DELETE | */proxy/[port]/allowlist* ||
113+
Displays blocklisted items | GET | */proxy/[port]/blocklist* ||
114+
Set a URL to blocklist | PUT | */proxy/[port]/blocklist* |<p>*regex* - The blocklist regular expression.</p><p>*status* - The HTTP status code to return for URLs that are blocklisted.</p><p>*method* - The regular expression for matching HTTP method (GET, POST, PUT, etc). Optional, by default processing all HTTP method.</p>|
115+
Clears all URL patterns from the blocklist | DELETE | */proxy/[port]/blocklist* ||
116116
Limit the bandwidth through the proxy on the *[port]* | PUT | */proxy/[port]/limit* |<p>*downstreamKbps* - Sets the downstream bandwidth limit in kbps. Optional.</p><p>*upstreamKbps* - Sets the upstream bandwidth limit kbps. Optional, by default unlimited.</p><p>*downstreamMaxKB* - Specifies how many kilobytes in total the client is allowed to download through the proxy. Optional, by default unlimited.</p><p>*upstreamMaxKB* - Specifies how many kilobytes in total the client is allowed to upload through the proxy. Optional, by default unlimited.</p><p>*latency* - Add the given latency to each HTTP request. Optional, by default all requests are invoked without latency.</p><p>*enable* - A boolean that enable bandwidth limiter. Optional, by default to "false", but setting any of the properties above will implicitly enable throttling</p><p>*payloadPercentage* - Specifying what percentage of data sent is payload, e.g. use this to take into account overhead due to tcp/ip. Optional.</p><p>*maxBitsPerSecond* - The max bits per seconds you want this instance of StreamManager to respect. Optional.</p>
117117
Displays the amount of data remaining to be uploaded/downloaded until the limit is reached | GET | */proxy/[port]/limit* ||
118118
Set and override HTTP Request headers | POST | */proxy/[port]/headers* | Payload data should be **JSON** encoded set of headers. Where key is a header name (such as "User-Agent") and value is a value of HTTP header to setup (such as "BrowserUp-Agent"). Example: `{"User-Agent": "BrowserUp-Agent"}`|

browserup-proxy-core/src/main/java/com/browserup/bup/BrowserUpProxy.java

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.browserup.bup.filters.RequestFilter;
99
import com.browserup.bup.filters.ResponseFilter;
1010
import com.browserup.bup.mitm.TrustSource;
11-
import com.browserup.bup.proxy.BlacklistEntry;
11+
import com.browserup.bup.proxy.BlocklistEntry;
1212
import com.browserup.bup.proxy.CaptureType;
1313
import com.browserup.bup.proxy.auth.AuthType;
1414
import com.browserup.bup.proxy.dns.AdvancedHostResolver;
@@ -406,105 +406,105 @@ default Har getHar() {
406406
void clearRewriteRules();
407407

408408
/**
409-
* Adds a URL-matching regular expression to the blacklist. Requests that match a blacklisted URL will return the specified HTTP
410-
* statusCode for all HTTP methods. If there are existing patterns on the blacklist, the urlPattern will be evaluated last,
411-
* after the URL is checked against all other blacklist entries.
409+
* Adds a URL-matching regular expression to the blocklist. Requests that match a blocklisted URL will return the specified HTTP
410+
* statusCode for all HTTP methods. If there are existing patterns on the blocklist, the urlPattern will be evaluated last,
411+
* after the URL is checked against all other blocklist entries.
412412
* The urlPattern matches the full URL of the request, including scheme, host, and port, path, and query parameters
413-
* for both HTTP and HTTPS requests. For example, to blacklist both HTTP and HTTPS requests to www.google.com,
413+
* for both HTTP and HTTPS requests. For example, to blocklist both HTTP and HTTPS requests to www.google.com,
414414
* use a urlPattern of "https?://www\\.google\\.com/.*".
415415
*
416-
* @param urlPattern URL-matching regular expression to blacklist
416+
* @param urlPattern URL-matching regular expression to blocklist
417417
* @param statusCode HTTP status code to return
418418
*/
419-
void blacklistRequests(String urlPattern, int statusCode);
419+
void blocklistRequests(String urlPattern, int statusCode);
420420

421421
/**
422-
* Adds a URL-matching regular expression to the blacklist. Requests that match a blacklisted URL will return the specified HTTP
422+
* Adds a URL-matching regular expression to the blocklist. Requests that match a blocklisted URL will return the specified HTTP
423423
* statusCode only when the request's HTTP method (GET, POST, PUT, etc.) matches the specified httpMethodPattern regular expression.
424-
* If there are existing patterns on the blacklist, the urlPattern will be evaluated last, after the URL is checked against all
425-
* other blacklist entries.
426-
* See {@link #blacklistRequests(String, int)} for details on the URL the urlPattern will match.
424+
* If there are existing patterns on the blocklist, the urlPattern will be evaluated last, after the URL is checked against all
425+
* other blocklist entries.
426+
* See {@link #blocklistRequests(String, int)} for details on the URL the urlPattern will match.
427427
*
428-
* @param urlPattern URL-matching regular expression to blacklist
428+
* @param urlPattern URL-matching regular expression to blocklist
429429
* @param statusCode HTTP status code to return
430430
* @param httpMethodPattern regular expression matching a request's HTTP method
431431
*/
432-
void blacklistRequests(String urlPattern, int statusCode, String httpMethodPattern);
432+
void blocklistRequests(String urlPattern, int statusCode, String httpMethodPattern);
433433

434434
/**
435-
* Replaces any existing blacklist with the specified blacklist. URLs will be evaluated against the blacklist in the order
435+
* Replaces any existing blocklist with the specified blocklist. URLs will be evaluated against the blocklist in the order
436436
* specified by the Collection's iterator.
437437
*
438-
* @param blacklist new blacklist entries
438+
* @param blocklist new blocklist entries
439439
*/
440-
void setBlacklist(Collection<BlacklistEntry> blacklist);
440+
void setBlocklist(Collection<BlocklistEntry> blocklist);
441441

442442
/**
443-
* Returns all blacklist entries currently in effect. Iterating over the returned Collection is guaranteed to return
444-
* blacklist entries in the order in which URLs are actually evaluated against the blacklist.
443+
* Returns all blocklist entries currently in effect. Iterating over the returned Collection is guaranteed to return
444+
* blocklist entries in the order in which URLs are actually evaluated against the blocklist.
445445
*
446-
* @return blacklist entries, or an empty collection if none exist
446+
* @return blocklist entries, or an empty collection if none exist
447447
*/
448-
Collection<BlacklistEntry> getBlacklist();
448+
Collection<BlocklistEntry> getBlocklist();
449449

450450
/**
451-
* Clears any existing blacklist.
451+
* Clears any existing blocklist.
452452
*/
453-
void clearBlacklist();
453+
void clearBlocklist();
454454

455455
/**
456-
* Whitelists URLs matching the specified regular expression patterns. Replaces any existing whitelist.
456+
* Allowlists URLs matching the specified regular expression patterns. Replaces any existing allowlist.
457457
* The urlPattern matches the full URL of the request, including scheme, host, and port, path, and query parameters
458-
* for both HTTP and HTTPS requests. For example, to whitelist both HTTP and HTTPS requests to www.google.com, use a urlPattern
458+
* for both HTTP and HTTPS requests. For example, to allowlist both HTTP and HTTPS requests to www.google.com, use a urlPattern
459459
* of "https?://www\\.google\\.com/.*".
460-
* <b>Note:</b> All HTTP CONNECT requests are automatically whitelisted and cannot be short-circuited using the
461-
* whitelist response code.
460+
* <b>Note:</b> All HTTP CONNECT requests are automatically allowlisted and cannot be short-circuited using the
461+
* allowlist response code.
462462
*
463-
* @param urlPatterns URL-matching regular expressions to whitelist; null or an empty collection will enable an empty whitelist
463+
* @param urlPatterns URL-matching regular expressions to allowlist; null or an empty collection will enable an empty allowlist
464464
* @param statusCode HTTP status code to return to clients when a URL matches a pattern
465465
*/
466-
void whitelistRequests(Collection<String> urlPatterns, int statusCode);
466+
void allowlistRequests(Collection<String> urlPatterns, int statusCode);
467467

468468
/**
469-
* Adds a URL-matching regular expression to an existing whitelist.
469+
* Adds a URL-matching regular expression to an existing allowlist.
470470
*
471-
* @param urlPattern URL-matching regular expressions to whitelist
472-
* @throws java.lang.IllegalStateException if the whitelist is not enabled
471+
* @param urlPattern URL-matching regular expressions to allowlist
472+
* @throws java.lang.IllegalStateException if the allowlist is not enabled
473473
*/
474-
void addWhitelistPattern(String urlPattern);
474+
void addAllowlistPattern(String urlPattern);
475475

476476
/**
477-
* Enables the whitelist, but with no matching URLs. All requests will generated the specified HTTP statusCode.
477+
* Enables the allowlist, but with no matching URLs. All requests will generated the specified HTTP statusCode.
478478
*
479479
* @param statusCode HTTP status code to return to clients on all requests
480480
*/
481-
void enableEmptyWhitelist(int statusCode);
481+
void enableEmptyAllowlist(int statusCode);
482482

483483
/**
484-
* Clears any existing whitelist and disables whitelisting.
484+
* Clears any existing allowlist and disables allowlisting.
485485
*/
486-
void disableWhitelist();
486+
void disableAllowlist();
487487

488488
/**
489-
* Returns the URL-matching regular expressions currently in effect. If the whitelist is disabled, this method always returns an empty collection.
490-
* If the whitelist is enabled but empty, this method return an empty collection.
489+
* Returns the URL-matching regular expressions currently in effect. If the allowlist is disabled, this method always returns an empty collection.
490+
* If the allowlist is enabled but empty, this method return an empty collection.
491491
*
492-
* @return whitelist currently in effect, or an empty collection if the whitelist is disabled or empty
492+
* @return allowlist currently in effect, or an empty collection if the allowlist is disabled or empty
493493
*/
494-
Collection<String> getWhitelistUrls();
494+
Collection<String> getAllowlistUrls();
495495

496496
/**
497-
* Returns the status code returned for all URLs that do not match the whitelist. If the whitelist is not currently enabled, returns -1.
497+
* Returns the status code returned for all URLs that do not match the allowlist. If the allowlist is not currently enabled, returns -1.
498498
*
499-
* @return HTTP status code returned for non-whitelisted URLs, or -1 if the whitelist is disabled.
499+
* @return HTTP status code returned for non-allowlisted URLs, or -1 if the allowlist is disabled.
500500
*/
501-
int getWhitelistStatusCode();
501+
int getAllowlistStatusCode();
502502

503503
/**
504-
* Returns true if the whitelist is enabled, otherwise false.
505-
* @return is WhitelistEnabled
504+
* Returns true if the allowlist is enabled, otherwise false.
505+
* @return is AllowlistEnabled
506506
*/
507-
boolean isWhitelistEnabled();
507+
boolean isAllowlistEnabled();
508508

509509
/**
510510
* Adds the specified HTTP headers to every request. Replaces any existing additional headers with the specified headers.

0 commit comments

Comments
 (0)