Skip to content

Commit

Permalink
fix identation and change some names of variables
Browse files Browse the repository at this point in the history
  • Loading branch information
htrgouvea committed Aug 23, 2024
1 parent 8f1ce34 commit 0fd039e
Showing 1 changed file with 43 additions and 36 deletions.
79 changes: 43 additions & 36 deletions security-gate.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,59 @@
use Getopt::Long;

sub main {
my ($token, $repository, $dependency_alerts, $secret_scanning_alerts, $code_scanning_alerts);
my %severity_limits = map {$_ => 0} @SEVERITIES;

Getopt::Long::GetOptions(
"t|token=s" => \$token,
"r|repo=s" => \$repository,
"c|critical=i" => \$severity_limits{critical},
"h|high=i" => \$severity_limits{high},
"m|medium=i" => \$severity_limits{medium},
"l|low=i" => \$severity_limits{low},
"dependency-alerts" => \$dependency_alerts,
"secret-scanning-alerts" => \$secret_scanning_alerts,
"code-scanning-alerts" => \$code_scanning_alerts
);

if ($token && $repository) {
my $result = 0;

my %alert_checks = (
'dependency-alerts' => sub { SecurityGate::Engine::Dependencies->new($token, $repository, \%severity_limits) },
'secret-scanning-alerts' => sub { SecurityGate::Engine::Secrets->new($token, $repository) },
'code-scanning-alerts' => sub { SecurityGate::Engine::CodeScanning->new($token, $repository, \%severity_limits) },
my ($token, $repository, $dependency_alerts, $secret_alerts, $code_alerts);
my %severity_limits = map {$_ => 0} @SEVERITIES;

Getopt::Long::GetOptions(
"t|token=s" => \$token,
"r|repo=s" => \$repository,
"c|critical=i" => \$severity_limits{critical},
"h|high=i" => \$severity_limits{high},
"m|medium=i" => \$severity_limits{medium},
"l|low=i" => \$severity_limits{low},
"dependency-alerts" => \$dependency_alerts,
"secret-alerts" => \$secret_alerts,
"code-alerts" => \$code_alerts
);

for my $alert_type (keys %alert_checks) {
if ($$alert_type) {
$result += $alert_checks{$alert_type}->();
}
}
if ($token && $repository) {
my $result = 0;

my %alert_checks = (
'dependency-alerts' => sub { SecurityGate::Engine::Dependencies->new($token, $repository, \%severity_limits) },
'secret-alerts' => sub { SecurityGate::Engine::Secrets->new($token, $repository) },
'code-alerts' => sub { SecurityGate::Engine::CodeScanning->new($token, $repository, \%severity_limits) }
);

return $result;
}
for my $alert_type (keys %alert_checks) {
if ($alert_type eq 'dependency-alerts' && $dependency_alerts) {
$result += $alert_checks{$alert_type}->();
}

else {
print SecurityGate::Utils::Helper->new();
elsif ($alert_type eq 'secret-alerts' && $secret_alerts) {
$result += $alert_checks{$alert_type}->();
}

elsif ($alert_type eq 'code-alerts' && $code_alerts) {
$result += $alert_checks{$alert_type}->();
}
}

return 1;
}
return $result;
}

else {
print SecurityGate::Utils::Helper->new();
return 1;
}

return 0;
return 0;
}

if ($ENV{TEST_MODE}) {
main();
main();
}

else {
exit main();
exit main();
}

0 comments on commit 0fd039e

Please sign in to comment.