Skip to content

Commit

Permalink
- bump version to 1.00 as PAUSE ignores 0.1x version numbers as they …
Browse files Browse the repository at this point in the history
…are lower than 0.9 (:facepalm:)

- display a list of redacted fields where provided
- support TLD queries by directly querying the IANA RDAP server.
  • Loading branch information
gbicann committed May 30, 2024
1 parent 3e188a1 commit e356211
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 29 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.00 - 2024-05-30:
- bump version to 1.00 as PAUSE ignores 0.1x version numbers as they are lower than 0.9 (:facepalm:)
- display a list of redacted fields where provided
- support TLD queries by directly querying the IANA RDAP server.

0.11 - 2024-05-30:
- handle help queries better.

Expand Down
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ WriteMakefile(
'Net::ASN' => 0,
'Net::DNS::Domain' => 0,
'Net::IP' => 0,
'Net::RDAP' => 0,
'Net::RDAP' => '0.24',
'Pod::Usage' => 0,
'Term::ANSIColor' => 0,
'Term::Size' => 0,
Expand Down
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ App::rdapper - a simple console-based RDAP client.

To install, run:

cpanm --sudo App::rdapper
cpanm --sudo App::rdapper

# RUNNING VIA DOCKER

Expand All @@ -15,13 +15,13 @@ that can be used to build an image on your local system.

Alternatively, you can pull the [image from Docker Hub](https://hub.docker.com/r/gbxyz/rdapper):

$ docker pull gbxyz/rdapper
$ docker pull gbxyz/rdapper

$ docker run -it gbxyz/rdapper --help
$ docker run -it gbxyz/rdapper --help

# SYNOPSIS

rdapper OBJECT [OPTIONS]
rdapper [OPTIONS] OBJECT

# DESCRIPTION

Expand All @@ -40,6 +40,7 @@ just a very thin front-end to [Net::RDAP](https://metacpan.org/pod/Net%3A%3ARDAP
You can pass any internet resource as an argument; this may be:

- a "forward" domain name such as `example.com`;
- a top-level domain such as `com`;
- a "reverse" domain name such as `168.192.in-addr.arpa`;
- a IPv4 or IPv6 address or CIDR prefix, such as `192.168.0.1`
or `2001:DB8::/32`;
Expand Down Expand Up @@ -69,20 +70,22 @@ will guess the type by pattern matching the value of `OBJECT` but
you can override this by explicitly setting the `--type` argument
to one of : `ip`, `autnum`, `domain`, `nameserver`, `entity`
or `url`.

If `--type=url` is used, `rdapper` will directly fetch the
specified URL and attempt to process it as an RDAP response.

If `--type=entity` is used, `OBJECT` must be a a string
- If `--type=url` is used, `rdapper` will directly fetch the
specified URL and attempt to process it as an RDAP response. If the URL
path ends with `/help` then the response will be treated as a "help"
query response (if you want to see the record for the .help TLD, use
`--type=tld help`).
- If `--type=entity` is used, `OBJECT` must be a a string
containing a "tagged" handle, such as `ABC123-EXAMPLE`, as per
RFC 8521.

- `--help` - display help message.
- `--raw` - print the raw JSON rather than parsing it.
- `--short` - omit remarks, notices, and links.
- `--short` - omit remarks, notices, links and redactions.
- `--bypass-cache` - disable local cache of RDAP objects.
- `--auth=USER:PASS` - HTTP Basic Authentication credentials
to be used when accessing the specified resource.
to be used when accessing the specified resource. This option
**SHOULD NOT** be used unless you explicitly specify a URL, otherwise
your credentials may be sent to servers you aren't expecting them to.
- `--nocolor` - disable ANSI colors in the formatted output.

# COPYRIGHT & LICENSE
Expand Down
60 changes: 44 additions & 16 deletions lib/App/rdapper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Net::ASN;
use Net::DNS::Domain;
use Net::IP;
use Net::RDAP::EPPStatusMap;
use Net::RDAP;
use Net::RDAP 0.24;
use Pod::Usage;
use Term::ANSIColor;
use Term::Size;
Expand All @@ -21,11 +21,12 @@ use constant {
'ADR_PC' => 5,
'ADR_CC' => 6,
'INDENT' => ' ',
'IANA_BASE_URL' => 'https://rdap.iana.org/',
};
use vars qw($VERSION);
use strict;

$VERSION = '0.11';
$VERSION = '1.00';

#
# global arg variables (note: nopager is now ignored)
Expand Down Expand Up @@ -91,13 +92,14 @@ sub main {
$package->show_usage if ($help || length($object) < 1);

if (!$type) {
if ($object =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { $type = 'ip' } # v4 address
elsif ($object =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}$/) { $type = 'ip' } # v4 range
elsif ($object =~ /^[0-9a-f:]+$/i) { $type = 'ip' } # v6 address
elsif ($object =~ /^[0-9a-f:]+\/\d{1,3}$/i) { $type = 'ip' } # v6 range
elsif ($object =~ /^asn?\d+$/i) { $type = 'autnum' } # ASN
elsif ($object =~ /^(file|https)?:\/\//) { $type = 'url' } # URL
else { $type = 'domain' } # domain
if ($object =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { $type = 'ip' }
elsif ($object =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}$/) { $type = 'ip' }
elsif ($object =~ /^[0-9a-f:]+$/i) { $type = 'ip' }
elsif ($object =~ /^[0-9a-f:]+\/\d{1,3}$/i) { $type = 'ip' }
elsif ($object =~ /^asn?\d+$/i) { $type = 'autnum' }
elsif ($object =~ /^(file|https)?:\/\//) { $type = 'url' }
elsif ($object =~ /^([a-z]{2,}|xn--[a-z0-9\-]+)$/i) { $type = 'tld' }
else { $type = 'domain' }
}

my %args;
Expand Down Expand Up @@ -133,6 +135,9 @@ sub main {
} elsif ('entity' eq $type) {
$response = $rdap->entity($object, %args);

} elsif ('tld' eq $type) {
$response = $rdap->fetch(URI->new(IANA_BASE_URL.'domain/'.$object), %args);

} elsif ('url' eq $type) {
my $uri = URI->new($object);

Expand Down Expand Up @@ -243,7 +248,7 @@ sub display {
$package->print_entities($object, $indent);

#
# links, remarks and notices unless --short has been passed
# links, remarks, notices and redactions, unless --short has been passed
#
if (!$short) {
foreach my $link (grep { 'self' ne $_->rel } $object->links) {
Expand All @@ -257,6 +262,18 @@ sub display {
foreach my $notice ($object->notices) {
$package->print_remark_or_notice($notice, $indent);
}

my @fields = $object->redactions;
if (scalar(@fields) > 0) {
$package->print_kv('Redacted Fields', '', $indent);
foreach my $field (@fields) {
$out->print(wrap(
(INDENT x ($indent + 1)),
(INDENT x ($indent + 2)),
sprintf("%s %s (reason: %s)\n", b('*'), $field->name, $field->reason)
));
}
}
}

$out->print("\n") if ($indent < 1);
Expand Down Expand Up @@ -560,7 +577,7 @@ Alternatively, you can pull the L<image from Docker Hub|https://hub.docker.com/r
=head1 SYNOPSIS
rdapper OBJECT [OPTIONS]
rdapper [OPTIONS] OBJECT
=head1 DESCRIPTION
Expand All @@ -582,6 +599,8 @@ You can pass any internet resource as an argument; this may be:
=item * a "forward" domain name such as C<example.com>;
=item * a top-level domain such as C<com>;
=item * a "reverse" domain name such as C<168.192.in-addr.arpa>;
=item * a IPv4 or IPv6 address or CIDR prefix, such as C<192.168.0.1>
Expand Down Expand Up @@ -622,23 +641,32 @@ you can override this by explicitly setting the C<--type> argument
to one of : C<ip>, C<autnum>, C<domain>, C<nameserver>, C<entity>
or C<url>.
If C<--type=url> is used, C<rdapper> will directly fetch the
specified URL and attempt to process it as an RDAP response.
=over
=item * If C<--type=url> is used, C<rdapper> will directly fetch the
specified URL and attempt to process it as an RDAP response. If the URL
path ends with C</help> then the response will be treated as a "help"
query response (if you want to see the record for the .help TLD, use
C<--type=tld help>).
If C<--type=entity> is used, C<OBJECT> must be a a string
=item * If C<--type=entity> is used, C<OBJECT> must be a a string
containing a "tagged" handle, such as C<ABC123-EXAMPLE>, as per
RFC 8521.
=back
=item * C<--help> - display help message.
=item * C<--raw> - print the raw JSON rather than parsing it.
=item * C<--short> - omit remarks, notices, and links.
=item * C<--short> - omit remarks, notices, links and redactions.
=item * C<--bypass-cache> - disable local cache of RDAP objects.
=item * C<--auth=USER:PASS> - HTTP Basic Authentication credentials
to be used when accessing the specified resource.
to be used when accessing the specified resource. This option
B<SHOULD NOT> be used unless you explicitly specify a URL, otherwise
your credentials may be sent to servers you aren't expecting them to.
=item * C<--nocolor> - disable ANSI colors in the formatted output.
Expand Down

0 comments on commit e356211

Please sign in to comment.