From 2547f822148819d9d11111787bf66263f8445c81 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 26 Oct 2022 12:31:46 +0200 Subject: [proxy] properly handle wildcard protocols in payloads patterns --- src/hydrilla/proxy/simple_dependency_satisfying.py | 11 ++++++++--- .../proxy/state_impl/_operations/recompute_dependencies.py | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/hydrilla/proxy') diff --git a/src/hydrilla/proxy/simple_dependency_satisfying.py b/src/hydrilla/proxy/simple_dependency_satisfying.py index ffe4d62..ba40a20 100644 --- a/src/hydrilla/proxy/simple_dependency_satisfying.py +++ b/src/hydrilla/proxy/simple_dependency_satisfying.py @@ -98,8 +98,7 @@ class MappingChoice: required: bool = False mapping_dependencies: t.Sequence[item_infos.MappingInfo] = () - payloads: dict[url_patterns.ParsedPattern, ComputedPayload] = \ - dc.field(default_factory=dict) + payloads: dict[str, ComputedPayload] = dc.field(default_factory=dict) MappingsGraph = t.Union[ @@ -238,7 +237,13 @@ class _ComputationData: failure = False + processed_patterns = set() + for pattern, resource_spec in choice.info.payloads.items(): + if pattern.orig_url in processed_patterns: + continue + processed_patterns.add(pattern.orig_url) + computed_payload = self._satisfy_payload_resource( mapping_identifier = choice.info.identifier, resource_identifier = resource_spec.identifier @@ -253,7 +258,7 @@ class _ComputationData: if choice.info.allows_cors_bypass: computed_payload.allows_cors_bypass = True - choice.payloads[pattern] = computed_payload + choice.payloads[pattern.orig_url] = computed_payload if not failure: choices[choice.info.identifier] = choice diff --git a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py index 399e20e..97f9de6 100644 --- a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py +++ b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py @@ -389,7 +389,7 @@ def _recompute_dependencies_no_state_update_no_pull_files( ''', ( mapping_ver_id, - pattern.orig_url, + pattern, payload.allows_eval, payload.allows_cors_bypass ) @@ -404,7 +404,7 @@ def _recompute_dependencies_no_state_update_no_pull_files( WHERE mapping_item_id = ? AND pattern = ?; ''', - (mapping_ver_id, pattern.orig_url) + (mapping_ver_id, pattern) ) (payload_id,), = cursor.fetchall() -- cgit v1.2.3