File Coverage

blib/lib/STIX/Observable/Artifact.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::Observable::Artifact;
2              
3 24     24   513 use 5.010001;
  24         105  
4 24     24   182 use strict;
  24         68  
  24         742  
5 24     24   146 use warnings;
  24         74  
  24         1556  
6 24     24   172 use utf8;
  24         55  
  24         201  
7              
8 24     24   12944 use STIX::Common::Binary;
  24         96  
  24         1124  
9 24     24   262 use STIX::Common::Enum;
  24         61  
  24         910  
10 24     24   147 use Types::Standard qw(Str InstanceOf Enum);
  24         55  
  24         248  
11              
12 24     24   56431 use Moo;
  24         64  
  24         152  
13 24     24   10824 use namespace::autoclean;
  24         63  
  24         267  
14              
15             extends 'STIX::Observable';
16              
17 24         3131 use constant SCHEMA =>
18 24     24   2964 'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/artifact.json';
  24         89  
19              
20 24         2013 use constant PROPERTIES => (
21             qw(type id),
22             qw(spec_version object_marking_refs granular_markings defanged extensions),
23             qw(mime_type payload_bin url hashes encryption_algorithm decryption_key),
24 24     24   212 );
  24         67  
25              
26 24     24   162 use constant STIX_OBJECT => 'SCO';
  24         47  
  24         1666  
27 24     24   146 use constant STIX_OBJECT_TYPE => 'artifact';
  24         53  
  24         7151  
28              
29             has mime_type => (is => 'rw', isa => Str);
30              
31             has payload_bin => (
32             is => 'rw',
33             isa => InstanceOf ['STIX::Common::Binary'],
34             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Binary->new($_[0]) }
35             );
36              
37             has url => (is => 'rw', isa => Str);
38             has hashes => (is => 'rw', isa => InstanceOf ['STIX::Common::Hashes']);
39             has encryption_algorithm => (is => 'rw', isa => Enum [STIX::Common::Enum->ENCRYPTION_ALGORITHM()]);
40             has decryption_key => (is => 'rw', isa => Str);
41              
42             1;
43              
44             =encoding utf-8
45              
46             =head1 NAME
47              
48             STIX::Observable::Artifact - STIX Cyber-observable Object (SCO) - Artifact
49              
50             =head1 SYNOPSIS
51              
52             use STIX::Observable::Artifact;
53              
54             my $artifact = STIX::Observable::Artifact->new();
55              
56              
57             =head1 DESCRIPTION
58              
59             The Artifact Object permits capturing an array of bytes (8-bits), as a
60             base64-encoded string string, or linking to a file-like payload.
61              
62              
63             =head2 METHODS
64              
65             L inherits all methods from L
66             and implements the following new ones.
67              
68             =over
69              
70             =item STIX::Observable::Artifact->new(%properties)
71              
72             Create a new instance of L.
73              
74             =item $artifact->decryption_key
75              
76             Specifies the decryption key for the encrypted binary data (either via
77             payload_bin or url).
78              
79             =item $artifact->encryption_algorithm
80              
81             If the artifact is encrypted, specifies the type of encryption algorithm
82             the binary data (either via payload_bin or url) is encoded in.
83              
84             =item $artifact->hashes
85              
86             Specifies a dictionary of hashes for the contents of the url or the
87             payload_bin. This MUST be provided when the url property is present
88             (see L).
89              
90             =item $artifact->id
91              
92             =item $artifact->mime_type
93              
94             The value of this property MUST be a valid MIME type as specified in the
95             IANA Media Types registry.
96              
97             =item $artifact->payload_bin
98              
99             Specifies the binary data contained in the artifact as a base64-encoded
100             string.
101              
102             =item $artifact->type
103              
104             The value of this property MUST be C.
105              
106             =item $artifact->url
107              
108             The value of this property MUST be a valid URL that resolves to the
109             unencoded content.
110              
111             =back
112              
113              
114             =head2 HELPERS
115              
116             =over
117              
118             =item $artifact->TO_JSON
119              
120             Encode the object in JSON.
121              
122             =item $artifact->to_hash
123              
124             Return the object HASH.
125              
126             =item $artifact->to_string
127              
128             Encode the object in JSON.
129              
130             =item $artifact->validate
131              
132             Validate the object using JSON Schema
133             (see L).
134              
135             =back
136              
137              
138             =head1 SUPPORT
139              
140             =head2 Bugs / Feature Requests
141              
142             Please report any bugs or feature requests through the issue tracker
143             at L.
144             You will be notified automatically of any progress on your issue.
145              
146             =head2 Source Code
147              
148             This is open source software. The code repository is available for
149             public review and contribution under the terms of the license.
150              
151             L
152              
153             git clone https://github.com/giterlizzi/perl-STIX.git
154              
155              
156             =head1 AUTHOR
157              
158             =over 4
159              
160             =item * Giuseppe Di Terlizzi
161              
162             =back
163              
164              
165             =head1 LICENSE AND COPYRIGHT
166              
167             This software is copyright (c) 2024 by Giuseppe Di Terlizzi.
168              
169             This is free software; you can redistribute it and/or modify it under
170             the same terms as the Perl 5 programming language system itself.
171              
172             =cut
173