Subversion:在预提交钩子中获取用户的ip地址? [英] Subversion: Get ip-address of user in pre-commit hook?

查看:171
本文介绍了Subversion:在预提交钩子中获取用户的ip地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在托管一个Subversion版本库,用于分布式软件开发.因此,非员工可以使用我们的某些代码.我们公司的IT安全政策要求我们对从公司Intranet外部上传的所有文件进行病毒扫描.所有内部计算机均配备了最新的病毒扫描程序.

We're hosting a subversion repository for distrubuted software development. So non-employees have access to some of our sorce code. Our company's IT security policy requires us to virusscan all files uploaded from outside of our corporate intranet. All internal computers are equipped with up to date virus scanners.

我们正计划将病毒扫描集成到Subversion预提交挂钩中.但这会导致执行大型提交时出现延迟.因此,我们只想扫描来自Intranet外部的提交.为了识别来源,我们需要执行提交的用户的IP地址.由于我们的一些员工在家工作,因此我们无法使用用户名来识别来自互联网的提交.

We're planning on integration the virus scan in a Subversion precommit-hook. But this causes delays when performing large commits. So we would like to scan only the commits, that are originated outside of our intranet. To identify the origin, we need the IP adress of the user performing the commit. Since some of our employees work from home we can't use the usernames to identify commits from the internet.

最后我的问题是

我如何获得在Subversion预提交挂钩中执行提交的IP地址?

How can I get the IP-adress from which a commit ist performed in a subversion precommit hook?

推荐答案

让我想象一下,您在Perl中编写了自己的钩子,在这种情况下,您可以使用以下lib:

Let me imagine that you write your hook in Perl, in that case, you can use the following lib : DocumentationClientIP

您可以通过以下链接从Git安装lib: GITClientIP (或使用随附的代码).

you can install the lib from Git thru this link : GITClientIP (or use the code included).

安装后,您需要在代码中添加类似内容:

After installation, you need to add something like that in your code :

    use SVN::Utils::ClientIP qw(ssh_client_ip);

    print "The client's IP address is ", ssh_client_ip();

这篇关于Subversion:在预提交钩子中获取用户的ip地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆