it
will get set the default from schema during argument validation:
# via CLI
% progname --baz-json 'null'
# via wrapped function call
funcname(baz=>undef)
Function will receive C<bar> key in i
(bit|box|cidr|circle|date|inet|line|lseg|macaddr|money|numeric|decimal|path|point|polygon|varchar|json|hstore|uuid)/i
{
$return = { type => $item[1] };
}
parens_value_list
oluted like:
[%- SET item_list = [] -%]
[%- FOREACH i IN api_mt_result; item_list.push(i.json); END -%]
[% '\[% locale.makevar(' _ item_list.join(", ") _ ') %\]' | evaltt %]
=head2 $lh->
as some common options like C<--format> to return the result in a
different format:
% ./hello --json
[200,"OK","Hello, world!"]
% ./hello --format perl; # only in PC::Classic, not available in PC
ame Jimmy --name Sion --name Habil
Hello, Jimmy!
Hello, Sion!
Hello, Habil!
% ./hello --name-json '["Jimmy","Sion","Habil"]' --gender m
Hello, Mr. Jimmy!
Hello, Mr. Sion!
Hello, Mr. Habil!
So
ither specify multiple times (e.g. C<--name
NAME1 --name NAME2 ...>) or specify using JSON (i.e. C<--name-json JSONSTR>).
Second, the C<name> argument specifies the C<slurpy> property. This is used i
package STIX::Common::Hashes;
use 5.010001;
use strict;
use warnings;
use utf8;
use Cpanel::JSON::XS;
use Types::Standard qw(Str);
use Moo;
use namespace::autoclean;
extends 'STIX::Object';
use c
Str);
has ssdeep => (is => 'rw', isa => Str);
has tlsh => (is => 'rw', isa => Str);
sub TO_JSON {
my $self = shift;
my $hashes = {};
$hashes->{'md5'} = $self->md5 if (
$self->tlsh);
return $hashes;
}
sub to_hash { shift->TO_JSON }
sub to_string {
my $self = shift;
my $json = Cpanel::JSON::XS->new->utf8->canonical->allow_nonref->allow_unknown->allow
scalars (check at most 5 elements), print
as table.
7) otherwise print as JSON (after cleaning it with L<Data::Clean::JSON>).
YAML and the other formats are not supported.
Table is printed using t
onstant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/incident.json';
use constant PROPERTIES => (
qw(type spec_version id created modifie
_JSON
Encode the object in JSON.
=item $incident->to_hash
Return the object HASH.
=item $incident->to_string
Encode the object in JSON.
=item $incident->validate
Validate the object using JSON
stream_ext->TO_JSON
Helper for JSON encoders.
=item $alternate_data_stream_ext->to_hash
Return the object HASH.
=item $alternate_data_stream_ext->to_string
Encode the object in JSON.
=item $alte
rnate_data_stream_ext->validate
Validate the object using JSON Schema (see L<STIX::Schema>).
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature requests throug
nt SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/kill-chain-phase.json';
use constant PROPERTIES => qw(kill_chain_name phase_name);
has kil
m $kill_chain_phase->TO_JSON
Helper for JSON encoders.
=item $kill_chain_phase->to_hash
Return the object HASH.
=item $kill_chain_phase->to_string
Encode the object in JSON.
=item $kill_chain_ph
ase->validate
Validate the object using JSON Schema (see L<STIX::Schema>).
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracke
constant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/note.json';
use constant PROPERTIES => (
qw(type spec_version id created modified)
te->TO_JSON
Encode the object in JSON.
=item $note->to_hash
Return the object HASH.
=item $note->to_string
Encode the object in JSON.
=item $note->validate
Validate the object using JSON Schema
rter 'import';
use File::Basename qw(dirname);
use File::Spec::Functions qw(catfile);
use JSON::Validator;
use Moo;
use constant DEBUG => $ENV{STIX_DEBUG} || 0;
has object => (is => 'ro');
path { catfile(dirname(__FILE__), 'cache') }
sub validator {
my ($self) = @_;
my $jv = JSON::Validator->new;
DEBUG and say sprintf('-- Load validator and use %s schema', $self->object-
rn $self->validator->validate($self->object);
}
1;
=encoding utf-8
=head1 NAME
STIX::Schema - JSON Schema Validator
=head1 SYNOPSIS
use STIX::Schema;
my $validator = STIX::Schema->new(o
/$regexp/);
}
Carp::carp 'Malformed timestamp';
return Time::Piece->new;
}
sub TO_JSON { shift->value->datetime . '.000Z' }
1;
=encoding utf-8
=head1 NAME
STIX::Common::Timestamp -
lue
=back
=head2 HELPERS
=over
=item $timestamp->TO_JSON
Encode the object in JSON.
=item $timestamp->to_string
Encode the object in JSON.
=back
=head1 SUPPORT
=head2 Bugs / Feature Request
}[0] }
sub last { $_[0]->{collections}[-1] }
sub to_array { [@{$_[0]->{collections}}] }
sub TO_JSON { [@{$_[0]->{collections}}] }
1;
__END__
=encoding utf-8
=head1 NAME
STIX::Common::List - Co
->unshift('baz');
=item $c->to_array
Return the collection ARRAY.
=item $c->TO_JSON
Convert the collenction in JSON.
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs
nt SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/email-addr.json';
use constant PROPERTIES => (
qw(type id),
qw(spec_version ob
=over
=item $email_addr->TO_JSON
Encode the object in JSON.
=item $email_addr->to_hash
Return the object HASH.
=item $email_addr->to_string
Encode the object in JSON.
=item $email_addr->validat
e
Validate the object using JSON Schema
(see L<STIX::Schema>).
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracker
at L<https
ant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/mac-addr.json';
use constant PROPERTIES =>
(qw(type id), qw(spec_version object_m
_JSON
Encode the object in JSON.
=item $mac_addr->to_hash
Return the object HASH.
=item $mac_addr->to_string
Encode the object in JSON.
=item $mac_addr->validate
Validate the object using JSON
m $http_request_ext->TO_JSON
Helper for JSON encoders.
=item $http_request_ext->to_hash
Return the object HASH.
=item $http_request_ext->to_string
Encode the object in JSON.
=item $http_request_
ext->validate
Validate the object using JSON Schema (see L<STIX::Schema>).
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature requests through the issue tracke
onstant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sros/sighting.json';
use constant PROPERTIES => (
qw(type spec_version id created modifie
_JSON
Encode the object in JSON.
=item $sighting->to_hash
Return the object HASH.
=item $sighting->to_string
Encode the object in JSON.
=item $sighting->validate
Validate the object using JSON
O_JSON
Helper for JSON encoders.
=item $icmp_ext->to_hash
Return the object HASH.
=item $icmp_ext->to_string
Encode the object in JSON.
=item $icmp_ext->validate
Validate the object using JSON
dows_service_ext->TO_JSON
Helper for JSON encoders.
=item $windows_service_ext->to_hash
Return the object HASH.
=item $windows_service_ext->to_string
Encode the object in JSON.
=item $windows_se
rvice_ext->validate
Validate the object using JSON Schema (see L<STIX::Schema>).
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature requests through the issue
as some common options like C<--format> to return the result in a
different format:
% ./hello --json
[200,"OK","Hello, world!"]
% ./hello --format perl; # only in PC::Classic, not available in PC
ame Jimmy --name Sion --name Habil
Hello, Jimmy!
Hello, Sion!
Hello, Habil!
% ./hello --name-json '["Jimmy","Sion","Habil"]' --gender m
Hello, Mr. Jimmy!
Hello, Mr. Sion!
Hello, Mr. Habil!
So
ither specify multiple times (e.g. C<--name
NAME1 --name NAME2 ...>) or specify using JSON (i.e. C<--name-json JSONSTR>).
Second, the C<name> argument specifies the C<slurpy> property. This is used i