/www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
# perl 5.6 ready UTF-8 encoding adapted from JSON::PP
my %escapes = map { chr($_) => sprintf("%%%02X", $_) } 0..255;
$escapes{' '}="+";
my $unsafe_
ant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/artifact.json';
use constant PROPERTIES => (
qw(type id),
qw(spec_version obj
_JSON
Encode the object in JSON.
=item $artifact->to_hash
Return the object HASH.
=item $artifact->to_string
Encode the object in JSON.
=item $artifact->validate
Validate the object using JSON
onstant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/location.json';
use constant PROPERTIES => (
qw(type spec_version id created modifie
_JSON
Encode the object in JSON.
=item $location->to_hash
Return the object HASH.
=item $location->to_string
Encode the object in JSON.
=item $location->validate
Validate the object using JSON
nstant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/indicator.json';
use constant PROPERTIES => (
qw(type spec_version id created modifie
=over
=item $indicator->TO_JSON
Encode the object in JSON.
=item $indicator->to_hash
Return the object HASH.
=item $indicator->to_string
Encode the object in JSON.
=item $indicator->validate
ant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/course-of-action.json';
use constant PROPERTIES => (
qw(type spec_version id created mod
$course_of_action->TO_JSON
Encode the object in JSON.
=item $course_of_action->to_hash
Return the object HASH.
=item $course_of_action->to_string
Encode the object in JSON.
=item $course_of_act
ion->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
so be passed as JSON or
YAML. For example, if the C<tags> argument is defined as 'array', then all of
below are equivalent:
% mycmd --tags-yaml '[foo, bar, baz]'
% mycmd --tags-json '["foo","bar","
commands)
=item * Configurable output format (--format, --format-options)
By default C<yaml>, C<json>, C<text>, C<text-simple>, C<text-pretty> are
recognized.
=back
=head1 ABOUT THIS MANUAL
This
to be parsed using JSON, and then YAML. This is
convenient for common cases:
--aoa '[[1],[2],[3]]' # parsed as JSON
--hash '{a: 1, b: 2}' # parsed as YAML
For explicit JSON parsing, all argum
package STIX::Parser;
use 5.010001;
use strict;
use warnings;
use utf8;
use Cpanel::JSON::XS;
use STIX::Common::Hashes;
use STIX::Common::Identifier;
use STIX::Util qw(file_read);
use STIX;
use Moo
l::JSON::XS->new->filter_json_object(\&_filter_json_object)->decode($content);
Carp::croak "Failed to parse the STIX file: $@" if ($@);
return $parsed;
}
}
sub _filter_json_ob
RR "-- PROPERTY $property";
my $value = $_[0]->{$property};
if (ref($value) eq 'JSON::PP::Boolean') {
$value = !!1 if $value;
$value = !!0 if !$value;
SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/extension-definition.json';
use constant PROPERTIES => (
qw(type spec_version id created
sion_definition->TO_JSON
Helper for JSON encoders.
=item $extension_definition->to_hash
Return the object HASH.
=item $extension_definition->to_string
Encode the object in JSON.
=item $extension
_definition->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 issu
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
t SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/email-message.json';
use constant PROPERTIES => (
qw(type id),
qw(spec_version
=item $email_message->TO_JSON
Encode the object in JSON.
=item $email_message->to_hash
Return the object HASH.
=item $email_message->to_string
Encode the object in JSON.
=item $email_message->v
alidate
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
tant SCHEMA =>
'https://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/file.json#/definitions/windows-pe-optional-header-type';
use constant PROPERTIES =>
type->TO_JSON
Helper for JSON encoders.
=item $windows_pe_optional_header_type->to_hash
Return the object HASH.
=item $windows_pe_optional_header_type->to_string
Encode the object in JSON.
=item
$windows_pe_optional_header_type->validate
Validate the object using JSON Schema (see L<STIX::Schema>).
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
Please report any bugs or feature req
EMA =>
'https://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/windows-registry-key.json#/definitions/windows-registry-value-type';
use constant PROPERTIE
lue_type->TO_JSON
Helper for JSON encoders.
=item $windows_registry_value_type->to_hash
Return the object HASH.
=item $windows_registry_value_type->to_string
Encode the object in JSON.
=item $wi
ndows_registry_value_type->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 th
t SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/email-message.json#/definitions/mime-part-type';
use constant PROPERTIES => (qw(
bo
=item $mime_part_type->TO_JSON
Helper for JSON encoders.
=item $mime_part_type->to_hash
Return the object HASH.
=item $mime_part_type->to_string
Encode the object in JSON.
=item $mime_part_type-
>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 tracker
at
SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/x509-certificate.json#/definitions/x509-v3-extensions-type';
use constant PROPERTIES => (
nsions_type->TO_JSON
Encode the object in JSON.
=item $x509_v3_extensions_type->to_hash
Return the object HASH.
=item $x509_v3_extensions_type->to_string
Encode the object in JSON.
=item $x509_v
3_extensions_type->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 th
tant SCHEMA =>
'https://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/file.json#/definitions/windows-pe-section';
use constant PROPERTIES => (qw(
nam
section_type->TO_JSON
Helper for JSON encoders.
=item $windows_pe_section_type->to_hash
Return the object HASH.
=item $windows_pe_section_type->to_string
Encode the object in JSON.
=item $window
s_pe_section_type->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 th
m $raster_image_ext->TO_JSON
Helper for JSON encoders.
=item $raster_image_ext->to_hash
Return the object HASH.
=item $raster_image_ext->to_string
Encode the object in JSON.
=item $raster_image_
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
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
ant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/ipv4-addr.json';
use constant PROPERTIES => (
qw(type id),
qw(spec_version ob
=over
=item $ipv4_addr->TO_JSON
Encode the object in JSON.
=item $ipv4_addr->to_hash
Return the object HASH.
=item $ipv4_addr->to_string
Encode the object in JSON.
=item $ipv4_addr->validate
/$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
::Mail::ESMTP;
use JSON::PP ();
use Exporter qw< import >;
our @EXPORT_OK = qw<
mojo_ioloop_server_callback_factory
>;
our %EXPORT_TAGS = (all => \@EXPORT_OK);
sub _encode_json_pretty ($data) {
state $encoder = JSON::PP->new->ascii->canonical->pretty;
return $encoder->encode($data);
}
sub _require_class_module ($module) {
require_module($module) unless $module->can('new');
return
$log->trace(_encode_json_pretty($call_sequence))
if $log->is_trace;
$out eq 'accept';
}
catch {
my $e = $_;
$log->error(_encode_json_pretty($e->data));
u