Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #14

Merged
merged 9 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading