Skip to content

Commit

Permalink
fixed update status issue and no regex criteria issue (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
HzANut authored Sep 8, 2022
1 parent 99b8f95 commit 1c741c3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion moesifdjango/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, get_response):
# below comment for setting moesif base_uri to a test server.
if self.middleware_settings.get('LOCAL_DEBUG', False):
Configuration.BASE_URI = self.get_configuration_uri(self.middleware_settings, 'BASE_URI', 'LOCAL_MOESIF_BASEURL')
Configuration.version = 'moesifdjango-python/2.1.3'
Configuration.version = 'moesifdjango-python/2.1.4'
if settings.MOESIF_MIDDLEWARE.get('CAPTURE_OUTGOING_REQUESTS', False):
try:
if self.DEBUG:
Expand Down Expand Up @@ -270,6 +270,7 @@ def __call__(self, request):
self.LOG_BODY,
self.middleware_settings)

response.status_code = updated_Response.block_response_status
event_rsp = self.event_mapper.to_response(rsp_time, updated_Response.block_response_status,
updated_Response.block_response_headers, rsp_body,
rsp_body_transfer_encoding)
Expand Down
2 changes: 1 addition & 1 deletion moesifdjango/middleware_pre19.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self):
# below comment for setting moesif base_uri to a test server.
if self.middleware_settings.get('LOCAL_DEBUG', False):
Configuration.BASE_URI = self.get_configuration_uri(self.middleware_settings, 'BASE_URI', 'LOCAL_MOESIF_BASEURL')
Configuration.version = 'moesifdjango-python/2.1.3'
Configuration.version = 'moesifdjango-python/2.1.4'
if settings.MOESIF_MIDDLEWARE.get('CAPTURE_OUTGOING_REQUESTS', False):
try:
if self.DEBUG:
Expand Down
9 changes: 5 additions & 4 deletions moesifdjango/moesif_gov.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ def block_request_based_on_entity_governance_rule(self,

governance_rule = governance_rules.get(rule_id, None)

if not governance_rule or 'response' not in governance_rule or 'status' not in governance_rule['response'] \
or 'headers' not in governance_rule['response']:
if not governance_rule or 'response' not in governance_rule or 'status' not in governance_rule['response']:
if DEBUG:
print(
'[moesif] Skipped blocking request as governance rule response is not set for the entity Id - ',
Expand All @@ -343,8 +342,10 @@ def block_request_based_on_entity_governance_rule(self,
if "regex_config" in governance_rule and governance_rule["regex_config"]:
gr_regex_configs = governance_rule["regex_config"]

matched = self.check_event_matched_with_governance_rules(gr_regex_configs, request_mapping_for_regex_config,
ready_for_body_request)
matched = not gr_regex_configs or self.check_event_matched_with_governance_rules(
gr_regex_configs,
request_mapping_for_regex_config,
ready_for_body_request)

if not matched:
if DEBUG:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='2.1.3',
version='2.1.4',

description='Moesif Middleware for Python Django',
long_description=long_description,
Expand Down

0 comments on commit 1c741c3

Please sign in to comment.