Skip to content

Commit

Permalink
adding raw_url and updating px_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ori-gold-px committed Nov 16, 2023
1 parent af46196 commit bab98d7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions perimeterx/px_activities_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def send_to_perimeterx(activity_type, ctx, config, detail):
'client_uuid': ctx.uuid,
'request_id': ctx.request_id
}
if ctx.raw_url:
_details['raw_url'] = ctx.raw_url

if len(detail.keys()) > 0:
_details = dict(list(_details.items()) + list(detail.items()))
Expand Down
3 changes: 3 additions & 0 deletions perimeterx/px_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ def prepare_risk_body(ctx, config):
logger.debug('attaching px_cookie to request')
body['additional']['px_cookie'] = ctx.decoded_cookie

if ctx.raw_url:
body['additional']['raw_url'] = ctx.raw_url

return body


Expand Down
11 changes: 11 additions & 0 deletions perimeterx/px_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def __init__(self, request, config):
else:
uri = request.path
full_url = request.url

raw_url = request.url if request.url != full_url else None
hostname = request.host
is_filtered = is_filtered_request(config, request)
sensitive_route = sum(1 for _ in filter(lambda sensitive_route_item: re.match(sensitive_route_item, uri), config.sensitive_routes_regex)) > 0 or sum(1 for _ in filter(lambda sensitive_route_item: uri == sensitive_route_item, config.sensitive_routes)) > 0
Expand All @@ -79,6 +81,7 @@ def __init__(self, request, config):
self._user_agent = user_agent
self._full_url = full_url
self._uri = uri
self._raw_url = raw_url
self._hostname = hostname
self._px_cookies = px_cookies
self._cookie_names = request_cookie_names
Expand Down Expand Up @@ -215,6 +218,14 @@ def uri(self):
def uri(self, uri):
self._uri = uri

@property
def raw_url(self):
return self._raw_url

@raw_url.setter
def raw_url(self, raw_url):
self._raw_url = raw_url

@property
def hostname(self):
return self._hostname
Expand Down
3 changes: 2 additions & 1 deletion px_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"vid_extraction"
],
"excluded_tests": [
"test_url_decode_reserved_characters_with_character\\[;-"
"test_url_decode_reserved_characters_send_decoded_url\\[;-",
"test_url_decode_reserved_characters_send_additional_raw_url\\[(/|:)-"
]
}

0 comments on commit bab98d7

Please sign in to comment.