From 642a07ded5aa9f1d95a590202d991958a1effc3a Mon Sep 17 00:00:00 2001 From: Torsten Steinbach Date: Mon, 20 Nov 2023 18:04:52 +0100 Subject: [PATCH] Fixed prefix matching --- cosaccess/cosaccess/__init__.py | 2 +- cosaccess/cosaccess/cosaccess.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cosaccess/cosaccess/__init__.py b/cosaccess/cosaccess/__init__.py index be6c9b5..700d82c 100644 --- a/cosaccess/cosaccess/__init__.py +++ b/cosaccess/cosaccess/__init__.py @@ -14,6 +14,6 @@ # limitations under the License. # ------------------------------------------------------------------------------ -__version__ = "0.1.6" +__version__ = "0.1.7" # flake8: noqa F401 from .cosaccess import CosAccessManager diff --git a/cosaccess/cosaccess/cosaccess.py b/cosaccess/cosaccess/cosaccess.py index 6714692..8c6b925 100644 --- a/cosaccess/cosaccess/cosaccess.py +++ b/cosaccess/cosaccess/cosaccess.py @@ -187,8 +187,9 @@ def list_policies_for_cos_bucket(self, cosBucket: str = None, prefix: str = None else: conditions = condition["value"] for condition in conditions: - # For Python regex we need to escape literal dots in the condition string and replace asterisk with dot - condition_expression = re.compile(condition.replace(".", "\\.").replace("*", ".")) + # For Python regex we need to escape literal dots in the condition string and + # then replace asterisk with dot + asterisk (zero or more of any character) + condition_expression = re.compile(condition.replace(".", "\\.").replace("*", ".")+"*") if condition_expression.match(prefix): policies.append(bucket_policy) break