Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rdap-conformance
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CentralNic
rdap-conformance
Commits
a6dc0726
Unverified
Commit
a6dc0726
authored
Jul 25, 2018
by
Gavin Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first commit
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
234 additions
and
0 deletions
+234
-0
README.md
README.md
+32
-0
rdap-conformance
rdap-conformance
+202
-0
No files found.
README.md
0 → 100644
View file @
a6dc0726
# NAME
`rdap-conformance`
- a script to validate the conformance of an RDAP server.
# DESCRIPTION
`rdap-conformance`
provides a report of the conformance of an RDAP server to
the RDAP profile for generic top-level domains. It tests the responses from
an RDAP server against the requirements published by ICANN.
# USAGE
rdap-conformance OPTIONS URL
# OPTIONS
-
`--handle=HANDLE`
- explicitly specify handle. If not provided, this is
derived from the path segment of the URL.
-
`--type=TYPE`
- specify response type, must be one of
`domain`
(the default),
`entity`
,
`nameserver`
, or
`help`
.
-
`--debug`
- enable debug mode (i.e. print the HTTP request and response)
-
`--help`
- show this help
# COPYRIGHT
Copyright 2018 CentralNic Ltd. This program is free software, you can
use it and/or modify it under the same terms as Perl itself.
# SEE ALSO
-
[
https://www.icann.org/rdap
](
https://www.icann.org/rdap
)
- the RDAP information page on the ICANN website
-
[
Net::RDAP
](
https://metacpan.org/pod/Net::RDAP
)
rdap-conformance
0 → 100755
View file @
a6dc0726
#!/usr/bin/perl
# Copyright 2018 CentralNic Ltd. This program is free software, you can
# use it and/or modify it under the same terms as Perl itself.
use
File::
Basename
qw(basename)
;
use
Getopt::
Long
;
use
List::
MoreUtils
qw(any)
;
use
Net::
RDAP
;
use
Pod::
Usage
;
use
Text::
Wrap
;
use
URI
;
use
strict
;
my
$opt
=
{};
GetOptions
(
$opt
,
'
help
',
'
handle=s
',
'
type=s
',
'
debug
',
);
pod2usage
()
if
(
$opt
->
{'
help
'});
pod2usage
({'
-verbose
'
=>
99
,
'
-sections
'
=>
'
USAGE|OPTIONS
'})
unless
(
$ARGV
[
0
]);
$opt
->
{'
type
'}
||=
'
domain
';
pod2usage
({'
-verbose
'
=>
99
,
'
-sections
'
=>
'
USAGE|OPTIONS
'})
unless
(
$opt
->
{'
type
'}
=~
/^(domain|entity|nameserver|help)$/
);
$opt
->
{'
handle
'}
||=
basename
(
$ARGV
[
0
]);
$ENV
{'
NET_RDAP_UA_DEBUG
'}
=
$opt
->
{'
debug
'};
printf
(
STDERR
"
Testing %s which is a domain...
\n
",
$ARGV
[
0
],
$opt
->
{'
type
'});
my
$response
=
Net::
RDAP
->
new
->
fetch
(
URI
->
new
(
$ARGV
[
0
]));
my
$errors
=
0
;
if
(
$response
->
isa
('
Net::RDAP::Error
'))
{
fail
(
$response
);
}
else
{
check_rdap_conformance
(
$response
);
check_gtld_conformance
(
$response
);
if
('
domain
'
eq
$opt
->
{'
type
'})
{
check_domain_conformance
(
$response
);
}
elsif
('
entity
'
eq
$opt
->
{'
type
'})
{
check_entity_conformance
(
$response
);
}
elsif
('
nameserver
'
eq
$opt
->
{'
type
'})
{
check_nameserver_conformance
(
$response
);
}
elsif
('
help
'
eq
$opt
->
{'
type
'})
{
check_help_conformance
(
$response
);
}
else
{
print
STDERR
"
Cannot validate responses of type '
$opt
->{'type'}'
\n
";
exit
(
1
);
}
printf
(
STDERR
"
Completed with %d errors
\n
",
$errors
);
exit
(
$errors
);
}
sub
check_rdap_conformance
{
my
$response
=
shift
;
# to get this far, Net::RDAP has already validated a lot of stuff, e.g. the media type, JSON well-formedness, etc.
my
@conformance
=
$response
->
conformance
;
if
(
scalar
(
@conformance
)
<
1
)
{
fail
('
rdapConformance is missing or empty
',
[
"
The 'rdapConformance' property must be an array of one or more strings
"]);
}
else
{
pass
("
'rdapConformance' property is an array of one or more values
");
my
%
conformance
;
for
(
my
$i
=
0
;
$i
<
scalar
(
@conformance
)
;
$i
++
)
{
my
$value
=
$conformance
[
$i
];
if
(
ref
(
$value
))
{
fail
(
sprintf
('
value #%d in rdapConformance array is not a string
',
$i
));
}
else
{
$conformance
{
$value
}
++
;
}
pass
("
values in the 'rdapConformance' property are all strings
");
if
(
defined
(
$conformance
{'
rdap_level_0
'}))
{
pass
("
'rdap_level_0' is present in the 'rdapConformance' array
");
}
else
{
fail
("
'rdap_level_0' is not present in the 'rdapConformance' array
");
}
}
}
}
sub
check_gtld_conformance
{
my
$response
=
shift
;
# TODO
}
sub
check_domain_conformance
{
my
$response
=
shift
;
# TODO
}
sub
check_entity_conformance
{
my
$response
=
shift
;
# TODO
}
sub
check_nameserver_conformance
{
my
$response
=
shift
;
# TODO
}
sub
check_help_conformance
{
my
$response
=
shift
;
# TODO
}
sub
pass
{
my
$fmt
=
shift
;
printf
(
STDERR
"
PASS (%04d): %s
\n
",
(
caller
)[
2
],
sprintf
(
$fmt
,
@_
));
}
sub
fail
{
my
$error
=
shift
;
$error
=
mkerror
(
$error
,
@_
)
if
(
!
$error
->
isa
('
Net::RDAP::Error
'));
printf
(
STDERR
"
FAIL (#%04d): %s
\n\n
",
$error
->
errorCode
,
$error
->
title
);
my
@description
=
$error
->
description
;
print
"
Description:
\n\n
"
.
fill
("
",
"
",
join
("
\n
",
@description
))
.
"
\n\n
"
if
(
scalar
(
@description
)
>
0
);
}
sub
mkerror
{
my
(
$title
,
$description
)
=
@_
;
return
Net::RDAP::
Error
->
new
({
'
errorCode
'
=>
600
+
(
caller
)[
2
],
'
title
'
=>
$title
,
'
description
'
=>
$description
,
});
}
__END__
=pod
=head1 NAME
C<rdap-conformance> - a script to validate the conformance of an RDAP server.
=head1 DESCRIPTION
C<rdap-conformance> provides a report of the conformance of an RDAP server to
the RDAP profile for generic top-level domains. It tests the responses from
an RDAP server against the requirements published by ICANN.
=head1 USAGE
rdap-conformance OPTIONS URL
=head1 OPTIONS
=over
=item * C<--handle=HANDLE> - explicitly specify handle. If not provided, this is
derived from the path segment of the URL.
=item * C<--type=TYPE> - specify response type, must be one of C<domain> (the default),
C<entity>, C<nameserver>, or C<help>.
=item * C<--debug> - enable debug mode (i.e. print the HTTP request and response)
=item * C<--help> - show this help
=back
=head1 COPYRIGHT
Copyright 2018 CentralNic Ltd. This program is free software, you can
use it and/or modify it under the same terms as Perl itself.
=head1 SEE ALSO
=over
=item * L<https://www.icann.org/rdap> - the RDAP information page on the ICANN website
=item * L<Net::RDAP>
=back
=cut
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment