Check IP before submission
This commit is contained in:
parent
188931f0d4
commit
9038f49904
3 changed files with 70 additions and 19 deletions
|
@ -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.";
|
||||
|
|
Reference in a new issue