shift->{scores}->{impact} }
sub modified_impact_score { shift->{scores}->{modified_impact} }
# JSON-style alias
sub vectorString { shift->vector_string }
sub baseScore { shift-
ics->{$metric});
}
}
return join '/', @vectors;
}
sub TO_JSON {
my ($self) = @_;
# Required JSON fields:
# CVSS == v2.0: version, vectorString and baseScore
#
ring, baseScore and baseSeverity
$self->calculate_score unless ($self->base_score);
my $json = {
version => sprintf('%.1f', $self->version),
vectorString => $self->vecto
}
=head1 DESCRIPTION
L<CSAF::Validator> reads documents and performs a check against the JSON schema
(L<CSAF::Validator::Schema>), performs all mandatory (L<CSAF::Validator::MandatoryTests>)
:
=over
=item * CSAF basic validator: A program that reads a document and checks it against the JSON schema and performs mandatory tests.
=item * CSAF extended validator: A CSAF basic validator tha
$skip_validation) {
$self->csaf->validator->validate;
}
return $csaf;
}
sub TO_JSON { shift->build }
1;
__END__
=encoding utf-8
=head1 NAME
CSAF::Builder - Build the CSAF docu
;
use CSAF::Options::Downloader;
use CSAF::Util qw(file_read gpg_verify);
use CSAF;
use Cpanel::JSON::XS;
use File::Basename;
use File::Path qw(make_path);
use File::Spec::Functions qw(ca
= 1 if ($url =~ /\/index\.txt$/);
$is_provider_metadata = 1 if ($url =~ /\/provider-metadata\.json$/);
my $ua = $self->ua;
my $log = $self->log;
$log->info("Check: $url");
if (
my $base_url = $url;
$base_url =~ s/\/index\.txt$//;
$base_url =~ s/\/provider-metadata\.json$//;
return $self->_mirror_via_index_txt($base_url) if ($is_index_txt);
return $s
tDetector::Handlers::CommandInjection;
use strict;
use warnings;
use Exporter 'import';
use JSON;
use Time::HiRes qw(gettimeofday);
our $VERBOSE = 0;
our @EXPORT_OK = qw(handle_command_inje
t => $entry->{user_agent},
};
push @COMMAND_INJECTION_EVENTS, $alert;
print encode_json($alert) . "\n" if $VERBOSE;
}
sub get_command_injection_events {
return @COMMAND_INJECTION
ndle_command_injection);
handle_command_injection($entry);
=head1 DESCRIPTION
Prints a JSON alert for requests that appear to contain command injection or remote/local file inclusion attemp
hreatDetector::Handlers::SQLInjection;
use strict;
use warnings;
use Exporter 'import';
use JSON;
use Time::HiRes qw(gettimeofday);
our $VERBOSE = 0;
our @EXPORT_OK = qw(handle_sql_injectio
eferer => $entry->{referer} || '',
};
push @SQLI_EVENTS, $alert;
print encode_json($alert) . "\n" if $VERBOSE;
}
sub get_sqli_events {
return @SQLI_EVENTS;
}
1;
=head
ion qw(handle_sql_injection);
handle_sql_injection($entry);
=head1 DESCRIPTION
Emits a JSON-formatted alert when a request appears to contain SQL injection payloads. Common indicators inclu
{json => 'accessVector', values => $AV},
AC => {json => 'accessComplexity', values => $AC},
Au => {json => 'authentication', values => $Au},
C => {json =
s => $C},
I => {json => 'integrityImpact', values => $I},
A => {json => 'availabilityImpact', values => $A},
# Temporal
E => {json => 'exploitability', v
es => $E},
RL => {json => 'remediationLevel', values => $RL},
RC => {json => 'reportConfidence', values => $RC},
# Environmental
CDP => {json => 'collateralDamagePoten
il::AuthenticationResults::Token::Separator;
use Mail::AuthenticationResults::Token::String;
use JSON;
sub new {
my ( $class, $auth_header ) = @_;
my $self = {};
bless $self, $class;
self->parsed();
}
sub from_authentication_results_json {
my ( $self, $json ) = @_;
my $j = JSON->new();
my $hashref = $j->decode( $json );
return $self->_from_hashref( $hashref );
}
er and return the parsed object.
=head2 from_authentication_results_json( $json )
Parse $json as the json returned from an as_json method call and return the parsed object.
=head2 tokenise( $header
e::HiRes qw(gettimeofday);
use JSON;
use File::Slurp;
# ----- CONFIG -----
my $config_file = 'config/config.json';
my $config_data = -e $config_file ? decode_json(scalar read_file($config_file)
atmandu->exporter('JSON', pretty => 1, array => 0);
}
1;
__END__
=pod
=head1 NAME
Catmandu::Cmd::config - export the Catmandu config
=head1 EXAMPLES
# export config to JSON
catmandu config
SH key or ARRAY index by replacing
its value with imported data
=head1 SYNOPSIS
import(foo.bar, JSON, file: "http://foo.com/bar.json", data_path: data.*)
=head1 SEE ALSO
L<Catmandu::Fix>
=cut
exporter
=head1 SYNOPSIS
export_to_string(my.field,'YAML')
export_to_string(my.field2,'JSON')
export_to_string(my.field3,'CSV', 'sep_char' => ';' )
=head1 DESCRIPTION
=head2 export_s
choose:
* full package name of the exporter (e.g. 'Catmandu::Exporter::JSON')
* short package name of the exporter (e.g. 'JSON')
* name of the exporter as declared in the Catmandu configuration
=i
r->new(data => $_[1])->parse }
sub to_string { shift->renderer->render }
sub TO_JSON { shift->builder->TO_JSON }
1;
__END__
=encoding utf-8
=head1 NAME
CSAF - Common Security Advisory Frame
vulnerabilities
Return L<CSAF::Type::Vulnerabilities>.
=back
=head2 HELPERS
=over
=item TO_JSON
=item builder
Return L<CSAF::Builder>.
=item render
Alias for C<renderer-E<gt>render($format)
le
Parse CSAF document file and return L<CSAF>.
=item to_string
Render CSAF document.
my $json = $csaf->to_string;
=item writer
Return L<CSAF::Writer>.
=back
=head1 SUPPORT
=head2 Bugs /
package ThreatDetector::Dispatcher;
use strict;
use warnings;
use JSON;
use File::Basename;
use Time::HiRes qw(gettimeofday);
use ThreatDetector::Handlers::SQLInjection qw(handle_sql_injecti
pes. Each handler is responsible for processing or logging the alert in its own way (typically as JSON output).
The dispatch system uses a mapping of known threat types to handler subroutine refere
qw(make_path);
use File::Slurp;
use IPC::System::Simple qw(system);
use Term::ANSIColor;
use JSON;
# NOT finished
my $key_path = "$ENV{HOME}/.ssh/id_rsa.pub";
my $private_key = "$ENV{
GetOptionsFromArray :config gnu_compat);
use Pod::Usage qw(pod2usage);
use Carp ();
use JSON::PP ();
use Data::Dumper ();
use URI::PackageURL ();
our $VERSION = '2.23';
sub cli_error
DERR "ERROR: $error\n";
}
sub run {
my ($class, @args) = @_;
my %options = (format => 'json');
GetOptionsFromArray(
\@args, \%options, qw(
help|h
man
alifiers|qualifier=s%
subpath=s
null|0
format=s
json
yaml
dumper
env
)
) or pod2usage(-verbose => 0);
file:/tmp/test.txt, header: 1)
# Export the complete record into a JSON file
add_to_exporter(data,JSON, file:/tmp/test.json, pretty:1)
# In general, export a PATH to an EXPORTER with one or
add_to_exporter(.,JSON)
end
# You can get an output with 3 records using the command line function
catmandu convert JSON to Null --fix exporter.fix < book.json
=head1 SEE ALSO
L<Catm
;
use warnings;
our $VERSION = '2.20250709'; # VERSION
use Scalar::Util qw{ weaken refaddr };
use JSON;
use Carp;
use Clone qw{ clone };
use Mail::AuthenticationResults::Header::Group;
use Mail::Auth
$hashref->{'children'} = \@children;
}
return $hashref;
}
sub as_json {
my ( $self ) = @_;
my $J = JSON->new();
$J->canonical();
return $J->encode( $self->_as_hashref() );
bject when calledas a child
of another objects as_string method call.
=head2 as_json()
Return this instance as a JSON serialised string
=head2 as_string()
Returns this instance as a string.
=head
ote characters make it more difficult to transport the lines in
typical string-based APIs like in JSON payload. We completely drop
them (i.e., there is no replacement character):
A line like
ok fo
etector::Handlers::DirectoryTraversal;
use strict;
use warnings;
use Exporter 'import';
use JSON;
use Time::HiRes qw(gettimeofday);
our $VERBOSE = 0;
our @EXPORT_OK = qw(handle_directory_tr
=> $entry->{user_agent},
};
push @DIRECTORY_TRAVERSAL_EVENTS, $alert;
print encode_json($alert) . "\n" if $VERBOSE;
}
sub get_directory_traversal_events {
return @DIRECTORY_TRAVE
_directory_traversal);
handle_directory_traversal($entry);
=head1 DESCRIPTION
Prints a JSON alert for requests containing suspected directory traversal patterns such as `../`, URL-encoded t