Skip to content

Commit

Permalink
Merge pull request #273 from matsduf/merge-develop-into-master
Browse files Browse the repository at this point in the history
Merge develop into master (CLI)
  • Loading branch information
matsduf authored Jun 9, 2022
2 parents 6f9c0d6 + d0ff2e7 commit 4391018
Show file tree
Hide file tree
Showing 13 changed files with 244 additions and 89 deletions.
17 changes: 9 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dist: focal

language: perl

perl:
- "5.30"
- "5.28"
- "5.26"
- "5.24"
- "5.22"
- "5.16"
- "5.32"
- "5.30.2"
- "5.26"
- "5.14.4"

addons:
apt:
Expand All @@ -20,7 +20,7 @@ addons:
- libdevel-checklib-perl
- libfile-sharedir-perl
- libfile-slurp-perl
- libidn11-dev
- libidn2-dev
- libintl-perl
- libjson-pp-perl
- liblist-moreutils-perl
Expand All @@ -46,7 +46,8 @@ before_install:
- export PERL5LIB=/usr/share/perl5

# Provide cpanm helper
- eval $(curl https://travis-perl.github.io/init) --auto
# quoting preserves newlines in the script and then avoid error if the script contains comments
- eval "$(curl https://travis-perl.github.io/init)" --auto

# Zonemaster LDNS needs a newer version of Module::Install
- cpan-install Module::Install Module::Install::XSUtil
Expand Down
38 changes: 29 additions & 9 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
Release history for Zonemaster component Zonemaster-CLI

v4.0.0 2022-06-09 (public release version)

[Breaking changes]
- Updates how trailing dots of domain name or name
server name is handled. Trailing double dot is now
always an error. (#253)

[Features]
- Uses pre-built packages for ubuntu (#268)
- Adds support for global configuration file (#260, #252)

[Fixes]
- Updates translation (#263, #267, #266, #265, #269, #264, #261)
- Fixes a bug where a trailing dot on name server name
gives a crash (#253)
- Fixes warning message (#255)
- Uses libidn2 instead of libidn (#254)
- Updates documentation for users (#241, #244)
- Updates installation document (#243)


v3.2.0 2021-12-20 (public fix version)

Expand Down Expand Up @@ -116,7 +136,7 @@ v2.0.3 2020-04-30
[Fixes]
- Update installation instructions (#119, #117, #137)
- Translation into Danish (#109, #61)


v2.0.2 2019-05-31 (public fix version)

Expand Down Expand Up @@ -171,14 +191,14 @@ v1.1.3 2018-06-25
Fixed:
- Move license from Makefile.PL to main module (#67)
- Initialize gettext according to gettext documentation (#71), which
solves issues with translations in Linux (#46) and FreeBSD (#64)
solves issues with translations in Linux (#46) and FreeBSD (#64)
- Updated the install instructions for debian and centos (#75)
- Update Installation.md for FreeBSD (uses cpan instead of cpanm) (#78)

v1.1.2 2018-01-12

Natural Language support:
- Adding support for Danish translation. (#62)
- Adding support for Danish translation. (#62)

Fixed:
- Fixes issues with pre-delegation testing ("fake delegation") (#63)
Expand All @@ -187,12 +207,12 @@ Fixed:
v1.1.1 2017-11-02 Public release

Fixed:
- Update licensing (#58)
- Update licensing (#58)
- Specify smallest version of Locale::TextDomain i Makefile.PL. (#57)
- Updated installation instruction (#53)
- Updated installation instruction (#53)
- Changed dependency from Net::LDNS to Zonemaster::LDNS due to
name space change (#51)
- Various updates to packaging (#52)
name space change (#51)
- Various updates to packaging (#52)
- Fix Commonmark rendering on Github. Replace NBSP with SPACE. (#49)
- Changed dependency from Zonemaster to Zonemaster::Engine due
to name space change (#43)
Expand All @@ -210,7 +230,7 @@ v1.1.0 2017-04-04 Public pre-release
- Correcting version in CLI.pm. Update missing in 1.0.4.

1.0.4 2016-10-14
- Updating README.md and USING.md
- Updating README.md and USING.md
- Better way to check ExtUtils::MakeMaker version
- Introduced MANIFEST.SKIP

Expand Down Expand Up @@ -239,7 +259,7 @@ v1.1.0 2017-04-04 Public pre-release
0.001000 2014-11-17

0.03 2014-10-30

0.01 2014-05-25

- initial CPAN release
4 changes: 2 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ requires(
'Locale::TextDomain' => 1.23,
'MooseX::Getopt' => 0,
'Text::Reflow' => 0,
'Zonemaster::Engine' => 4.004,
'Zonemaster::LDNS' => 2.002,
'Zonemaster::Engine' => 4.005,
'Zonemaster::LDNS' => 2.002002,
);

# Make all platforms include inc/Module/Install/External.pm
Expand Down
45 changes: 34 additions & 11 deletions USING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Table of contents
* [Docker or local installation](#Docker-or-local-installation)
* [Invoking the command line tool](#Invoking-the-command-line-tool)
* [Invoking the command line tool using Docker](#Invoking-the-command-line-tool-using-Docker)
* [Invoking the command line tool using local installation](#Invoking-the-command-line-tool-using-local-installation)
* [More details on the command line tool invocation](#More-details-on-the-command-line-tool-invocation)
* [Test reports](#Test-reports)
* [Translation]
* [Advanced use](#Advanced-use)
Expand Down Expand Up @@ -40,12 +42,11 @@ If the network has no IPv6 support (common in home networks) then turn off IPv6.
Use `--no-ipv6` to avoid meaningless errors if there is no IPv6 support.


## Invoking the command line tool
## Invoking the command line tool using Docker

The most basic use of the `zonemaster-cli` command is to just test a domain, e.g.
"zonemaster.net".

Using Docker:
```sh
docker run -t --rm zonemaster/cli zonemaster.net --no-ipv6
```
Expand All @@ -54,7 +55,22 @@ or
docker run -t --rm zonemaster/cli zonemaster.net
```

With local installation:
To make sure that Docker uses the latest version, add `--pull always`, e.g.

```sh
docker run -t --rm --pull always zonemaster/cli zonemaster.net --no-ipv6
```

If `--pull always` is skipped, the invocation is quicker. The recommendation is
to include `--pull always` in the first command of a session to make sure latest
version is used, and then to exclude it to improve performance.


## Invoking the command line tool using local installation

The most basic use of the `zonemaster-cli` command is to just test a domain, e.g.
"zonemaster.net".

```sh
zonemaster-cli zonemaster.net
```
Expand All @@ -63,7 +79,11 @@ or
zonemaster-cli zonemaster.net --no-ipv6
```

The output comes continuously as the tests are performed.
## More details on the command line tool invocation

The output of any of the commands above comes continuously as the tests (test
cases) are performed.

```
Seconds Level Message
======= ========= =======
Expand Down Expand Up @@ -91,17 +111,20 @@ docker run -t --rm zonemaster/cli zonemaster.net --no-ipv6 --show-testcase --loc
zonemaster-cli zonemaster.net --no-ipv6 --show-testcase --locale=da_DK.UTF-8
```

To see all available command line options, use the `--help` command.

```
zonemaster-cli --help
```

### Using Docker or local installation

The difference between running `zonemaster-cli` on Docker or local installation
is the invocation string, `docker run -t --rm zonemaster/cli` vs.
`zonemaster-cli`. To simplify this document, from now on the shorter
`zonemaster-cli` will be used and for Docker the longer string will be assumed.
To simplify repeated invocation on Docker an alias can be created for the shell.

To see all available command line options, use the `--help` command.

```
zonemaster-cli --help
```

## Test reports

Expand Down Expand Up @@ -171,7 +194,7 @@ en_US.UTF-8 | English
fi_FI.UTF-8 | Finnish
fr_FR.UTF-8 | French
nb_NO.UTF-8 | Norwegian
es-CL.UTF-8 | Spanish
es_ES.UTF-8 | Spanish
sv_SE.UTF-8 | Swedish

E.g.:
Expand Down
18 changes: 10 additions & 8 deletions docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
* [Prerequisites for CPAN installation](#Prerequisites-for-CPAN-installation)
* [Local installation](#Local-installation)
* [Installation on Rocky Linux](#Installation-on-Rocky-Linux)
* [Installation on Debian](#Installation-on-Debian)
* [Installation on Ubuntu](#Installation-on-Ubuntu)
* [Installation on Debian and Ubuntu](#Installation-on-Debian-and-Ubuntu)
* [Installation on FreeBSD](#Installation-on-FreeBSD)
* [Post-installation sanity check](#Post-installation-sanity-check)
* [Using zonemaster-cli](#Using-zonemaster-cli)
Expand Down Expand Up @@ -74,10 +73,11 @@ Zonemaster::CLI, see the [declaration of prerequisites].
```


### Installation on Debian
### Installation on Debian and Ubuntu

Using pre-built packages is the preferred method for Debian. If you prefer to
install from CPAN instead, follow the steps for Ubuntu.
Using pre-built packages is the preferred method for Debian and Ubuntu.

#### Installation from pre-built packages

1) Add Zonemaster packages repository to repository list
```sh
Expand All @@ -91,21 +91,22 @@ install from CPAN instead, follow the steps for Ubuntu.
3) Update configuration of "locale"

```sh
sudo perl -pi -e 's/^# (da_DK\.UTF-8.*|en_US\.UTF-8.*|fi_FI\.UTF-8.*|fr_FR\.UTF-8.*|nb_NO\.UTF-8.*|sv_SE\.UTF-8.*)/$1/' /etc/locale.gen
sudo perl -pi -e 's/^# (da_DK\.UTF-8.*|en_US\.UTF-8.*|es_ES\.UTF-8.*|fi_FI\.UTF-8.*|fr_FR\.UTF-8.*|nb_NO\.UTF-8.*|sv_SE\.UTF-8.*)/$1/' /etc/locale.gen
sudo locale-gen
```

After the update, `locale -a` should at least list the following locales:
```
da_DK.utf8
en_US.utf8
es_ES.utf8
fi_FI.utf8
fr_FR.utf8
nb_NO.utf8
sv_SE.utf8
```

### Installation on Ubuntu
#### Installation from CPAN

1) Install dependencies:

Expand All @@ -121,14 +122,15 @@ install from CPAN instead, follow the steps for Ubuntu.
3) Update configuration of "locale"

```sh
sudo perl -pi -e 's/^# (da_DK\.UTF-8.*|en_US\.UTF-8.*|fi_FI\.UTF-8.*|fr_FR\.UTF-8.*|nb_NO\.UTF-8.*|sv_SE\.UTF-8.*)/$1/' /etc/locale.gen
sudo perl -pi -e 's/^# (da_DK\.UTF-8.*|en_US\.UTF-8.*|es_ES\.UTF-8.*|fi_FI\.UTF-8.*|fr_FR\.UTF-8.*|nb_NO\.UTF-8.*|sv_SE\.UTF-8.*)/$1/' /etc/locale.gen
sudo locale-gen
```

After the update, `locale -a` should at least list the following locales:
```
da_DK.utf8
en_US.utf8
es_ES.utf8
fi_FI.utf8
fr_FR.utf8
nb_NO.utf8
Expand Down
21 changes: 17 additions & 4 deletions lib/Zonemaster/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use 5.014002;
use strict;
use warnings;

use version; our $VERSION = version->declare( "v3.2.0" );
use version; our $VERSION = version->declare( "v4.0.0" );

use Locale::TextDomain 'Zonemaster-CLI';
use Moose;
Expand Down Expand Up @@ -472,6 +472,12 @@ sub run {
die __( "Must give the name of a domain to test.\n" );
}

if ( $domain =~ m/\.\./i ) {
die __( "The domain name contains consecutive dots.\n" );
}

$domain =~ s/\.$// unless $domain eq '.';

if ( $translator ) {
if ( $self->time ) {
print __( 'Seconds ' );
Expand Down Expand Up @@ -597,10 +603,17 @@ sub add_fake_delegation {
my ( $name, $ip ) = split( '/', $pair, 2 );

if ( not $name ) {
say STDERR "--ns must have be a name or a name/ip pair.";
say STDERR __( "--ns must be a name or a name/ip pair." );
exit( 1 );
}

if ( $name =~ m/\.\./i ) {
say STDERR __x( "The name of the nameserver '{nsname}' contains consecutive dots.", nsname => $name );
exit ( 1 );
}

$name =~ s/\.$// unless $name eq '.';

if ($ip) {
push @{ $data{ $self->to_idn( $name ) } }, $ip;
}
Expand Down Expand Up @@ -669,7 +682,7 @@ sub to_idn {
return Zonemaster::LDNS::to_idn( decode( $self->encoding, $str ) );
}
else {
say STDERR __( "Warning: Zonemaster::LDNS not compiled with libidn, cannot handle non-ASCII names correctly." );
say STDERR __( "Warning: Zonemaster::LDNS not compiled with IDN support, cannot handle non-ASCII names correctly." );
return $str;
}
}
Expand Down Expand Up @@ -704,7 +717,7 @@ sub print_test_list {

sub do_dump_profile {
my $json = JSON::XS->new->canonical->pretty;

print $json->encode( Zonemaster::Engine::Profile->effective->{ q{profile} } );

exit;
Expand Down
Loading

0 comments on commit 4391018

Please sign in to comment.