Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1-lib: fix $ escaping #756

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 5 additions & 16 deletions library/1.1.4/utils.py → library/1.1.5/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ def basic_auth_header(username, password):
return f"Basic {security.basic_auth(username, password)}"


def bcrypt_hash(password, escape=True):
hashed = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8")
if escape:
# Docker compose will try to expand the value, so we need to escape it
return hashed.replace("$", "$$")
return hashed
def bcrypt_hash(password):
return bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8")


def match_regex(value, regex):
Expand Down Expand Up @@ -88,9 +84,7 @@ def get_image(images={}, name=""):
if name not in images:
throw_error(f"Expected [images.{name}] to be set")
if not images[name].get("repository") or not images[name].get("tag"):
throw_error(
f"Expected [images.{name}.repository] and [images.{name}.tag] to be set"
)
throw_error(f"Expected [images.{name}.repository] and [images.{name}.tag] to be set")

return f"{images[name]['repository']}:{images[name]['tag']}"

Expand All @@ -109,13 +103,8 @@ def copy_dict(dict):
return dict.copy()


# Replaces all single dollar signs with double dollar signs
# Docker tries to expand shell variables, so we need to
# escape them in multiple places
# It will not replace dollar signs that are already escaped
def escape_dollar(text):
# https://regex101.com/r/tdbI7y/1
return re.sub(r"(?<!\$)\$(?!\$)", r"$$", text)
def escape_dollar(text: str) -> str:
return text.replace("$", "$$")


def auto_cast(value):
Expand Down
2 changes: 1 addition & 1 deletion library/hashes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
0.0.1: f074617a82a86d2a6cc78a4c8a4296fc9d168e456f12713e50c696557b302133
1.1.4: 6e32ff5969906d9c3a10fea2b17fdd3197afb052d3432344da03188d8a907113
1.1.5: 51332f2b032a0c473693458cd93daa96d56604241878e538c07cb85b8be66727
2.0.4: 0e79e3390d3ea73649ee2ac05a4af9ed944a02e95289b5c7e2eb047d475a4651
Loading