Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Pod::Usage since podlators minimum perl is now v5.12 #60

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions META.json

This file was deleted.

1 change: 0 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ my %WriteMakefile = (
'IO::Interactive' => '0',
'JSON' => '0',
'PerlIO::gzip' => '0',
'Pod::Usage' => '1.69',
},

'META_MERGE' => {
Expand Down
1 change: 0 additions & 1 deletion cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ requires 'Module::CPANfile';
requires 'Module::CoreList', '5.20181020';
requires 'Module::Extract::VERSION';
requires 'PerlIO::gzip';
requires 'Pod::Usage', '1.69';
requires 'version';

on 'test' => sub {
Expand Down
204 changes: 203 additions & 1 deletion script/cpan-audit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use IO::Interactive qw(is_interactive);

use CPAN::Audit;

our $VERSION = "1.501";
our $VERSION = "1.502";

__PACKAGE__->run( @ARGV ) unless caller;

Expand Down Expand Up @@ -216,6 +216,208 @@ sub usage {
my( $class, $exit_code ) = @_;
no warnings qw(once);
Pod::Usage::pod2usage( -input => $FindBin::Bin . "/" . $FindBin::Script );
print <<'HERE';
NAME
cpan-audit - Audit CPAN modules

SYNOPSIS
cpan-audit [command] [options]

Commands:

module [version range] audit module with optional version range (all by default)
modules [version range] audit module list with optional version range (all by default)
dist|release [version range] audit distribution with optional version range (all by default)
deps [directory] audit dependencies from the directory (. by default)
installed audit all installed modules
show [advisory id] show information about specific advisory

Options:

--ascii use ascii output
--fresh|f check the database for freshness (CPAN::Audit::FreshnessCheck)
--help|h show the help message and exit
--no-color switch off colors
--no-corelist ignore modules bundled with perl version
--perl include perl advisories
--quiet be quiet (overrules --verbose)
--verbose be verbose (off if --quiet in effect)
--version show the version and exit
--exit-zero always exit with 0 even if advisories are reported
--exclude <str> exclude/ignore the specified advisory/cve (multiple)
--exclude-file <file> read exclude/ignore patterns from file
--json output JSON

Examples:

cpan-audit dist Catalyst-Runtime
cpan-audit dist Catalyst-Runtime 7.0
cpan-audit dist Catalyst-Runtime '>5.48'

cpan-audit module Catalyst 7.0

cpan-audit modules "Catalyst;7.0" "Mojolicious;>8.40,<9.20"

cpan-audit deps .
cpan-audit deps /path/to/distribution

cpan-audit installed
cpan-audit installed local/
cpan-audit installed local/ --exclude CVE-2011-4116
cpan-audit installed local/ --exclude CVE-2011-4116 --exclude CVE-2011-123
cpan-audit installed local/ --exclude-file ignored-cves.txt

cpan-audit installed --json

cpan-audit installed --json --exit-zero

cpan-audit show CPANSA-Mojolicious-2018-03

DESCRIPTION
"cpan-audit" is a command line application that checks the modules or
distributions for known vulnerabilities. It is using its internal
database that is automatically generated from a hand-picked database
<https://github.com/briandfoy/cpan-security-advisory>.

"cpan-audit" does not connect to anything, that is why it is important
to keep it up to date. Every update of the internal database is released
as a new version. Ensure that you have the latest database by updating
CPAN::Audit frequently; the database can change daily. You can use
enable a warning for a possibly out-of-date database by adding
"--fresh", which warns if the database version is older than a month:

% cpan-audit --fresh ...
% cpan-audit -f ...

% env CPAN_AUDIT_FRESH_DAYS=7 cpan-audit -f ...

Finding dependencies
"cpan-audit" can automatically detect dependencies from the following
sources:

"Carton"
Parses cpanfile.snapshot file and checks the distribution versions.

cpanfile
Parses cpanfile taking into account the required versions.

It is assumed that if the required version of the module is less than a
version of a release with a known vulnerability fix, then the module is
considered affected.

JSON data
If you request JSON output, the data looks like

{
"meta" : {
... meta information ...
"dists": {
"<distribution1>": {
... distribution info ...
}
}
"errors" : [
... list of errors - if any ...
]
}

Meta information
The meta data contains information about the run of "cpan-audit".

{
"args": [
"Mojo::File",
"Mojo::UserAgent",
"LWP::UserAgent"
],
"cpan_audit": {
"version": "20230601.002"
},
"total_advisories": 19,
"command": "modules"
}

These information are shown

* cpan_audit

The version of "cpan_audit" that is used for the audit

* command

The command of "cpan_audit" that was run

* args

Arguments for the command

* total_advisories

Number of found advisories

Distribution information
For each distribution where at least one advisory was found, the JSON
looks like:

"Dist-Name": {
"queried_modules": [
"Queried::Namespace"
],
"version": "Any",
"advisories": [
{
... advisory data as in the audit database ...
},
... more advisories ...
]
},

The advisory data is basically the data from the database. So this
depends on what is known for the given advisory.

The distribution information contains:

* version

The version (range) that is checked for advisories. If there's no
version specified, all versions are checked and the version is
report as "Any".

* queried_modules

The actual namespaces queried, either from the command line or
another source, such as a cpanfile.

* advisories

A list of all vulnerabilities found for the version range

Exit values
In prior versions, "cpan-audit" exited with the number of advisories it
found. Starting with 1.001, if there are advisories found, "cpan-audit"
exits with 64 added to that number. The maximum number of reported
advisories is 62, since values over 126 are spoken for.

If the option "--exit-zero" is set "cpan-audit" exits always with a
normal exit code (0). This allows to use "cpan-audit" in build
environments together with bash exit mode activated ("set -e").

* 0 - no advisories found

* 2 - problem with program invocation, such as bad switches or values

* 64+n - advisories found. Subtract 64 to get the advisory count, up
to 62 advisories

* 255 - unspecified program error

LICENSE
Copyright (C) Viacheslav Tykhanovskyi.

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.HERE
HERE

exit( $exit_code );
}

Expand Down
Loading