e CSAF::Renderer::JSON;
use 5.010001;
use strict;
use warnings;
use utf8;
use Cpanel::JSON::XS;
use Moo;
extends 'CSAF::Renderer::Base';
sub render {
my $json = Cpanel::JSON::XS->new->utf8->c
af->build;
my $json_string = $json->encode($csaf);
return $json_string;
}
1;
__END__
=encoding utf-8
=head1 NAME
CSAF::Renderer::JSON - Render a CSAF document in JSON
=head1 SYNOPSIS
enderer::JSON;
my $renderer = CSAF::Renderer::JSON->new( csaf => $csaf );
my $json = $renderer->render;
=head1 DESCRIPTION
L<CSAF::Renderer::JSON> render the CSAF document in JSON format.
e tracking_id_to_well_filename);
use CSAF::ROLIE::Entries;
use CSAF::Options::ROLIE;
use Cpanel::JSON::XS;
use File::Basename;
use File::Find;
use File::Spec::Functions qw(catfile);
use Time::Piece;
ALSE => !!0;
my $CSAF_SCHEMAS = {'2.0' => 'https://docs.oasis-open.org/csaf/csaf/v2.0/csaf_json_schema.json'};
has options => (
isa => sub { Carp::croak q{Not "CSAF::Options::ROLIE" object} un
my $json = eval { Cpanel::JSON::XS->new->decode(file_read($feed_path)) };
Carp::croak "Failed to parse the ROLIE feed: $@" if ($@);
Carp::croak 'Invalid ROLIE feed' unless defined $json->{fe
use CSAF;
use CSAF::Util qw(file_read);
use CSAF::Schema;
use List::Util qw(first);
use Cpanel::JSON::XS;
use Moo;
has file => (is => 'ro');
has content => (is => 'ro');
has data => (is => '
$content;
my $json = eval { Cpanel::JSON::XS->new->decode($content) };
Carp::croak "Failed to parse the CSAF document: $@" if ($@);
$self->data($json);
}
my $data
SYNOPSIS
use CSAF::Parser;
my $parser = eval { CSAF::Parser->new(file => 'csaf-2023-01.json') };
Carp::croak "Failed to parse CSAF document" if ($@);
my $csaf = $parser->parse;
package CSAF::Util;
use 5.010001;
use strict;
use warnings;
use utf8;
use Cpanel::JSON::XS;
use Data::Dumper;
use File::Basename qw(dirname);
use File::Spec::Functions qw(catfile);
use GnuPG:
7 => 'DEBUG',
8 => 'TRACE',
);
{
no warnings qw{ redefine };
sub Time::Piece::TO_JSON { shift->datetime }
}
sub schema_cache_path { catfile(resources_path(), 'cache') }
sub tt_templ
$id =~ s/[^+\-a-z0-9]+/_/g; # Rif. 5.1 (Additional Conventions - Filename)
return "$id.json";
}
sub collect_product_ids {
my $item = shift;
my @product_ids = ();
my $
il qw(schema_cache_path);
use JSON::Validator;
our %SCHEMAS = (
'csaf-2.0' => 'https://docs.oasis-open.org/csaf/csaf/v2.0/os/schemas/csaf_json_schema.json',
'strict-csaf-2.0'
g/csaf/csaf/v2.0/os/schemas/csaf_json_schema.json?strict',
'csaf-2.0-provider' => 'https://docs.oasis-open.org/csaf/csaf/v2.0/os/schemas/provider_json_schema.json',
'csaf-2.0-aggregator' =>
/v2.0/os/schemas/aggregator_json_schema.json',
'cvss-v3.1' => 'https://www.first.org/cvss/cvss-v3.1.json',
'cvss-v3.0' => 'https://www.first.org/cvss/cvss-v3.0.json',
'cvss-v2.0' => 'http
elf) = @_;
my $csaf_id = $self->csaf->document->tracking->id;
my $csaf_json = $self->csaf->renderer->render;
my $csaf_directory = $self->direc
_current_release_date = $self->csaf->document->tracking->current_release_date->datetime;
my $json_file_path = catfile($csaf_directory, $csaf_file_year, $csaf_filename);
my $index_file_pat
ug("CSAF document : $csaf_filename");
$self->log->debug("CSAF document path : $json_file_path");
$self->log->debug("index.txt path : $index_file_path");
$self
;
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
t->{$attribute} = $self->$attribute if ($self->$attribute);
}
return $output;
}
sub TO_JSON { shift->TO_CSAF }
1;
__END__
=encoding utf-8
=head1 NAME
CSAF::Type::CVSS2
=head1 SYNOPSIS
AF::Renderer::JSON;
use CSAF::Renderer::HTML;
use Moo;
extends 'CSAF::Renderer::Base';
sub render {
my ($self, %options) = @_;
my $format = delete $options{'format'} || 'json';
my $re
nderer = {
json => sub { CSAF::Renderer::JSON->new($self->csaf) },
html => sub { CSAF::Renderer::HTML->new($self->csaf) },
};
if (defined $renderer->{lc $format}) {
re
)
Render a CSAF document.
Available options:
=over
=item format
Specify the render format (B<json> default, B<html>).
=back
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report
$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
}
=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
t->{$attribute} = $self->$attribute if ($self->$attribute);
}
return $output;
}
sub TO_JSON { shift->TO_CSAF }
1;
__END__
=encoding utf-8
=head1 NAME
CSAF::Type::CVSS3
=head1 SYNOPSIS
Moo;
use Carp;
sub TO_CSAF { Carp::croak 'Method "TO_CSAF" not implemented by subclass' }
sub TO_JSON { shift->TO_CSAF }
1;
__END__
=encoding utf-8
=head1 NAME
CSAF::Type::Base
=head1 SYNOPSIS
l methods from L<CSAF::Type::Base> and implements the following new ones.
=over
=item $type->TO_JSON
=item $type->TO_CSAF
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any
ntent => (is => 'rw', required => 1);
has summary => (is => 'rw');
sub TO_JSON {
my $self = shift;
my $json = {
id => $self->id,
title => $self->title,
=> $self->link,
content => $self->content
};
$json->{summary} = $self->summary if ($self->summary);
return $json;
}
1;
__END__
=encoding utf-8
=head1 NAME
CSAF::ROLIE::Fe
ntry->updated
=item $entry->link
=item $entry->content
=item $entry->summary
=item $entry->TO_JSON
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature reques
directory => './csaf-acme-advisories',
include_pattern => qr{acme-sa-2024-\d+\.json}
);
=head1 DESCRIPTION
L<CSAF::Options::Downloader> is a configurator of L<CSAF::Downloade
.domain.tld/advisories/csaf');
has feed_filename => (is => 'rw', default => 'csaf-feed-tlp-white.json');
has feed_id => (is => 'rw', trigger => 1, default => 'csaf-feed-tlp-white');
has feed_l
);
}
sub _trigger_feed_id {
my $self = shift;
$self->feed_filename($self->feed_id . '.json');
$self->feed_link([{rel => 'self', href => $self->feed_url}]);
}
sub feed_url {
my $s
n.tld/advisories/csaf>).
=item feed_filename
ROLIE feed filename (default C<csaf-feed-tlp-white.json>).
=item feed_id
ROLIE feed ID (default C<csaf-feed-tlp-white> or C<csaf-feed-tlp- + tlp_label>
2.0.json'},
cvss3 => {
oneOf => [
{'$ref' => 'https://www.first.org/cvss/cvss-v3.0.json'},
{'$ref' => 'https://www.first.org/cvss/cvss-v3.1.json'}
3.1' ? 'cvss-v3.1' : 'cvss-v3.0'));
my @schema_errors = $v->validate($cvss_v3->TO_JSON);
foreach my $schema_error (@schema_errors) {
$self->add_mes
AF::Schema->validator('cvss-v2.0');
my @schema_errors = $v->validate($cvss_v2->TO_JSON);
foreach my $schema_error (@schema_errors) {
$self->add_mes
;
__END__
=encoding utf-8
=head1 NAME
CSAF::Validator::Schema - Validate CSAF document using JSON Schema.
=head1 SYNOPSIS
use CSAF::Validator::Schema;
my $v = CSAF::Validator::Schema->
%s (%s - %s)', $_[0]->type, $_[0]->path, $_[0]->message, $_[0]->code, $_[0]->category;
}
sub TO_JSON {
return {
type => $_[0]->type,
category => $_[0]->category,
mes
=item path
=item type
=item category
=back
=head2 METHODS
=over
=item to_string
=item TO_JSON
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature request
n $item;
}
Carp::croak "Failed to load item class '$item_class': $@" if ($@);
}
sub TO_JSON { shift->TO_CSAF }
sub TO_CSAF {
my $self = shift;
my $output = [];
foreach my $