File Coverage

blib/lib/STIX/Observable/EmailMessage.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::EmailMessage;
2              
3 24     24   515 use 5.010001;
  24         98  
4 24     24   150 use strict;
  24         50  
  24         704  
5 24     24   114 use warnings;
  24         52  
  24         1325  
6 24     24   138 use utf8;
  24         90  
  24         199  
7              
8 24     24   1157 use STIX::Common::Timestamp;
  24         63  
  24         1271  
9 24     24   139 use Types::Standard qw(Bool Str HashRef InstanceOf);
  24         53  
  24         280  
10 24     24   55269 use Types::TypeTiny qw(ArrayLike);
  24         72  
  24         180  
11              
12 24     24   14588 use Moo;
  24         63  
  24         257  
13 24     24   11333 use namespace::autoclean;
  24         62  
  24         278  
14              
15             extends 'STIX::Observable';
16              
17 24         2666 use constant SCHEMA =>
18 24     24   2562 'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/email-message.json';
  24         57  
19              
20 24         1724 use constant PROPERTIES => (
21             qw(type id),
22             qw(spec_version object_marking_refs granular_markings defanged extensions),
23             qw(is_multipart date content_type from_ref sender_ref to_refs cc_refs bcc_refs subject received_lines additional_header_fields body body_multipart raw_email_ref)
24 24     24   158 );
  24         58  
25              
26 24     24   156 use constant STIX_OBJECT => 'SCO';
  24         58  
  24         1311  
27 24     24   164 use constant STIX_OBJECT_TYPE => 'email-message';
  24         64  
  24         10418  
28              
29             has is_multipart => (is => 'rw', required => 1, isa => Bool);
30              
31             has date => (
32             is => 'rw',
33             isa => InstanceOf ['STIX::Common::Timestamp'],
34             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
35             );
36              
37             has content_type => (is => 'rw', isa => Str);
38             has from_ref => (is => 'rw', isa => InstanceOf ['STIX::Obserbable::EmailAddr', 'STIX::Common::Identifier']);
39             has sender_ref => (is => 'rw', isa => InstanceOf ['STIX::Obserbable::EmailAddr', 'STIX::Common::Identifier']);
40              
41             has to_refs => (
42             is => 'rw',
43             isa => ArrayLike [InstanceOf ['STIX::Obserbable::EmailAddr', 'STIX::Common::Identifier']],
44             default => sub { STIX::Common::List->new }
45             );
46              
47             has cc_refs => (
48             is => 'rw',
49             isa => ArrayLike [InstanceOf ['STIX::Obserbable::EmailAddr', 'STIX::Common::Identifier']],
50             default => sub { STIX::Common::List->new }
51             );
52              
53             has bcc_refs => (
54             is => 'rw',
55             isa => ArrayLike [InstanceOf ['STIX::Obserbable::EmailAddr', 'STIX::Common::Identifier']],
56             default => sub { STIX::Common::List->new }
57             );
58              
59             has subject => (is => 'rw', isa => Str);
60             has received_lines => (is => 'rw', isa => ArrayLike [Str]);
61             has additional_header_fields => (is => 'rw', isa => HashRef);
62             has body => (is => 'rw', isa => Str);
63              
64             has body_multipart => (
65             is => 'rw',
66             isa => ArrayLike [InstanceOf ['STIX::Observable::Type::EmailMIMEPart']],
67             default => sub { STIX::Common::List->new }
68             );
69              
70             has raw_email_ref => (is => 'rw', isa => InstanceOf ['STIX::Observable::Artifact']);
71              
72             1;
73              
74             =encoding utf-8
75              
76             =head1 NAME
77              
78             STIX::Observable::EmailMessage - STIX Cyber-observable Object (SCO) - Email Message
79              
80             =head1 SYNOPSIS
81              
82             use STIX::Observable::EmailMessage;
83              
84             my $email_message = STIX::Observable::EmailMessage->new();
85              
86              
87             =head1 DESCRIPTION
88              
89             The Email Message Object represents an instance of an email message.
90              
91              
92             =head2 METHODS
93              
94             L inherits all methods from L
95             and implements the following new ones.
96              
97             =over
98              
99             =item STIX::Observable::EmailMessage->new(%properties)
100              
101             Create a new instance of L.
102              
103             =item $email_message->additional_header_fields
104              
105             Specifies any other header fields found in the email message, as a
106             dictionary.
107              
108             =item $email_message->bcc_refs
109              
110             Specifies the mailboxes that are 'BCC:' recipients of the email message.
111              
112             =item $email_message->cc_refs
113              
114             Specifies the mailboxes that are 'CC:' recipients of the email message.
115              
116             =item $email_message->content_type
117              
118             Specifies the value of the 'Content-Type' header of the email message.
119              
120             =item $email_message->date
121              
122             Specifies the date/time that the email message was sent.
123              
124             =item $email_message->from_ref
125              
126             Specifies the value of the 'From:' header of the email message.
127              
128             =item $email_message->id
129              
130             =item $email_message->message_id
131              
132             Specifies the Message-ID field of the email message.
133              
134             =item $email_message->raw_email_ref
135              
136             Specifies the raw binary contents of the email message, including both the
137             headers and body, as a reference to an Artifact Object.
138              
139             =item $email_message->received_lines
140              
141             Specifies one or more Received header fields that may be included in the
142             email headers.
143              
144             =item $email_message->sender_ref
145              
146             Specifies the value of the 'From' field of the email message.
147              
148             =item $email_message->subject
149              
150             Specifies the subject of the email message.
151              
152             =item $email_message->to_refs
153              
154             Specifies the mailboxes that are 'To:' recipients of the email message.
155              
156             =item $email_message->type
157              
158             The value of this property MUST be C.
159              
160             =back
161              
162              
163             =head2 HELPERS
164              
165             =over
166              
167             =item $email_message->TO_JSON
168              
169             Encode the object in JSON.
170              
171             =item $email_message->to_hash
172              
173             Return the object HASH.
174              
175             =item $email_message->to_string
176              
177             Encode the object in JSON.
178              
179             =item $email_message->validate
180              
181             Validate the object using JSON Schema
182             (see L).
183              
184             =back
185              
186              
187             =head1 SUPPORT
188              
189             =head2 Bugs / Feature Requests
190              
191             Please report any bugs or feature requests through the issue tracker
192             at L.
193             You will be notified automatically of any progress on your issue.
194              
195             =head2 Source Code
196              
197             This is open source software. The code repository is available for
198             public review and contribution under the terms of the license.
199              
200             L
201              
202             git clone https://github.com/giterlizzi/perl-STIX.git
203              
204              
205             =head1 AUTHOR
206              
207             =over 4
208              
209             =item * Giuseppe Di Terlizzi
210              
211             =back
212              
213              
214             =head1 LICENSE AND COPYRIGHT
215              
216             This software is copyright (c) 2024 by Giuseppe Di Terlizzi.
217              
218             This is free software; you can redistribute it and/or modify it under
219             the same terms as the Perl 5 programming language system itself.
220              
221             =cut