Archived
1
0
Fork 0

Check IP before submission

This commit is contained in:
Mercier Pierre-Olivier 2013-09-19 04:52:29 +02:00
parent 188931f0d4
commit 9038f49904
3 changed files with 70 additions and 19 deletions

View file

@ -28,14 +28,26 @@ if ($ref =~ m<^refs/tags/(.+)$>)
log DEBUG, "Pushed tag for repository $ENV{GL_REPO}: $tag with IP $ENV{'SSH_CLIENT'}";
my $ip = $1 if ($ENV{'SSH_CLIENT'} =~ m/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/);
say "[ACU] Your IP is: $ENV{'SSH_CLIENT'}.";
say "[ACU] Your IP is: $ip.";
$ip = ip2long($ip);
my $net = ip2long("10.41.0.0");
my $mask = ip2long("255.255.0.0");
if (($ip & $mask) != ($net & $mask))
{
log ERROR, "[ACU] You are not authorized to push from this IP. This will be reported.";
exit 1;
}
# Get project informations
my $project;
eval {
$project = API::Projects::get($id_project, $promo);
};
if ($@ or !$project) {
if ($@ or !$project)
{
my $err = $@;
log TRACE, $err;
log ERROR, "Impossible d'envoyer de tags ; si le problème persiste, passez au laboratoire.";