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

Fix the secrets stripping for HTTP endpoints upload #58

Merged
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
13 changes: 13 additions & 0 deletions calm/dsl/api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def strip_secrets(resources, secret_map, secret_variables, object_lists=[], obje
"name": default_creds[0]["name"] if default_creds else cred[0]["name"],
}

# Remove creds from HTTP endpoints resources
auth = resources.get("authentication", {}) or {}
if auth.get("type", None) == "basic":
name = auth["username"]
secret_map[name] = auth.pop("password", {})
auth["password"] = {'attrs': {'is_secret_modified': False, 'value': None}}

# Strip secret variable values
# TODO: Refactor and/or clean this up later

Expand Down Expand Up @@ -182,6 +189,12 @@ def patch_secrets(resources, secret_map, secret_variables):
name = cred["name"]
cred["secret"] = secret_map[name]

# Add creds back for HTTP endpoint
auth = resources.get("authentication", {})
username = auth.get("username")
if username:
auth["password"] = secret_map[username]

for path, secret in secret_variables:
variable = resources
for sub_path in path:
Expand Down