Zonemaster-CLI-v6.0.3/000755 001754 001754 00000000000 14476561000 014737 5ustar00matsdmatsd000000 000000 Zonemaster-CLI-v6.0.3/share/000755 001754 001754 00000000000 14476561000 016041 5ustar00matsdmatsd000000 000000 Zonemaster-CLI-v6.0.3/Makefile.PL000644 001754 001754 00000003237 14476560733 016732 0ustar00matsdmatsd000000 000000 use 5.014002; use strict; use warnings FATAL => 'all'; use inc::Module::Install; use ExtUtils::MakeMaker (); name 'Zonemaster-CLI'; all_from 'lib/Zonemaster/CLI.pm'; resources( repository => 'https://github.com/zonemaster/zonemaster-cli', bugtracker => 'https://github.com/zonemaster/zonemaster-cli/issues', ); tests_recursive( 't' ); # "2.1.0" could be declared as "2.001" but not as "2.1" # (see Zonemaster::LDNS below) requires( 'JSON::XS' => 0, 'Locale::TextDomain' => 1.23, 'MooseX::Getopt' => 0, 'Text::Reflow' => 0, 'Try::Tiny' => 0, 'Zonemaster::LDNS' => 3.002000, # v3.2.0 'Zonemaster::Engine' => 4.007003, # v4.7.3 ); # Make all platforms include inc/Module/Install/External.pm requires_external_bin 'find'; if ($^O eq "freebsd") { requires_external_bin 'gmake'; }; sub MY::postamble { my $pure_all; my $sharemakefile = 'share/GNUmakefile'; if ($^O eq "freebsd") { # Make FreeBSD use gmake for share $pure_all = "GMAKE ?= \"gmake\"\n" . "pure_all :: $sharemakefile\n" . "\tcd share && \$(GMAKE) all\n"; } else { # Here Linux and GNU Make is assumed $pure_all = "pure_all :: $sharemakefile\n" . "\tcd share && \$(MAKE) all\n"; }; my $docker = <<'END_DOCKER'; docker-build: docker build --tag zonemaster/cli:local --build-arg version=$(VERSION) . docker-tag-version: docker tag zonemaster/cli:local zonemaster/cli:$(VERSION) docker-tag-latest: docker tag zonemaster/cli:local zonemaster/cli:latest END_DOCKER return $pure_all . $docker; }; install_script 'zonemaster-cli'; install_share; WriteAll; Zonemaster-CLI-v6.0.3/inc/000755 001754 001754 00000000000 14476561000 015510 5ustar00matsdmatsd000000 000000 Zonemaster-CLI-v6.0.3/script/000755 001754 001754 00000000000 14476561000 016243 5ustar00matsdmatsd000000 000000 Zonemaster-CLI-v6.0.3/LICENSE000644 001754 001754 00000003561 14464322367 015761 0ustar00matsdmatsd000000 000000 ### Code license Copyright (c) The Swedish Internet Foundation () Copyright (c) AFNIC () All rights reserved. Copyright belongs to external contributor where applicable. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ### Documentation license Copyright (c) The Swedish Internet Foundation () Copyright (c) AFNIC () All rights reserved. Copyright belongs to external contributor where applicable. Creative Commons Attribution 4.0 International License You should have received a copy of the license along with this work. If not, see . Zonemaster-CLI-v6.0.3/META.yml000644 001754 001754 00000001546 14476560775 016240 0ustar00matsdmatsd000000 000000 --- abstract: 'run Zonemaster tests from the command line' author: - 'Vincent Levigneron ' build_requires: ExtUtils::MakeMaker: 6.59 configure_requires: ExtUtils::MakeMaker: 6.59 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.19' license: bsd meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Zonemaster-CLI no_index: directory: - inc - share - t requires: JSON::XS: 0 Locale::TextDomain: 1.23 MooseX::Getopt: 0 Text::Reflow: 0 Try::Tiny: 0 Zonemaster::Engine: 4.007003 Zonemaster::LDNS: 3.002 perl: 5.14.2 resources: bugtracker: https://github.com/zonemaster/zonemaster-cli/issues license: http://opensource.org/licenses/bsd-license.php repository: https://github.com/zonemaster/zonemaster-cli version: '6.000003' Zonemaster-CLI-v6.0.3/lib/000755 001754 001754 00000000000 14476561000 015505 5ustar00matsdmatsd000000 000000 Zonemaster-CLI-v6.0.3/CONTRIBUTING.md000644 001754 001754 00000002720 14464322367 017201 0ustar00matsdmatsd000000 000000 # Contributing to Zonemaster::CLI Contribution to this repository is welcome. Contribution can be either an issue report or a code or a documentation update. Also see the information in the [main README][Zonemaster/Zonemaster README] in the main Zonemaster respository. ## Issue First search for a similar issue in the [issues list]. If a relevant issue is found, add your information as a comment. If no relevant issue is found, create [a new issue][create issue]. Give as many details as you have and describe, if possible, how the issue can be reproduced. ## Pull request If you would like to contribute an update, first please look for issues and open [pull requests] that are about the same thing. If nothing relevant is found or you have a different solution, create [a new pull request][create pull request]. Creating a pull request assumes that you have your proposal in a fork repository. When you create a pull request, please always start with the `develop` branch and create the pull request against the same branch. [issues list]: https://github.com/zonemaster/zonemaster-cli/issues [create issue]: https://github.com/zonemaster/zonemaster-cli/issues/new [pull requests]: https://github.com/zonemaster/zonemaster-cli/pulls [create pull request]: https://github.com/zonemaster/zonemaster-cli/compare [Zonemaster/Zonemaster README]: https://github.com/zonemaster/zonemaster#readme Zonemaster-CLI-v6.0.3/t/000755 001754 001754 00000000000 14476561000 015202 5ustar00matsdmatsd000000 000000 Zonemaster-CLI-v6.0.3/Changes000644 001754 001754 00000022512 14476560733 016250 0ustar00matsdmatsd000000 000000 Release history for Zonemaster component Zonemaster-CLI v6.0.3 2023-09-08 (public fix version) [Fixes] - Fixes a spelling error (text) in the zonemaster-cli script (#351). - This version contains no real code changes, but it requires a higher (fixed) version of Zonemaster-Engine. v6.0.2 2023-08-07 (public fix version) [Fixes] - This version contains no real changes. It has been created to require a higher (fixed) version of Zonemaster-Engine. v6.0.1 2023-07-24 (public fix version) [Fixes] - Updates the translation to Norwegian (#342) v6.0.0 2023-06-21 (public release version) [Breaking changes] - Adds display of Zonemaster::LDNS and libldns versions when --version has been selected (#306) [Features] - Updates various report options to zonemaster-cli script (#318, #337, #309, #308) - Adds options "--sourceaddr4" and "--sourceaddr6" to zonemaster-cli script (#317) [Fixes] - Updates translations (#338, #328, #329, #331, #327, #322) - Updates documentation in zonemaster-cli script (#336) - Fixes table layout in zonemaster-cli output (#335) - Removes documentation moved to the zonemaster/zonemaster repository (#332) - Removes some untranslatable characters from msgids (#307) v5.0.2 2023-03-01 (public fix version) [Fixes] - Updates translations (#303) v5.0.1 2023-01-31 (public fix version) [Fixes] - Updates translations (#298, #297) v5.0.0 2022-12-19 (public release version) [Breaking changes] - Makes zonemaster-cli fail if there are multiple domain names in entry (#287, #286) [Features] - Adds --hints option (#284, #293, #292) [Fixes] - Updates installation instruction (#291, #289) - Corrects the license statement in CLI.pm (#288) - Sets lowercase fragments to refer to internal headings in markdown documents (#282) - Cleans-up unused import (#283) - Adds Mac note on USING.md when it comes to Docker (#281) v4.0.1 2022-07-08 (public fix version) [Fixes] - Adds missing installation instructions for CentOS Linux 7 (#275) - Updates translation to Danish (#271) 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) [Features] - Adds translation to Spanish language (#219) [Fixes] - Clarifies IPv6 limitations in Docker (#238) - Updates Danish translation (#236, #233) - Updates French translation (#237, #225) v3.1.1 2021-12-03 (public release version) [Features] - Deb packages are available for Debian (#233) - Adds support for Docker (#221, #218, #216) - Replaces CentOS with Rocky Linux (#220) [Fixes] - Updates Finnish translation (#230, #224) - Updates Norwegian translation (#228, #226) - Updates Swedish translation (#227) - Updates dependencies (#217) - Improves DEBUG3 output (#215, #111) - Improves output when option is incorrect (#214, #160) - Clean-up removing unused options (#213, #145) - More user-friendly options (#212, #159) v3.1.0 2021-05-28 (public release version) [Features] - Adds Finnish translation (PO file) (#192, #191) [Fixes] - Updates the installation instructions (#193, #191) - Updates translations (#204, #201, #205, #200, #207, #202) v3.0.4 2021-02-10 (public release version) [Features] - Updates --raw mode output in debug level (#113) [Fixes] - Updates the installation instructions (#188) - Prevents PO files to be updated unintentionally (#186) - Fixes how command line options of profile and IP interact (#185, #183, #182) - Makes --sourceaddr behavior more reasonable when selected address is not reasonable (#110, #38) v3.0.3 (never released) v3.0.2 (never released) v3.0.1 2020-11-09 (public release version) [Fixes] - Fixed an version specification error in Makefile.PL (#178) v3.0.0 2020-11-06 (public release version) [Breaking changes] - Added "--show_testcase" and changed format when "--raw" is selected (#157) [Features] - Added Norwegian language support to match added translation to Norwegian in Zonemaster-Engine (#164, #155, #161) [Fixes] - Updated/corrected translations/PO files (#174, #173) - Corrected documentation (#172) - Rename share/Makefile to share/GNUmakefile and create wrapper for FreeBSD. Make FreeBSD use gmake for share/GNUmakefile (#169) - Corrected MANIFEST (#168) - Updated share/Makefile (#167) - Clean-up (#166, #158) - Correcting --nstimes option (#163, #148) - Updated translation/PO files handling (#151, #132, #147, #150, #149) v2.0.4 2020-05-22 [Fixes] - Bumping the version of Zonemaster::CLI to be able to upload a new package to CPAN to avoid the confusion that the version v2.0.3.1 created. There are no changes compared to v2.0.3. v2.0.3.1 2020-05-15 [Fixes] - This release fixes inconsitency between the branches in the repository. See the release notes for v2.0.3 for the real changes. - There is no change in data so this release has not been published on CPAN. v2.0.3 2020-04-30 [Features] - (none) [Fixes] - Update installation instructions (#119, #117, #137) - Translation into Danish (#109, #61) v2.0.2 2019-05-31 (public fix version) [Fixes] - Corrects in Makefile.PL the versions of Zonemaster::Engine and Zonemaster::LDNS that this version of Zonemaster::CLI depends on (#105) v2.0.1 2019-05-22 (public release version) [Status] - This a public release fully tested before release. This version will be available on CPAN. [Fixes] - Updated installation instructions for FreeBSD (#101) - Dropped support for Ubuntu 14.04 (#99) - Made Travis use the equivalent branch in Zonemaster-Engine (#98) v2.0.0 2019-01-25 (pre-release version) - Status - This is a pre-release version not fully tested on all supported OS's and Perl versions. This version will not be available on CPAN. - API change - Replaced separate config and policy with a unified profile (see below) - Some changes in printout that can affect scripts using zonemaster-cli (see below) - Features - Changes in printout - Print information on STDERR if --json has been selected #84 - Diagnostics #85 - Only show spinner in human readable output mode #86 - Make --level and --stop_level case-insensitive #87 - Replaced separate config and policy with a unified profile - Removed config and policy and added profile #70, #93 - Fixes - All link references on Github now to zonemaster/zonemaster instead of old dotse/zonemaster #81 - Clarify documentation of --progress option #88 - Travis tests against develop branch of Zonemaster-Engine instead of fetching from CPAN #92 - Update travis configuration when it comes to Perl versions. #95 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) - 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) Fixed: - Fixes issues with pre-delegation testing ("fake delegation") (#63) v1.1.1 2017-11-02 Public release Fixed: - Update licensing (#58) - Specify smallest version of Locale::TextDomain i Makefile.PL. (#57) - Updated installation instruction (#53) - Changed dependency from Net::LDNS to Zonemaster::LDNS due to 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) v1.1.0 2017-04-04 Public pre-release - This release will not be published on CPAN since it contains updates that have not been fully tested. Do not update production systems without verification. - Update install instructions (#34) - Fixes packaging issue with version numbering (#35) - Solved --sourceaddr is not correctly implemented (#36) - Updates so that "fake delegation" is tested correctly (#42) 1.0.5 2016-10-14 - Correcting version in CLI.pm. Update missing in 1.0.4. 1.0.4 2016-10-14 - Updating README.md and USING.md - Better way to check ExtUtils::MakeMaker version - Introduced MANIFEST.SKIP 1.0.3 2015-12-22 - Added JSON streaming - Changed all instances from .SE to IIS 1.0.2 2015-06-25 - Allow lookup of nameservers for undelegated tests - Net::LDNS::to_idn() takes Perl characters, not octets with utf-8 data - Fixed display bug when using --nstimes with --no-ipv6 or --no-ipv4 1.0.1 2015-04-07 - State clearly that a given name is not a domain when it is not a domain - Send "Net::LDNS not compiled with libidn" to STDERR, not STDOUT 1.0.0 2014-12-11 Release version 1.000000 2014-12-11 Public beta release. 0.001002 2014-11-26 0.001001 2014-11-19 0.001000 2014-11-17 0.03 2014-10-30 0.01 2014-05-25 - initial CPAN release Zonemaster-CLI-v6.0.3/README.md000644 001754 001754 00000004140 14464322367 016225 0ustar00matsdmatsd000000 000000 # Zonemaster-CLI ## Purpose This Git repository is one of the components of the Zonemaster software and contains the source for the Zonemaster-CLI utility. For an overview of the Zonemaster software, please see the [Zonemaster repository]. ## Prerequisite Before you install the Zonemaster-CLI utility, you need the Zonemaster-Engine test framework installed. Please see the [Zonemaster Engine installation instructions][Zonemaster-Engine installation]. ## Installation For installation, see the [installation] document. ## Configuration This repository does not need any specific configuration. ## Docker Zonemaster-CLI is available on [Docker Hub], and can be conveniently downloaded and run without any installation. See [USING] Zonemaster-CLI for how to run Zonemaster-CLI on Docker. To build your own Docker image, see the [Docker Image Creation] documentation. ## Documentation Other than the installation documentation, no specific documentation is needed. The [USING] document provides an overview on how to use the CLI. ## Participation, Contact and Bug reporting For participation, contact and bug reporting, please see the main [Zonemaster README]. ## License This is free software under a 2-clause BSD license. The full text of the license can be found in the [LICENSE](LICENSE) file included in this respository. [Docker Image Creation]: https://github.com/zonemaster/zonemaster/blob/master/docs/internal/maintenance/ReleaseProcess-create-docker-image.md [Docker Hub]: https://hub.docker.com/u/zonemaster [Installation]: https://github.com/zonemaster/zonemaster/blob/master/docs/public/installation/zonemaster-cli.md [USING]: https://github.com/zonemaster/zonemaster/blob/master/docs/public/using/cli.md [Zonemaster-Engine installation]: https://github.com/zonemaster/zonemaster/blob/master/docs/public/installation/zonemaster-engine.md [Zonemaster README]: https://github.com/zonemaster/zonemaster/blob/master/README.md [Zonemaster repository]: https://github.com/zonemaster/zonemaster Zonemaster-CLI-v6.0.3/MANIFEST000644 001754 001754 00000001432 14446600336 016073 0ustar00matsdmatsd000000 000000 Changes CONTRIBUTING.md inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/External.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/Scripts.pm inc/Module/Install/Share.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Zonemaster/CLI.pm LICENSE Makefile.PL MANIFEST This list of files META.yml README.md script/zonemaster-cli script/zonemaster-info share/GNUmakefile share/Makefile share/locale/da/LC_MESSAGES/Zonemaster-CLI.mo share/locale/es/LC_MESSAGES/Zonemaster-CLI.mo share/locale/fi/LC_MESSAGES/Zonemaster-CLI.mo share/locale/fr/LC_MESSAGES/Zonemaster-CLI.mo share/locale/nb/LC_MESSAGES/Zonemaster-CLI.mo share/locale/sv/LC_MESSAGES/Zonemaster-CLI.mo t/00-load.t Zonemaster-CLI-v6.0.3/t/00-load.t000644 001754 001754 00000000350 14464322367 016531 0ustar00matsdmatsd000000 000000 use 5.014002; use strict; use warnings FATAL => 'all'; use Test::More; plan tests => 1; BEGIN { use_ok( 'Zonemaster::CLI' ) || print "Bail out!\n"; } diag( "Testing Zonemaster::CLI $Zonemaster::CLI::VERSION, Perl $], $^X" ); Zonemaster-CLI-v6.0.3/lib/Zonemaster/000755 001754 001754 00000000000 14476561000 017634 5ustar00matsdmatsd000000 000000 Zonemaster-CLI-v6.0.3/lib/Zonemaster/CLI.pm000755 001754 001754 00000071715 14476560733 020633 0ustar00matsdmatsd000000 000000 # Brief help module to define the exception we use for early exits. package Zonemaster::Engine::Exception::NormalExit; use Moose; extends 'Zonemaster::Engine::Exception'; # The actual interesting module. package Zonemaster::CLI; use 5.014002; use strict; use warnings; use version; our $VERSION = version->declare( "v6.0.3" ); use Locale::TextDomain 'Zonemaster-CLI'; use Moose; with 'MooseX::Getopt::GLD' => { getopt_conf => [ 'pass_through' ] }; use Encode; use File::Slurp; use JSON::XS; use List::Util qw[max]; use POSIX qw[setlocale LC_MESSAGES LC_CTYPE]; use Scalar::Util qw[blessed]; use Socket qw[AF_INET AF_INET6]; use Text::Reflow qw[reflow_string]; use Try::Tiny; use Zonemaster::Engine; use Zonemaster::Engine::Exception; use Zonemaster::Engine::Logger::Entry; use Zonemaster::Engine::Translator; use Zonemaster::Engine::Util qw[parse_hints pod_extract_for]; use Zonemaster::Engine::Zone; use Zonemaster::LDNS; our %numeric = Zonemaster::Engine::Logger::Entry->levels; our $JSON = JSON::XS->new->allow_blessed->convert_blessed->canonical; STDOUT->autoflush( 1 ); has 'version' => ( is => 'ro', isa => 'Bool', default => 0, required => 0, documentation => __( 'Print version information and exit.' ), ); has 'level' => ( is => 'ro', isa => 'Str', required => 0, default => 'NOTICE', initializer => sub { my ( $self, $value, $set, $attr ) = @_; $set->( uc $value ); }, documentation => __( 'The minimum severity level to display. Must be one of CRITICAL, ERROR, WARNING, NOTICE, INFO or DEBUG.' ), ); has 'locale' => ( is => 'ro', isa => 'Str', required => 0, documentation => __( 'The locale to use for messages translation.' ), ); has 'json' => ( is => 'rw', isa => 'Bool', default => 0, documentation => __( 'Flag indicating if output should be in JSON or not.' ), ); has 'json_stream' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Bool', default => 0, cmd_aliases => 'json_stream', cmd_flag => 'json-stream', documentation => __( 'Flag indicating if output should be streaming JSON or not.' ), ); has 'json_translate' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Bool', cmd_aliases => 'json_translate', cmd_flag => 'json-translate', documentation => __( 'Deprecated. Flag indicating if JSON output should include the translated message of the tag or not.' ), ); has 'raw' => ( is => 'rw', isa => 'Bool', documentation => __( 'Flag indicating if output should be translated to human language or dumped raw.' ), ); has 'time' => ( is => 'ro', isa => 'Bool', documentation => __( 'Print timestamp on entries.' ), default => 1, ); has 'show_level' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Bool', cmd_aliases => 'show_level', cmd_flag => 'show-level', documentation => __( 'Print level on entries.' ), default => 1, ); has 'show_module' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Bool', cmd_aliases => 'show_module', cmd_flag => 'show-module', documentation => __( 'Print the name of the module on entries.' ), default => 0, ); has 'show_testcase' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Bool', cmd_aliases => 'show_testcase', cmd_flag => 'show-testcase', documentation => __( 'Print the name of the test case on entries.' ), default => 0, ); has 'ns' => ( is => 'ro', isa => 'ArrayRef', documentation => __( 'A name/ip string giving a nameserver for undelegated tests, or just a name which will be looked up for IP addresses. Can be given multiple times.' ), ); has 'hints' => ( is => 'ro', isa => 'Str', required => 0, documentation => __( 'Name of a root hints file to override the defaults.' ), ); has 'save' => ( is => 'ro', isa => 'Str', required => 0, documentation => __( 'Name of a file to save DNS data to after running tests.' ), ); has 'restore' => ( is => 'ro', isa => 'Str', required => 0, documentation => __( 'Name of a file to restore DNS data from before running test.' ), ); has 'ipv4' => ( is => 'ro', isa => 'Bool', documentation => __( 'Flag to permit or deny queries being sent via IPv4. --ipv4 permits IPv4 traffic, --no-ipv4 forbids it.' ), ); has 'ipv6' => ( is => 'ro', isa => 'Bool', documentation => __( 'Flag to permit or deny queries being sent via IPv6. --ipv6 permits IPv6 traffic, --no-ipv6 forbids it.' ), ); has 'list_tests' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Bool', default => 0, cmd_aliases => 'list_tests', cmd_flag => 'list-tests', documentation => __( 'Instead of running a test, list all available tests.' ), ); has 'test' => ( is => 'ro', isa => 'ArrayRef', required => 0, documentation => __( 'Specify test to run. Should be either the name of a module, or the name of a module and the name of a method in that module separated by a "/" character (Example: "Basic/basic1"). The method specified must be one that takes a zone object as its single argument. This switch can be repeated.' ) ); has 'stop_level' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Str', required => 0, initializer => sub { my ( $self, $value, $set, $attr ) = @_; $set->( uc $value ); }, cmd_aliases => 'stop_level', cmd_flag => 'stop-level', documentation => __( 'As soon as a message at this level or higher is logged, execution will stop. Must be one of CRITICAL, ERROR, WARNING, NOTICE, INFO or DEBUG.' ) ); has 'profile' => ( is => 'ro', isa => 'Str', required => 0, documentation => __( 'Name of profile file to load. (DEFAULT)' ), ); has 'ds' => ( is => 'ro', isa => 'ArrayRef[Str]', required => 0, documentation => __( 'Strings with DS data on the form "keytag,algorithm,type,digest"' ), ); has 'count' => ( is => 'ro', isa => 'Bool', required => 0, documentation => __( 'Print a count of the number of messages at each level' ), ); has 'progress' => ( is => 'ro', isa => 'Bool', default => !!( -t STDOUT ), documentation => __( 'Boolean flag for activity indicator. Defaults to on if STDOUT is a tty, off if it is not. Disable with --no-progress.' ), ); has 'encoding' => ( is => 'ro', isa => 'Str', default => sub { my $locale = $ENV{LC_CTYPE} // 'C'; my ( $e ) = $locale =~ m|\.(.*)$|; $e //= 'UTF-8'; return $e; }, documentation => __( 'Name of the character encoding used for command line arguments' ), ); has 'nstimes' => ( is => 'ro', isa => 'Bool', required => 0, default => 0, documentation => __( 'At the end of a run, print a summary of the times (in milliseconds) the zone\'s name servers took to answer.' ), ); has 'dump_profile' => ( traits => [ 'Getopt' ], is => 'ro', isa => 'Bool', required => 0, default => 0, cmd_aliases => 'dump_profile', cmd_flag => 'dump-profile', documentation => __( 'Print the effective profile used in JSON format, then exit.' ), ); has 'sourceaddr' => ( is => 'ro', isa => 'Str', required => 0, documentation => __( 'Deprecated (planned removal: v2024.1). ' . 'Use --sourceaddr4 and/or --sourceaddr6. ' . 'Source IP address used to send queries. ' . 'Setting an IP address not correctly configured on a local network interface causes cryptic error messages.' ), ); has 'sourceaddr4' => ( is => 'ro', isa => 'Str', required => 0, documentation => __( 'Source IPv4 address used to send queries. ' . 'Setting an IPv4 address not correctly configured on a local network interface fails silently. ' . 'Can not be combined with --sourceaddr.' ), ); has 'sourceaddr6' => ( is => 'ro', isa => 'Str', required => 0, documentation => __( 'Source IPv6 address used to send queries. ' . 'Setting an IPv6 address not correctly configured on a local network interface fails silently. ' . 'Can not be combined with --sourceaddr.' ), ); has 'elapsed' => ( is => 'ro', isa => 'Bool', required => 0, default => 0, documentation => __( 'Print elapsed time (in seconds) at end of run.' ), ); sub run { my ( $self ) = @_; my @accumulator; my %counter; my $printed_something; if ( grep /^-/, @{ $self->extra_argv } ) { print "Unknown option: ", join( q{ }, grep /^-/, @{ $self->extra_argv } ), "\n"; print "Run \"zonemaster-cli -h\" to get the valid options\n"; exit; } if ( $self->locale ) { undef $ENV{LANGUAGE}; $ENV{LC_ALL} = $self->locale; } # Set LC_MESSAGES and LC_CTYPE separately (https://www.gnu.org/software/gettext/manual/html_node/Triggering.html#Triggering) if ( not defined setlocale( LC_MESSAGES, "" ) ) { printf STDERR __( "Warning: setting locale category LC_MESSAGES to %s failed (is it installed on this system?).\n\n" ), $ENV{LANGUAGE} || $ENV{LC_ALL} || $ENV{LC_MESSAGES}; } if ( not defined setlocale( LC_CTYPE, "" ) ) { printf STDERR __( "Warning: setting locale category LC_CTYPE to %s failed (is it installed on this system?).\n\n" ), $ENV{LC_ALL} || $ENV{LC_CTYPE}; } if ( $self->version ) { print_versions(); exit; } if ( $self->list_tests ) { print_test_list(); } if ( $self->sourceaddr ) { if ( $self->sourceaddr4 or $self->sourceaddr6 ) { die __( "Error: --sourceaddr can't be combined with --sourceaddr4 or --sourceaddr6." ) . "\n"; } printf STDERR "%s\n\n", __( "Warning: --sourceaddr is deprecated (planned removal: v2024.1). Use --sourceaddr4 and/or --sourceaddr6 instead." ); Zonemaster::Engine::Profile->effective->set( q{resolver.source}, $self->sourceaddr ); } if ( $self->sourceaddr4 ) { Zonemaster::Engine::Profile->effective->set( q{resolver.source4}, $self->sourceaddr4 ); } if ( $self->sourceaddr6 ) { Zonemaster::Engine::Profile->effective->set( q{resolver.source6}, $self->sourceaddr6 ); } # errors and warnings if ( $self->json_stream and not $self->json and grep( /^--no-?json$/, @{ $self->ARGV } ) ) { die __( "Error: --json-stream and --no-json can't be used together." ) . "\n"; } if ( defined $self->json_translate ) { unless ( $self->json or $self->json_stream ) { printf STDERR __( "Warning: --json-translate has no effect without either --json or --json-stream." ) . "\n"; } if ( $self->json_translate ) { printf STDERR __( "Warning: deprecated --json-translate, use --no-raw instead." ) . "\n"; } else { printf STDERR __( "Warning: deprecated --no-json-translate, use --raw instead." ) . "\n"; } } # align values $self->json( 1 ) if $self->json_stream; $self->raw( $self->raw // ( defined $self->json_translate ? !$self->json_translate : 0 ) ); # Filehandle for diagnostics output my $fh_diag = ( $self->json or $self->raw ) ? *STDERR # Structured output mode (e.g. JSON) : *STDOUT; # Human readable output mode if ( $self->profile ) { say $fh_diag __x( "Loading profile from {path}.", path => $self->profile ); my $json = read_file( $self->profile ); my $foo = Zonemaster::Engine::Profile->from_json( $json ); my $profile = Zonemaster::Engine::Profile->default; $profile->merge( $foo ); Zonemaster::Engine::Profile->effective->merge( $profile ); } # These two must come after any profile from command line has been loaded # to make any IPv4/IPv6 option override the profile setting. if ( defined ($self->ipv4) ) { Zonemaster::Engine::Profile->effective->set( q{net.ipv4}, 0+$self->ipv4 ); } if ( defined ($self->ipv6) ) { Zonemaster::Engine::Profile->effective->set( q{net.ipv6}, 0+$self->ipv6 ); } if ( $self->dump_profile ) { do_dump_profile(); } if ( $self->stop_level and not defined( $numeric{ $self->stop_level } ) ) { die __( "Failed to recognize stop level '" ) . $self->stop_level . "'.\n"; } if ( not defined $numeric{ $self->level } ) { die __( "--level must be one of CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG, DEBUG2 or DEBUG3.\n" ); } my $translator; $translator = Zonemaster::Engine::Translator->new unless $self->raw; $translator->locale( $self->locale ) if $translator and $self->locale; if ( $self->restore ) { Zonemaster::Engine->preload_cache( $self->restore ); } my $level_width = 0; foreach ( keys %numeric ) { if ( $numeric{ $self->level } <= $numeric{$_} ) { my $width_l10n = length( decode_utf8( translate_severity( $_ ) ) ); $level_width = $width_l10n if $width_l10n > $level_width; } } my %field_width = ( seconds => 7, level => $level_width, module => 12, testcase => 14 ); my %header_names = (); my %remaining_space = (); if ( $translator ) { %header_names = ( seconds => __( 'Seconds' ), level => __( 'Level' ), module => __( 'Module' ), testcase => __( 'Testcase' ), message => __( 'Message' ) ); foreach ( keys %header_names ) { $field_width{$_} = _max( $field_width{$_}, length( decode_utf8( $header_names{$_} ) ) ); $remaining_space{$_} = $field_width{$_} - length( decode_utf8( $header_names{$_} ) ); } } # Callback defined here so it closes over the setup above. Zonemaster::Engine->logger->callback( sub { my ( $entry ) = @_; $self->print_spinner() if $fh_diag eq *STDOUT; $counter{ uc $entry->level } += 1; if ( $numeric{ uc $entry->level } >= $numeric{ $self->level } ) { $printed_something = 1; if ( $self->json and $self->json_stream ) { my %r; $r{timestamp} = $entry->timestamp if $self->time; $r{module} = $entry->module if $self->show_module; $r{testcase} = $entry->testcase if $self->show_testcase; $r{tag} = $entry->tag; $r{level} = $entry->level if $self->show_level; $r{args} = $entry->args if $entry->args; $r{message} = $translator->translate_tag( $entry ) unless $self->raw; say $JSON->encode( \%r ); } elsif ( $self->json and not $self->json_stream ) { # Don't do anything } else { my $prefix = q{}; if ( $self->time ) { $prefix .= sprintf "%*.2f ", ${field_width{seconds}}, $entry->timestamp; } if ( $self->show_level ) { $prefix .= $self->raw ? $entry->level : translate_severity( $entry->level ); my $space_l10n = ${field_width{level}} - length( decode_utf8( translate_severity($entry->level) ) ) + 1; $prefix .= ' ' x $space_l10n; } if ( $self->show_module ) { $prefix .= sprintf "%-*s ", ${field_width{module}}, $entry->module; } if ( $self->show_testcase ) { $prefix .= sprintf "%-*s ", ${field_width{testcase}}, $entry->testcase; } if ( $self->raw ) { $prefix .= $entry->tag; my $message = $entry->string; $message =~ s/^[A-Z0-9:_]+//; # strip MODULE:TAG, they're coming in $prefix instead my @lines = split /\n/, $message; printf "%s%s %s\n", $prefix, ' ', shift @lines; for my $line ( @lines ) { printf "%s%s %s\n", $prefix, '>', $line; } } else { if ( $entry->level eq q{DEBUG3} and scalar( keys %{$entry->args} ) == 1 and defined $entry->args->{packet} ) { my $packet = $entry->args->{packet}; my $padding = q{ } x length $prefix; $entry->args->{packet} = q{}; printf "%s%s\n", $prefix, $translator->translate_tag( $entry ); foreach my $line ( split /\n/, $packet ) { printf "%s%s\n", $padding, $line; } } else { printf "%s%s\n", $prefix, $translator->translate_tag( $entry ); } } } } if ( $self->stop_level and $numeric{ uc $entry->level } >= $numeric{ $self->stop_level } ) { die( Zonemaster::Engine::Exception::NormalExit->new( { message => "Saw message at level " . $entry->level } ) ); } } ); if ( $self->profile ) { # Separate initialization from main output in human readable output mode print "\n" if $fh_diag eq *STDOUT; } if ( scalar @{ $self->extra_argv } > 1 ) { die __( "Only one domain can be given for testing. Did you forget to prepend an option with '--