feat(ssh-wrapper): added pre/post pull hooks on top of git for ssh backend.

- this makes it consistent with the http backend and actually adds audit logging into the ssh pulls for git
This commit is contained in:
RhodeCode Admin 2024-02-15 19:58:58 +01:00
parent 1712cb1d49
commit 034377cec3
2 changed files with 18 additions and 3 deletions

View file

@ -118,6 +118,7 @@ class VcsServer(object):
if extras:
scm_data.update(extras)
os.putenv("RC_SCM_DATA", json.dumps(scm_data))
return scm_data
def get_root_store(self):
root_store = self.store

View file

@ -16,10 +16,11 @@
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import os
import sys
import logging
import subprocess
from vcsserver import hooks
from .base import VcsServer
log = logging.getLogger(__name__)
@ -50,9 +51,22 @@ class GitTunnelWrapper(object):
if exit_code:
return exit_code
self.server.update_environment(action=action, extras=extras)
scm_extras = self.server.update_environment(action=action, extras=extras)
hook_response = hooks.git_pre_pull(scm_extras)
pre_pull_messages = hook_response.output
sys.stdout.write(pre_pull_messages)
self.create_hooks_env()
return os.system(self.command())
result = subprocess.run(self.command(), shell=True)
result = result.returncode
# Upload-pack == clone
if action == "pull":
hook_response = hooks.git_post_pull(scm_extras)
post_pull_messages = hook_response.output
sys.stderr.write(post_pull_messages)
return result
class GitServer(VcsServer):