Skip to content

Commit

Permalink
fix: deny netblocks for nc, mtr, ping, alive plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
speed47 committed Dec 20, 2024
1 parent 1859d6a commit 9a4a402
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/plugin/open/alive
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ if (not $host) {
osh_exit 'ERR_MISSING_PARAMETER', "Missing required host parameter";
}

if ($host =~ m{/}) {
help();
osh_exit 'ERR_INVALID_PARAMETER', "Please use a single IP, not a netblock";
}

osh_info "Waiting for $host to be alive...";
my $startedat = Time::HiRes::gettimeofday();
my $firstLoop = 1;
Expand Down
5 changes: 5 additions & 0 deletions bin/plugin/open/mtr
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ if (not $host) {
osh_exit 'ERR_MISSING_PARAMETER', "Missing required host parameter";
}

if ($host =~ m{/}) {
help();
osh_exit 'ERR_INVALID_PARAMETER', "Please use a single IP, not a netblock";
}

my @command = qw{ mtr --show-ips --aslookup -n };
push @command, ($report ? '--report' : '--curses');
push @command, $host;
Expand Down
5 changes: 5 additions & 0 deletions bin/plugin/open/nc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ if (!$fnret) {
osh_exit $fnret;
}

if ($host =~ m{/}) {
help();
osh_exit 'ERR_INVALID_PARAMETER', "Please use a single IP, not a netblock";
}

osh_info "Checking whether TCP port $port of $host is reachable...";

my $Sock = IO::Socket->new(
Expand Down
5 changes: 5 additions & 0 deletions bin/plugin/open/ping
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ if (not $host) {
osh_exit 'ERR_MISSING_PARAMETER', "Missing required host parameter";
}

if ($host =~ m{/}) {
help();
osh_exit 'ERR_INVALID_PARAMETER', "Please use a single IP, not a netblock";
}

my @command = qw{ ping };
if ($count and $count > 0) {
push @command, ('-c', $count);
Expand Down

0 comments on commit 9a4a402

Please sign in to comment.