File Coverage

blib/lib/STIX/Sighting.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::Sighting;
2              
3 24     24   533 use 5.010001;
  24         115  
4 24     24   622 use strict;
  24         59  
  24         926  
5 24     24   134 use warnings;
  24         55  
  24         1412  
6 24     24   156 use utf8;
  24         55  
  24         201  
7              
8 24     24   827 use STIX::Common::List;
  24         53  
  24         897  
9 24     24   207 use Types::Standard qw(Bool Int Str InstanceOf);
  24         53  
  24         255  
10 24     24   101559 use Types::TypeTiny qw(ArrayLike);
  24         70  
  24         212  
11              
12 24     24   16360 use Moo;
  24         61  
  24         219  
13 24     24   12035 use namespace::autoclean;
  24         60  
  24         280  
14              
15             extends 'STIX::Common::Properties';
16              
17 24         2992 use constant SCHEMA =>
18 24     24   3233 'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sros/sighting.json';
  24         63  
19              
20 24         1816 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(description first_seen last_seen count sighting_of_ref observed_data_refs where_sighted_refs summary)
24 24     24   188 );
  24         58  
25              
26 24     24   151 use constant STIX_OBJECT => 'SRO';
  24         56  
  24         1314  
27 24     24   132 use constant STIX_OBJECT_TYPE => 'sighting';
  24         62  
  24         9353  
28              
29             has description => (is => 'rw');
30              
31             has first_seen => (
32             is => 'rw',
33             isa => InstanceOf ['STIX::Common::Timestamp'],
34             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
35             );
36              
37             has last_seen => (
38             is => 'rw',
39             isa => InstanceOf ['STIX::Common::Timestamp'],
40             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
41             );
42              
43             has count => (is => 'rw', isa => Int);
44              
45             has sighting_of_ref => (is => 'rw', isa => InstanceOf ['STIX::Common::Identifier', 'STIX::Object'], required => 1);
46              
47             has observed_data_refs => (
48             is => 'rw',
49             isa => ArrayLike [InstanceOf ['STIX::Observable', 'STIX::Common::Identifier']],
50             default => sub { STIX::Common::List->new }
51             );
52              
53             # TODO A list of ID references to the Identity or Location objects describing the entities or types of entities that saw the sighting.
54             has where_sighted_refs => (
55             is => 'rw',
56             isa => ArrayLike [InstanceOf ['STIX::Object', 'STIX::Common::Identifier']],
57             default => sub { STIX::Common::List->new }
58             );
59              
60             has summary => (is => 'rw', isa => Bool, coerce => 1);
61              
62             1;
63              
64             =encoding utf-8
65              
66             =head1 NAME
67              
68             STIX::Sighting - STIX Relationship Object (SRO) - Sighting
69              
70             =head1 SYNOPSIS
71              
72             use STIX::Sighting;
73              
74             my $sighting = STIX::Sighting->new();
75              
76              
77             =head1 DESCRIPTION
78              
79             A Sighting denotes the belief that something in CTI (e.g., an indicator,
80             malware, tool, threat actor, etc.) was seen.
81              
82              
83             =head2 METHODS
84              
85             L inherits all methods from L
86             and implements the following new ones.
87              
88             =over
89              
90             =item STIX::Sighting->new(%properties)
91              
92             Create a new instance of L.
93              
94             =item $sighting->count
95              
96             This is an integer between 0 and 999,999,999 inclusive and represents the
97             number of times the object was sighted.
98              
99             =item $sighting->description
100              
101             A description that provides more details and context about the Sighting.
102              
103             =item $sighting->first_seen
104              
105             The beginning of the time window during which the SDO referenced by the
106             sighting_of_ref property was sighted.
107              
108             =item $sighting->id
109              
110             =item $sighting->last_seen
111              
112             The end of the time window during which the SDO referenced by the
113             sighting_of_ref property was sighted.
114              
115             =item $sighting->observed_data_refs
116              
117             A list of ID references to the Observed Data objects that contain the raw
118             cyber data for this Sighting.
119              
120             =item $sighting->sighting_of_ref
121              
122             An ID reference to the object that has been sighted.
123              
124             =item $sighting->summary
125              
126             The summary property indicates whether the Sighting should be considered
127             summary data.
128              
129             =item $sighting->type
130              
131             The type of this object, which MUST be the literal C.
132              
133             =item $sighting->where_sighted_refs
134              
135             A list of ID references to the Identity or Location objects describing the
136             entities or types of entities that saw the sighting.
137              
138             =back
139              
140              
141             =head2 HELPERS
142              
143             =over
144              
145             =item $sighting->TO_JSON
146              
147             Encode the object in JSON.
148              
149             =item $sighting->to_hash
150              
151             Return the object HASH.
152              
153             =item $sighting->to_string
154              
155             Encode the object in JSON.
156              
157             =item $sighting->validate
158              
159             Validate the object using JSON Schema (see L).
160              
161             =back
162              
163              
164             =head1 SUPPORT
165              
166             =head2 Bugs / Feature Requests
167              
168             Please report any bugs or feature requests through the issue tracker
169             at L.
170             You will be notified automatically of any progress on your issue.
171              
172             =head2 Source Code
173              
174             This is open source software. The code repository is available for
175             public review and contribution under the terms of the license.
176              
177             L
178              
179             git clone https://github.com/giterlizzi/perl-STIX.git
180              
181              
182             =head1 AUTHOR
183              
184             =over 4
185              
186             =item * Giuseppe Di Terlizzi
187              
188             =back
189              
190              
191             =head1 LICENSE AND COPYRIGHT
192              
193             This software is copyright (c) 2024 by Giuseppe Di Terlizzi.
194              
195             This is free software; you can redistribute it and/or modify it under
196             the same terms as the Perl 5 programming language system itself.
197              
198             =cut