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
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
~ /$BASE64_REGEXP/;
return encode_base64($bin, '');
}
sub to_string { shift->value }
sub TO_JSON { shift->value }
1;
=encoding utf-8
=head1 NAME
STIX::Common::Binary - Binary type
=head1
em value
=back
=head2 HELPERS
=over
=item $binary->TO_JSON
Helper for JSON encoders.
=item $binary->to_string
Encode the object in JSON.
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
SCHEMA =>
'https://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/marking-definition.json#/definitions/statement';
use constant PROPERTIES => (qw(statement));
JSON
Helper for JSON encoders.
=item $statement->to_hash
Return the object HASH.
=item $statement->to_string
Encode the object in JSON.
=item $statement->validate
Validate the object using JSON
onstant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/bundle.json';
use constant PROPERTIES => qw(type id objects);
use constant STIX_OBJEC
->TO_JSON
Helper for JSON encoders.
=item $bundle->to_hash
Return the object HASH.
=item $bundle->to_string
Encode the object in JSON.
=item $bundle->validate
Validate the object using JSON Sch
stant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/threat-actor.json';
use constant PROPERTIES => (
qw(type spec_version id created modif
r
=item $threat_actor->TO_JSON
Encode the object in JSON.
=item $threat_actor->to_hash
Return the object HASH.
=item $threat_actor->to_string
Encode the object in JSON.
=item $threat_actor->val
idate
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<h
t SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/marking-definition.json';
use constant PROPERTIES => (
qw(type spec_version id created),
arking_definition->TO_JSON
Helper for JSON encoders.
=item $marking_definition->to_hash
Return the object HASH.
=item $marking_definition->to_string
Encode the object in JSON.
=item $marking_def
inition->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 tr
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
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;
constant SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/core.json';
has type => (is => 'rw', default => sub { shift->STIX_OBJECT_TYPE }, requ
->TO_JSON
Helper for JSON encoders.
=item $object->to_hash
Return the object HASH.
=item $object->to_string
Encode the object in JSON.
=item $object->validate
Validate the object using JSON Sch
f $bin =~ /$HEX_REGEXP/;
return unpack('H*', $bin);
}
sub to_string { shift->value }
sub TO_JSON { shift->value }
1;
=encoding utf-8
=head1 NAME
STIX::Common::Hex - Hex type
=head1 SYNOP
=item value
=back
=head2 HELPERS
=over
=item $hex->TO_JSON
Encode the object in JSON.
=item $hex->to_string
Encode the object in JSON.
=back
=head1 SUPPORT
=head2 Bugs / Feature Requests
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
nt SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/granular-marking.json';
use constant PROPERTIES => qw(lang marking_ref selectors);
has lan
m $granular_marking->TO_JSON
Helper for JSON encoders.
=item $granular_marking->to_hash
Return the object HASH.
=item $granular_marking->to_string
Encode the object in JSON.
=item $granular_mark
ing->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
}[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
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
/$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
t SCHEMA =>
'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/common/external-reference.json';
use constant PROPERTIES => qw(source_name description url hashes e
xternal_reference->TO_JSON
Helper for JSON encoders.
=item $external_reference->to_hash
Return the object HASH.
=item $external_reference->to_string
Encode the object in JSON.
=item $external_re
ference->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 tr
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
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