mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Add an option to grab the latest release candidate or stable which is intended to be used on dev servers to stage production.
This commit is contained in:
parent
98982e2962
commit
972e46825c
@ -48,13 +48,13 @@ else {
|
|||||||
|
|
||||||
my @fetched = ();
|
my @fetched = ();
|
||||||
my %opt = ();
|
my %opt = ();
|
||||||
getopts('c:r:p:s:v:t:e:f:EuS:D:R:U:F:ldh', \%opt);
|
getopts('c:r:p:s:v:t:e:f:EuS:D:R:U:F:L:ldh', \%opt);
|
||||||
|
|
||||||
usage(1) if(defined $opt{h});
|
usage(1) if(defined $opt{h});
|
||||||
usage(1) if(@ARGV > 1);
|
usage(1) if(@ARGV > 1);
|
||||||
|
|
||||||
# Make sure we have an action
|
# Make sure we have an action
|
||||||
if (! grep { defined } @opt{qw(S D R U F l)}) {
|
if (! grep { defined } @opt{qw(S D R U F L l)}) {
|
||||||
usage(1, "Action required.");
|
usage(1, "Action required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,13 +344,14 @@ sub ruleset_unpack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub ruleset_fetch_latest {
|
sub ruleset_fetch_latest {
|
||||||
my($repo, $type) = @_;
|
my($repo, @type) = @_;
|
||||||
my @versions = ruleset_available_versions($repo);
|
my @versions = ruleset_available_versions($repo);
|
||||||
my $verre = defined($opt{v}) ? qr/^$opt{v}/ : qr/^/;
|
my $verre = defined($opt{v}) ? qr/^$opt{v}/ : qr/^/;
|
||||||
my $typere = undef;
|
my $typere = undef;
|
||||||
|
|
||||||
# Figure out what to look for
|
# Figure out what to look for
|
||||||
if (defined($type) and $type ne "") {
|
if (@type == 1 and $type[0] ne "") {
|
||||||
|
my $type = $type[0];
|
||||||
if ($type eq "UNSTABLE") {
|
if ($type eq "UNSTABLE") {
|
||||||
$typere = qr/\d-\D+\d+$/;
|
$typere = qr/\d-\D+\d+$/;
|
||||||
}
|
}
|
||||||
@ -358,9 +359,32 @@ sub ruleset_fetch_latest {
|
|||||||
$typere = qr/\d-$type\d+$/;
|
$typere = qr/\d-$type\d+$/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif (defined($type)) {
|
elsif (@type > 1) {
|
||||||
qr/\.\d+$/;
|
my $type;
|
||||||
}
|
for (@type) {
|
||||||
|
if ($_ eq "") {
|
||||||
|
$type .= ($type?"|":"").qr/\.\d+$/;
|
||||||
|
}
|
||||||
|
elsif ($_ eq "UNSTABLE") {
|
||||||
|
$type .= ($type?"|":"").qr/\d-\D+\d+$/;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$type .= ($type?"|":"").qr/\d-$_\d+$/;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$typere = qr/$type/;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$typere = qr/\.\d+$/;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($opt{d}) {
|
||||||
|
print STDERR "REPO: $repo\n";
|
||||||
|
print STDERR "TYPES: ".join(", ", @type)."\n";
|
||||||
|
print STDERR "VERSIONS: ".join(", ", @versions)."\n";
|
||||||
|
print STDERR "REGEX: version=$opt{v} type=$typere\n";
|
||||||
|
}
|
||||||
|
|
||||||
while (@versions) {
|
while (@versions) {
|
||||||
my $last = pop(@versions);
|
my $last = pop(@versions);
|
||||||
@ -373,7 +397,7 @@ sub ruleset_fetch_latest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
die "No $type ruleset found.\n";
|
die "No '".join("' or '", @type)."' ruleset found.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub notify_email {
|
sub notify_email {
|
||||||
@ -437,6 +461,8 @@ elsif (defined($opt{D})) { ruleset_fetch_latest($opt{D}, "dev") }
|
|||||||
elsif (defined($opt{R})) { ruleset_fetch_latest($opt{R}, "rc") }
|
elsif (defined($opt{R})) { ruleset_fetch_latest($opt{R}, "rc") }
|
||||||
# Latest unstable
|
# Latest unstable
|
||||||
elsif (defined($opt{U})) { ruleset_fetch_latest($opt{U}, "UNSTABLE") }
|
elsif (defined($opt{U})) { ruleset_fetch_latest($opt{U}, "UNSTABLE") }
|
||||||
|
# Latest release candidate or stable
|
||||||
|
elsif (defined($opt{L})) { ruleset_fetch_latest($opt{R}, "rc", "") }
|
||||||
# Latest (any type)
|
# Latest (any type)
|
||||||
elsif (defined($opt{F})) { ruleset_fetch_latest($opt{F}, undef) }
|
elsif (defined($opt{F})) { ruleset_fetch_latest($opt{F}, undef) }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user