Skip to content

Commit

Permalink
Fixed prefix matching
Browse files Browse the repository at this point in the history
Torsten Steinbach committed Nov 20, 2023
1 parent e9b51ef commit 642a07d
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cosaccess/cosaccess/__init__.py
Original file line number Diff line number Diff line change
@@ -14,6 +14,6 @@
# limitations under the License.
# ------------------------------------------------------------------------------

__version__ = "0.1.6"
__version__ = "0.1.7"
# flake8: noqa F401
from .cosaccess import CosAccessManager
5 changes: 3 additions & 2 deletions cosaccess/cosaccess/cosaccess.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 642a07d

Please sign in to comment.