File Coverage

blib/lib/STIX/ObservedData.pm
Criterion Covered Total %
statement 38 38 100.0
branch n/a
condition n/a
subroutine 13 13 100.0
pod n/a
total 51 51 100.0


line stmt bran cond sub pod time code
1             package STIX::ObservedData;
2              
3 24     24   544 use 5.010001;
  24         109  
4 24     24   149 use strict;
  24         50  
  24         689  
5 24     24   168 use warnings;
  24         51  
  24         1407  
6 24     24   154 use utf8;
  24         63  
  24         206  
7              
8 24     24   1051 use STIX::Common::List;
  24         60  
  24         1022  
9 24     24   132 use Types::Standard qw(Str InstanceOf Int);
  24         47  
  24         233  
10 24     24   89133 use Types::TypeTiny qw(ArrayLike);
  24         69  
  24         192  
11              
12 24     24   16455 use Moo;
  24         57  
  24         262  
13 24     24   11333 use namespace::autoclean;
  24         57  
  24         270  
14              
15             extends 'STIX::Common::Properties';
16              
17 24         2681 use constant SCHEMA =>
18 24     24   3146 'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sdos/observed-data.json';
  24         54  
19              
20 24         1691 use constant PROPERTIES => (
21             qw(type spec_version id created modified),
22             qw(created_by_ref revoked labels confidence lang external_references object_marking_refs granular_markings extensions),
23             qw(first_observed last_observed number_observed objects object_refs)
24 24     24   184 );
  24         47  
25              
26 24     24   192 use constant STIX_OBJECT => 'SDO';
  24         54  
  24         1213  
27 24     24   133 use constant STIX_OBJECT_TYPE => 'observed-data';
  24         49  
  24         8255  
28              
29             has first_observed => (
30             is => 'rw',
31             required => 1,
32             isa => InstanceOf ['STIX::Common::Timestamp'],
33             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
34             );
35              
36             has last_observed => (
37             is => 'rw',
38             required => 1,
39             default => sub { $_[0]->{first_observed} },
40             isa => InstanceOf ['STIX::Common::Timestamp'],
41             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
42             );
43              
44             has number_observed => (is => 'rw', isa => Int, required => 1);
45             has objects => (is => 'rw', isa => ArrayLike [Str], default => sub { STIX::Common::List->new });
46              
47             has object_refs => (
48             is => 'rw',
49             isa =>
50             ArrayLike [InstanceOf ['STIX::Observable', 'STIX::Relationship', 'STIX::Sighting', 'STIX::Common::Identifier']],
51             default => sub { STIX::Common::List->new }
52             );
53              
54             1;
55              
56             =encoding utf-8
57              
58             =head1 NAME
59              
60             STIX::ObservedData - STIX Domain Object (SDO) - Observed Data
61              
62             =head1 SYNOPSIS
63              
64             use STIX::ObservedData;
65              
66             my $observed_data = STIX::ObservedData->new();
67              
68              
69             =head1 DESCRIPTION
70              
71             Observed data conveys information that was observed on systems and
72             networks, such as log data or network traffic, using the Cyber Observable
73             specification.
74              
75              
76             =head2 METHODS
77              
78             L inherits all methods from L
79             and implements the following new ones.
80              
81             =over
82              
83             =item STIX::ObservedData->new(%properties)
84              
85             Create a new instance of L.
86              
87             =item $observed_data->first_observed
88              
89             The beginning of the time window that the data was observed during.
90              
91             =item $observed_data->id
92              
93             =item $observed_data->last_observed
94              
95             The end of the time window that the data was observed during.
96              
97             =item $observed_data->number_observed
98              
99             The number of times the data represented in the objects property was
100             observed. This MUST be an integer between 1 and 999,999,999 inclusive.
101              
102             =item $observed_data->object_refs
103              
104             A list of SCOs and SROs representing the observation.
105              
106             =item $observed_data->objects
107              
108             A dictionary of Cyber Observable Objects that describes the single 'fact'
109             that was observed.
110              
111             =item $observed_data->type
112              
113             The type of this object, which MUST be the literal C.
114              
115             =back
116              
117              
118             =head2 HELPERS
119              
120             =over
121              
122             =item $observed_data->TO_JSON
123              
124             Encode the object in JSON.
125              
126             =item $observed_data->to_hash
127              
128             Return the object HASH.
129              
130             =item $observed_data->to_string
131              
132             Encode the object in JSON.
133              
134             =item $observed_data->validate
135              
136             Validate the object using JSON Schema (see L).
137              
138             =back
139              
140              
141             =head1 SUPPORT
142              
143             =head2 Bugs / Feature Requests
144              
145             Please report any bugs or feature requests through the issue tracker
146             at L.
147             You will be notified automatically of any progress on your issue.
148              
149             =head2 Source Code
150              
151             This is open source software. The code repository is available for
152             public review and contribution under the terms of the license.
153              
154             L
155              
156             git clone https://github.com/giterlizzi/perl-STIX.git
157              
158              
159             =head1 AUTHOR
160              
161             =over 4
162              
163             =item * Giuseppe Di Terlizzi
164              
165             =back
166              
167              
168             =head1 LICENSE AND COPYRIGHT
169              
170             This software is copyright (c) 2024 by Giuseppe Di Terlizzi.
171              
172             This is free software; you can redistribute it and/or modify it under
173             the same terms as the Perl 5 programming language system itself.
174              
175             =cut