Github user zwoop commented on a diff in the pull request:
https://github.com/apache/trafficserver/pull/747#discussion_r69205590
--- Diff: plugins/experimental/remap_purge/remap_purge.c ---
@@ -202,34 +202,38 @@ handle_purge(TSHttpTxn txnp, PurgeInstance *purge)
bool should_purge = false;
if (TS_SUCCESS == TSHttpTxnClientReqGet(txnp, &reqp, &hdr_loc)) {
- /* First see if we require the "secret" to be passed in a header, and
then use that */
- if (purge->header) {
- TSMLoc field_loc = TSMimeHdrFieldFind(reqp, hdr_loc, purge->header,
purge->header_len);
-
- if (field_loc) {
- const char *header;
- int header_len;
-
- header = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field_loc,
-1, &header_len);
- TSDebug(PLUGIN_NAME, "Checking for %.*s == %s ?", header_len,
header, purge->secret);
- if (header && (header_len == purge->secret_len) && !memcmp(header,
purge->secret, header_len)) {
- should_purge = true;
+ int method_len = 0;
+ const char *method = TSHttpHdrMethodGet(reqp, hdr_loc, &method_len);
+
+ if ((TS_HTTP_METHOD_PURGE == method) || ((TS_HTTP_METHOD_GET ==
method) && purge->allow_get)) {
+ /* First see if we require the "secret" to be passed in a header,
and then use that */
+ if (purge->header) {
+ TSMLoc field_loc = TSMimeHdrFieldFind(reqp, hdr_loc,
purge->header, purge->header_len);
+
+ if (field_loc) {
+ const char *header;
+ int header_len;
+
+ header = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field_loc,
-1, &header_len);
+ TSDebug(PLUGIN_NAME, "Checking for %.*s == %s ?", header_len,
header, purge->secret);
+ if (header && (header_len == purge->secret_len) &&
!memcmp(header, purge->secret, header_len)) {
+ should_purge = true;
+ }
+ TSHandleMLocRelease(reqp, hdr_loc, field_loc);
}
- TSHandleMLocRelease(reqp, hdr_loc, field_loc);
- }
- } else {
- /* We are matching on the path component instead of a header */
- if (TS_SUCCESS == TSHttpHdrUrlGet(reqp, hdr_loc, &url_loc)) {
- int path_len = 0, method_len = 0;
- const char *path = TSUrlPathGet(reqp, url_loc, &path_len);
- const char *method = TSHttpHdrMethodGet(reqp, hdr_loc,
&method_len);
-
- TSDebug(PLUGIN_NAME, "Checking PATH = %.*s", path_len, path);
- if (((TS_HTTP_METHOD_PURGE == method) || ((TS_HTTP_METHOD_GET ==
method) && purge->allow_get)) && path &&
- (path_len >= purge->secret_len) && !memcmp(path + (path_len -
purge->secret_len), purge->secret, purge->secret_len)) {
- should_purge = true;
+ } else {
+ /* We are matching on the path component instead of a header */
+ if (TS_SUCCESS == TSHttpHdrUrlGet(reqp, hdr_loc, &url_loc)) {
+ int path_len = 0;
+ const char *path = TSUrlPathGet(reqp, url_loc, &path_len);
+
+ TSDebug(PLUGIN_NAME, "Checking PATH = %.*s", path_len, path);
+ if (path && (path_len >= purge->secret_len) &&
+ !memcmp(path + (path_len - purge->secret_len),
purge->secret, purge->secret_len)) {
--- End diff --
Don't think that would work, then you couldn't use this to purge a remap
rule like
map http://example.com http://real.example.com
At least not without modifying the path, or, taking that into account (i.e.
a separate case for this situation). Is it really worth that complexity? I sort
of envisioned people to pick pretty strong secrets here, e.g. genuuid.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---