Skip to content

Commit

Permalink
don't deleted secret if used as sshkey
Browse files Browse the repository at this point in the history
  • Loading branch information
ib-steffen committed Feb 25, 2019
1 parent 3f28b3d commit 213d061
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/api/handlers/projects/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ def delete(self, project_id, secret_id):
if num_secrets == 0:
return abort(400, 'Such secret does not exist.')

num_keys = g.db.execute_one("""
SELECT COUNT(*) FROM sshkey
WHERE project_id = %s and secret_id = %s
""", [project_id, secret_id])[0]

if num_keys == 0:
return abort(400, 'Secret is still used SSH Key.')

g.db.execute("""
DELETE FROM secret WHERE project_id = %s and id = %s
""", [project_id, secret_id])
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/kubernetes/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def kube_job(self, job_id, cpu, mem, services=None):
cursor.close()

for r in result:
private_key += '\n%s' decrypt_secret(r[0])
private_key += '\n%s' % decrypt_secret(r[0])

if private_key:
env += [{
Expand Down

0 comments on commit 213d061

Please sign in to comment.