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

CRAYSAT-1913: Remove the ability to read VCS password from a file #44

Merged
merged 1 commit into from
Oct 21, 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.3] - 2024-10-14

### Fixed
- Remove the ability to read VCS password from a file which is no longer necessary.

## [2.2.2] - 2024-09-26

### Fixed
Expand Down
21 changes: 4 additions & 17 deletions csm_api_client/service/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,11 @@ def vcs_creds_helper() -> Generator[Dict[str, str], None, None]:
set to the path to the script for obtaining VCS credentials.
"""
# Get the password directly from k8s to avoid leaking it via the /proc filesystem
password_file_path = '/tmp/vcs_passwd'

try:
if os.path.exists(password_file_path):
# If the file exists, create a script that cats the file
with NamedTemporaryFile(delete=False) as cred_helper_script:
cred_helper_script.write((
'#!/bin/bash\n'
'cat {password_file}\n'.format(password_file=password_file_path).encode()
))
os.system(f'echo "{password_file_path}"')
os.system(f'cat "{password_file_path}"')
else:
# If the file doesn't exist, create a script to fetch from Kubernetes
with NamedTemporaryFile(delete=False) as cred_helper_script:
cred_helper_script.write('#!/bin/bash\n'
'kubectl get secret -n services vcs-user-credentials '
'--template={{.data.vcs_password}} | base64 -d'.encode())
with NamedTemporaryFile(delete=False) as cred_helper_script:
cred_helper_script.write('#!/bin/bash\n'
'kubectl get secret -n services vcs-user-credentials '
'--template={{.data.vcs_password}} | base64 -d'.encode())

os.chmod(cred_helper_script.name, 0o700) # Make executable by user
env = dict(os.environ)
Expand Down
Loading
Loading