::Property> will internally preserve the case of property and
value types so that JSON serialization via the C<TO_JSON()> method will return
the original data structure.
Please see the documentation
($_[1])} }
sub value_type { lc($_[0]->{value_type}) }
sub value { $_[0]->{value} }
sub TO_JSON {
my $self = shift;
return [
$self->type,
$self->params,
$self->
ams->{$_[1]} }
sub value_type { $_[0]->{value_type} }
sub value { $_[0]->{value} }
sub TO_JSON {
my $self = shift;
return [
$self->type,
$self->params,
$self->
[] }
];
}
return %hash;
}
sub as_json {
my ($self, @args) = @_;
return $self->object->errors_as_json($self) if $self->object->can('errors_as_json');
return $self->as_rfc_7807;
}
sub as
rrors
$rfc{fields}->{$field} = $hash{$field};
}
}
return \%rfc;
}
sub TO_JSON { shift->as_json }
# Adds +message+ to the error messages and used validator type to +details+ on +attri
ing an error response compatible with
RFC-7807, an open standard for returning errors formated in JSON from web APIs.
Example response:
{
fields => {
attendees => [
"Atten
ON = '1.16.1'; # VERSION
use Rex::Interface::Connection::Base;
BEGIN {
LWP::UserAgent->use;
JSON::MaybeXS->use;
}
use Data::Dumper;
use base qw(Rex::Interface::Connection::Base);
sub new {
ltipart/form-data",
Content => $data
);
if ( $res->is_success ) {
return decode_json( $res->decoded_content );
}
else {
die("Error requesting /fs/upload.");
}
}
sub post {
>{port}
. "$service",
%{$header},
Content => encode_json($data)
);
if ( $res->is_success ) {
return decode_json( $res->decoded_content );
}
else {
die( "Error requesting
;
use Rex::Virtualization::LibVirt::info;
use Rex::Interface::File;
use Rex::Interface::Exec;
use JSON::MaybeXS;
require Rex::Commands::Run;
sub execute {
my ( $class, $vmname ) = @_;
unless ($v
o agent
$info->{has_kvm_agent_on_port} = 0;
last;
}
my $ref = decode_json($data);
delete $ref->{networkconfiguration}->{lo};
for my $net ( keys %{ $ref->{netw
defined by
an IANA registry; see:
=over
=item * L<https://www.iana.org/assignments/rdap-json-values/rdap-json-values.xhtml>
=back
=cut
sub type { $_[0]->{'type'} }
=pod
=head2 Remark Descriptio
se JSON;
use POSIX qw(getpwuid);
use Net::RDAP::UA;
use Net::RDAP::Registry::IANARegistry;
use vars qw($UA $REGISTRY);
use constant {
IP4_URL => 'https://data.iana.org/rdap/ipv4.json',
https://data.iana.org/rdap/ipv6.json',
DNS_URL => 'https://data.iana.org/rdap/dns.json',
ASN_URL => 'https://data.iana.org/rdap/asn.json',
TAG_URL => 'h
ttps://data.iana.org/rdap/object-tags.json',
CACHE_TTL => 86400,
};
use strict;
our $UA;
our $REGISTRY = {};
=pod
=head1 NAME
L<Net::RDAP::Registry> - a module which provides an int
stant {
IANA_REGISTRY_URL => 'https://www.iana.org/assignments/rdap-json-values/rdap-json-values.xml',
RDAP_TYPE_NOTICE_OR_REMARK_TYPE => 'notice and remark type',
s> - a module which provides interface to the RDAP values
registry.
=head1 DESCRIPTION
The RDAP JSON Values Registry was defined in RFC 7483 and lists the
permitted values of certain RDAP object pro
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
=cut
sub is_rdap { exists($_[0]->{'type'}) && $_[0]->{'type'} =~ /^application\/rdap/i }
sub TO_JSON {
my $self = shift;
my %hash = %{$self};
delete($hash{_document_url});
delete($h
P::Link> object with a C<rel> property of
C<related> and a C<type> property of C<application/rdap+json> (or C<undef>
if no subject object is found).
=cut
sub related {
my $self = shift;
for
ink ($self->links) {
if (q{related} eq $link->rel && $link->type =~ m/^application\/rdap\+json/) {
return $link;
}
}
return undef;
}
=head2 "Self" Link
$self
}
}
=pod
=head1 C<TO_JSON()>
C<Net::RDAP::Base> provides a C<TO_JSON()> so that any RDAP object can be
serialized back into JSON if your JSON serializer (L<JSON>, L<JSON::XS>, etc)
is configured
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 $
defined by bn IANA registry; see:
=over
=item * L<https://www.iana.org/assignments/rdap-json-values/rdap-json-values.xhtml>
=back
=cut
sub status { $_[0]->{'status'} ? @{$_[0]->{'status'}} : () }
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
A qw(sha256_hex);
use File::Slurp;
use File::stat;
use File::Spec;
use HTTP::Request::Common;
use JSON;
use MIME::Base64;
use Net::ASN;
use Net::RDAP::Error;
use Net::RDAP::Help;
use Net::RDAP::Object
my $file = File::Spec->catfile(
File::Spec->tmpdir,
sprintf(
'%s-%s.json',
ref($self),
sha256_hex(join(chr(0), (
$VERSION,
}
my $response = $self->ua->mirror($url, $file, $ttl, $lang);
my $data = eval { decode_json(scalar(read_file($file))) };
if ($response->code >= 400) {
return $self->error_from_
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;
:Commands::File;
use Rex::Commands::Download;
use Rex::Helper::Path;
use Rex::Helper::Encode;
use JSON::MaybeXS;
use Text::Glob 'glob_to_regex', 'match_glob';
use File::Basename 'basename';
@EXPORT
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);
se Rex::Interface::Fs;
use Rex::Interface::Exec;
use Rex::User::Linux;
use Rex::Helper::Path;
use JSON::MaybeXS;
use base qw(Rex::User::Linux);
sub new {
my $that = shift;
my $proto = ref($that
$script = q|
unlink $0;
print to_json([ getpwnam($ARGV[0]) ]);
|;
$fh->open( ">", $rnd_file );
$fh->write($script);
$fh->write( func_to_json() );
$fh->close;
my $data_str = i_ru
if ( $? != 0 ) {
die("Error getting user information for $user");
}
my $data = decode_json($data_str);
return (
name => $data->[0],
password => $data->[1],
uid => $
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