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

Added linter to pipeline #37

Merged
merged 4 commits into from
Dec 19, 2023
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
16 changes: 16 additions & 0 deletions .github/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Linter / Perl Critic

on:
pull_request:
branches:
- main

jobs:
critic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Perl::Critic
uses: natanlao/[email protected]
with:
files: critic
2 changes: 2 additions & 0 deletions .perlcriticrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
only = 1
include = ProhibitUnusedVariables ProhibitUnusedConstant ProhibitUnusedInclude ProhibitUnusedImport ProhibitUnreachableCode ProhibitComplexRegexes ProhibitDuplicatedSub ProhibitDuplicateHashKeys ProhibitUnusedPrivateSubroutines ProhibitUnlessBlocks ProhibitExcessiveColons ProhibitExplicitReturnUndef RequireCamelCase ProhibitMagicNumbers ProhibitTrailingWhitespace ProhibitHardTabs
10 changes: 5 additions & 5 deletions lib/Engine/Fuzzer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ package Engine::Fuzzer {
my ($self, $timeout, $headers, $skipssl, $content) = @_;

my $userAgent = Mojo::UserAgent -> new() -> request_timeout($timeout) -> insecure($skipssl);
bless {

bless {
useragent => $userAgent,
headers => $headers
headers => $headers
}, $self;
}

sub request {
my ($self, $method, $agent, $endpoint, $payload, $accept) = @_;

my $request = $self -> {useragent} -> build_tx (
$method => $endpoint => {
"User-Agent" => $agent,
%{$self -> {headers}}
} => $payload || ""
);

try {
my $response = $self -> {useragent} -> start($request) -> result();

Expand Down
14 changes: 7 additions & 7 deletions lib/Engine/FuzzerThread.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ package Engine::FuzzerThread {

sub new {
my (
$self, $queue, $target, $methods, $agent, $headers, $accept,
$self, $queue, $target, $methods, $agent, $headers, $accept,
$timeout, $return, $payload, $json, $delay, $exclude, $skipssl,
$length, $content, $dir_callback
) = @_;

my @verbs = split (/,/, $methods);
my @valid_codes = split /,/, $return || "";
my @invalid_codes = split /,/, $exclude || "";

my $fuzzer = Engine::Fuzzer -> new($timeout, $headers, $skipssl);
my $format = JSON -> new() -> allow_nonref() -> pretty();

my $cmp;

if ($length) {
Expand All @@ -36,12 +36,12 @@ package Engine::FuzzerThread {
while (defined(my $resource = $queue -> dequeue())) {
my $endpoint = $target . $resource;
my $found = 0;

for my $verb (@verbs) {
my $result = $fuzzer -> request($verb, $agent, $endpoint, $payload, $accept);

next unless $result;

my $status = $result -> {Code};

next if grep(/^$status$/, @invalid_codes) || ($return && !grep(/^$status$/, @valid_codes));
Expand Down
14 changes: 7 additions & 7 deletions lib/Engine/Orchestrator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ package Engine::Orchestrator {

sub fill_queue {
my ($list, $number) = @_;

for (1 .. $number) {
return unless (@{$list} > 0);

if (eof($list -> [0])) {
close shift @{$list};

(@{$list} > 0) || $wordlist_queue -> end();

next
}

my $filehandle = $list -> [0];

chomp(my $line = <$filehandle>);
Expand All @@ -36,7 +36,7 @@ package Engine::Orchestrator {
$target .= "/" unless $target =~ /\/$/;

lock(@targets_queue);

push @targets_queue, $target;
}
}
Expand All @@ -50,7 +50,7 @@ package Engine::Orchestrator {
lock(@targets_queue);
$target = shift @targets_queue;
}

$self -> threaded_fuzz($target, %options);
}
}
Expand All @@ -60,10 +60,10 @@ package Engine::Orchestrator {

my @current = map {
open(my $filehandle, "<$_") || die "$0: Can't open $_: $!";

$filehandle
} glob($options{wordlist});

$wordlist_queue = Thread::Queue -> new();

fill_queue(\@current, 10 * $options{tasks});
Expand Down
2 changes: 1 addition & 1 deletion lib/Functions/Parser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Functions::Parser {
use warnings;
use YAML::Tiny;

sub new {
sub new {
my ($self, $workflow) = @_;

if ($workflow) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Functions/Plugins.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package Functions::Plugins {

sub new {
my ($self) = @_;

if ($self) {
print "Hello World!\n";

return 1;
}

return 0;
}
}
Expand Down
17 changes: 8 additions & 9 deletions nozaki.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
use Getopt::Long qw(:config no_ignore_case);

sub main {
my ($workflow, $plugin, @targets);
my ($workflow, @targets);

my %options = (
accept => "*/*",
accept => "*/*",
wordlist => "wordlists/default.txt",
method => "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH,PUSH",
headers => {},
Expand All @@ -25,7 +25,7 @@ sub main {
delay => 0,
);

Getopt::Long::GetOptions (
Getopt::Long::GetOptions (
"A|accept=s" => \$options{accept},
"a|agent=s" => \$options{agent},
"c|content=s" => \$options{content},
Expand All @@ -34,20 +34,19 @@ sub main {
"H|header=s%" => \$options{headers},
"w|wordlist=s" => \$options{wordlist},
"W|workflow=s" => \$workflow,
"m|method=s" => \$options{method},
"m|method=s" => \$options{method},
"r|return=s" => \$options{return},
"p|payload=s" => \$options{payload},
"j|json" => \$options{json},
"S|skip-ssl" => \$options{skipssl},
"T|tasks=i" => \$options{tasks},
"t|timeout=i" => \$options{timeout},
"u|url=s@" => \@targets,
"l|length=s" => \$options{length},
"p|plugin=s" => \$options{plugin}
"l|length=s" => \$options{length}
);

return Functions::Helper -> new() unless @targets;

if ($workflow) {
my $rules = Functions::Parser -> new($workflow);

Expand All @@ -57,7 +56,7 @@ sub main {
Engine::Orchestrator::add_target(@targets);

map { $new_options{$_} = $rule -> {$_} || 1 } keys %{$rule};

Engine::Orchestrator -> run_fuzzer(%new_options);
}

Expand All @@ -67,6 +66,6 @@ sub main {
Engine::Orchestrator::add_target(@targets);

return Engine::Orchestrator -> run_fuzzer (%options);
}
}

exit main() unless caller;
2 changes: 1 addition & 1 deletion plugins/encode/base64.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Encode::Base64 {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/seeds/BurpSuite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Seeds::BurpSuite {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/seeds/openapi.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Seeds::OpenAPI {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/seeds/passive_collect.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Seeds::Passive_Collect {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/seeds/robots.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Seeds::Robots {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/seeds/scraping.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Seeds::Scraping {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/seeds/sitemap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Seeds::Sitemap {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/seeds/swagger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Seeds::Swagger {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/seeds/waybackurls.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Seeds::WatBackUrls {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/seeds/zap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Plugins::Seeds::ZAP {

sub new {
my ($self, @params) = @_;

return 1;
}
}
Expand Down