diff --git a/.github/workflows/zarn.yml b/.github/workflows/zarn.yml index ef58357..cf8981b 100644 --- a/.github/workflows/zarn.yml +++ b/.github/workflows/zarn.yml @@ -22,4 +22,4 @@ jobs: - name: Send result to Github Security uses: github/codeql-action/upload-sarif@v3 with: - sarif_file: result.sarif + sarif_file: result.sarif \ No newline at end of file diff --git a/.perlcriticrc b/.perlcriticrc index 745932b..9c89373 100644 --- a/.perlcriticrc +++ b/.perlcriticrc @@ -1,3 +1,5 @@ -severity = 5 + +severity = 4 [-TestingAndDebugging::RequireUseStrict] +[-TestingAndDebugging::RequireUseWarnings] diff --git a/Dockerfile b/Dockerfile index 5414b8f..14817e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,13 @@ -FROM perl:5.38 +FROM ubuntu:latest COPY . /usr/src/nipe WORKDIR /usr/src/nipe -RUN cpanm --installdeps . +EXPOSE 9050 + +RUN apt-get update && \ + apt-get install -y cpanminus && \ + rm -rf /var/lib/apt/lists/* -ENTRYPOINT [ "perl", "./nipe.pl" ] \ No newline at end of file +RUN cpanm --installdeps . +RUN perl nipe.pl install \ No newline at end of file diff --git a/lib/Nipe/Utils/Helper.pm b/lib/Nipe/Utils/Helper.pm index 9f668e7..82e900e 100644 --- a/lib/Nipe/Utils/Helper.pm +++ b/lib/Nipe/Utils/Helper.pm @@ -4,15 +4,15 @@ package Nipe::Utils::Helper { sub new { return " - \rCore Commands - \r============== - \r\tCommand Description - \r\t------- ----------- - \r\tinstall Install dependencies - \r\tstart Start routing - \r\tstop Stop routing - \r\trestart Restart the Nipe circuit - \r\tstatus See status\n\n"; + \rCore Commands + \r============== + \r\tCommand Description + \r\t------- ----------- + \r\tinstall Install dependencies + \r\tstart Start routing + \r\tstop Stop routing + \r\trestart Restart the Nipe circuit + \r\tstatus See status\n\n"; } } diff --git a/lib/Nipe/Utils/Install.pm b/lib/Nipe/Utils/Install.pm index 9b240f0..5fe3eee 100644 --- a/lib/Nipe/Utils/Install.pm +++ b/lib/Nipe/Utils/Install.pm @@ -6,7 +6,7 @@ package Nipe::Utils::Install { sub new { my %device = Nipe::Utils::Device -> new(); my $stopTor = "systemctl stop tor"; - + my %install = ( "debian" => "apt-get install -y tor iptables", "fedora" => "dnf install -y tor iptables", diff --git a/lib/Nipe/Utils/Status.pm b/lib/Nipe/Utils/Status.pm index 9fad333..e61cc69 100644 --- a/lib/Nipe/Utils/Status.pm +++ b/lib/Nipe/Utils/Status.pm @@ -5,10 +5,12 @@ package Nipe::Utils::Status { use HTTP::Tiny; sub new { - my $apiCheck = "https://check.torproject.org/api/ip"; - my $request = HTTP::Tiny -> new -> get($apiCheck); - - if ($request -> {status} == 200) { + use constant SUCCESS_CODE => 200; + + my $apiCheck = "https://check.torproject.org/api/ip"; + my $request = HTTP::Tiny -> new -> get($apiCheck); + + if ($request -> {status} == SUCCESS_CODE) { my $data = decode_json ($request -> {content}); my $checkIp = $data -> {"IP"}; diff --git a/nipe.pl b/nipe.pl index 913de63..9126951 100755 --- a/nipe.pl +++ b/nipe.pl @@ -14,7 +14,7 @@ sub main { my $argument = $ARGV[0]; - + if ($argument) { die "Nipe must be run as root.\n" if $< != 0;