Skip to content

Commit

Permalink
Merge pull request #14 from instriq/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
htrgouvea authored Dec 25, 2024
2 parents e35a45b + a56d541 commit 080b32a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Linter

on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/zarn.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: ZARN SAST

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]
schedule:
- cron: '28 23 * * 1'

jobs:
zarn:
Expand Down
2 changes: 1 addition & 1 deletion .perlcriticrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
severity = 2
severity = 3

[-TestingAndDebugging::RequireUseStrict]
[-TestingAndDebugging::RequireUseWarnings]
Expand Down
2 changes: 1 addition & 1 deletion cpanfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
requires "Getopt::Long", "2.54";
requires "Mojo::UserAgent";
requires "Mojo::JSON";
requires "JSON";
requires "DateTime";
requires "DateTime::Format::ISO8601";

Expand Down
11 changes: 5 additions & 6 deletions lib/Sentra/Engine/DependabotMetrics.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ package Sentra::Engine::DependabotMetrics {
my $userAgent = Sentra::Utils::UserAgent -> new($token);
my @repositories_list = Sentra::Utils::Repositories_List -> new($org, $token);

my $output = "";
my $total_alerts = 0;

my $output = "";
my $total_alerts = 0;
my %severity_count = (
low => 0,
medium => 0,
high => 0,
low => 0,
medium => 0,
high => 0,
critical => 0
);

Expand Down
17 changes: 10 additions & 7 deletions lib/Sentra/Engine/SearchFiles.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ package Sentra::Engine::SearchFiles {
my $output = '';
my $userAgent = Sentra::Utils::UserAgent -> new($token);
my @repositories_list = Sentra::Utils::Repositories_List -> new($org, $token);

my @files = (".github/dependabot.yml");

foreach my $repository (@repositories_list) {
my $dependabot_url = "https://api.github.com/repos/$repository/contents/.github/dependabot.yaml";
my $request = $userAgent -> get($dependabot_url);

if ($request -> code == 404) {
$output .= "The dependabot.yml file was not found in this repository: https://github.com/$repository\n";
}
foreach my $file (@files) {
my $dependabot_url = "https://api.github.com/repos/$repository/contents/$file";
my $request = $userAgent -> get($dependabot_url);

if ($request -> code == 404) {
$output .= "The $file file was not found in this repository: https://github.com/$repository\n";
}
}
}

return $output;
Expand Down
4 changes: 2 additions & 2 deletions lib/Sentra/Engine/SlackWebhook.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package Sentra::Engine::SlackWebhook {
use strict;
use warnings;
use Mojo::UserAgent;
use Mojo::JSON qw(encode_json);
use JSON;

sub new {
my ($class, $message, $webhook) = @_;

my $userAgent = Mojo::UserAgent -> new();
my $payload = encode_json({text => $message});
my $payload = encode_json({ text => $message });

my $text = $userAgent -> post($webhook => {
'Content-Type' => 'application/json'
Expand Down
28 changes: 15 additions & 13 deletions lib/Sentra/Utils/Helper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ package Sentra::Utils::Helper {
use warnings;

sub new {
return "
\rSentra v0.0.3
\rCore Commands
\r==============
\r\tCommand Description
\r\t------- -----------
\r\t-o, --org Specify the name of the organization
\r\t-t, --token Set the GitHub Token to use during actions
\r\t-mt, --maintained Get alerts about repositories with a last commit date greater than 90 days old
\r\t-d, --dependency Check if repositories has dependabot.yaml file
\r\t-M, --metrics See some metrics based on GHAS
\r\t-w, --webhook Set the webhook address for Slack
\r\t-m, --message Message to send via Slack webhook\n\n";
return join("\n",
"Sentra v0.0.3",
"Core Commands",
" ==============",
" Command Description",
" ------- -----------",
" -o, --org Specify the name of the organization",
" -t, --token Set the GitHub Token to use during actions",
" -mt, --maintained Get alerts about repositories with a last commit date greater than 90 days old",
" -d, --dependency Check if repositories has dependabot.yaml file",
" -M, --metrics See some metrics based on GHAS",
" -w, --webhook Set the webhook address for Slack",
" -m, --message Message to send via Slack webhook",
""
);
}
}

Expand Down
6 changes: 5 additions & 1 deletion sentra.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ sub main {
}

if ($webhook && $message) {
return Sentra::Engine::SlackWebhook -> new($message, $webhook) -> send();
my $send = Sentra::Engine::SlackWebhook -> new($message, $webhook);

if ($send) {
return 0;
}
}

if ($help) {
Expand Down

0 comments on commit 080b32a

Please sign in to comment.