File Coverage

blib/lib/STIX/Observable/Directory.pm
Criterion Covered Total %
statement 35 35 100.0
branch n/a
condition n/a
subroutine 12 12 100.0
pod n/a
total 47 47 100.0


line stmt bran cond sub pod time code
1             package STIX::Observable::Directory;
2              
3 24     24   561 use 5.010001;
  24         104  
4 24     24   153 use strict;
  24         53  
  24         737  
5 24     24   129 use warnings;
  24         50  
  24         1416  
6 24     24   167 use utf8;
  24         52  
  24         255  
7              
8 24     24   1464 use Types::Standard qw(Str InstanceOf);
  24         58  
  24         234  
9 24     24   52319 use Types::TypeTiny qw(ArrayLike);
  24         63  
  24         215  
10              
11 24     24   15933 use Moo;
  24         61  
  24         225  
12 24     24   11183 use namespace::autoclean;
  24         64  
  24         242  
13              
14             extends 'STIX::Observable';
15              
16 24         2433 use constant SCHEMA =>
17 24     24   2694 'http://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/observables/directory.json';
  24         63  
18              
19 24         1778 use constant PROPERTIES => (
20             qw(type id),
21             qw(spec_version object_marking_refs granular_markings defanged extensions),
22             qw(path path_enc ctime mtime atime contains_refs),
23 24     24   157 );
  24         81  
24              
25 24     24   151 use constant STIX_OBJECT => 'SCO';
  24         61  
  24         1290  
26 24     24   134 use constant STIX_OBJECT_TYPE => 'directory';
  24         52  
  24         8547  
27              
28             has path => (is => 'rw', required => 1, isa => Str);
29              
30             has path_enc => (is => 'rw', isa => Str);
31              
32             has ctime => (
33             is => 'rw',
34             isa => InstanceOf ['STIX::Common::Timestamp'],
35             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
36             );
37              
38             has mtime => (
39             is => 'rw',
40             isa => InstanceOf ['STIX::Common::Timestamp'],
41             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
42             );
43              
44             has atime => (
45             is => 'rw',
46             isa => InstanceOf ['STIX::Common::Timestamp'],
47             coerce => sub { ref($_[0]) ? $_[0] : STIX::Common::Timestamp->new($_[0]) },
48             );
49              
50             has contains_refs => (
51             is => 'rw',
52             isa => ArrayLike [InstanceOf ['STIX::Observable::Directory', 'STIX::Observable::File']],
53             default => sub { STIX::Common::List->new }
54             );
55              
56             1;
57              
58             =encoding utf-8
59              
60             =head1 NAME
61              
62             STIX::Observable::Directory - STIX Cyber-observable Object (SCO) - Directory
63              
64             =head1 SYNOPSIS
65              
66             use STIX::Observable::Directory;
67              
68             my $directory = STIX::Observable::Directory->new();
69              
70              
71             =head1 DESCRIPTION
72              
73             The Directory Object represents the properties common to a file system
74             directory.
75              
76              
77             =head2 METHODS
78              
79             L inherits all methods from L
80             and implements the following new ones.
81              
82             =over
83              
84             =item STIX::Observable::Directory->new(%properties)
85              
86             Create a new instance of L.
87              
88             =item $directory->atime
89              
90             Specifies the date/time the directory was last accessed.
91              
92             =item $directory->contains_refs
93              
94             Specifies a list of references to other File and/or Directory Objects
95             contained within the directory.
96              
97             =item $directory->ctime
98              
99             Specifies the date/time the directory was created.
100              
101             =item $directory->id
102              
103             =item $directory->mtime
104              
105             Specifies the date/time the directory was last written to/modified.
106              
107             =item $directory->path
108              
109             Specifies the path, as originally observed, to the directory on the file
110             system.
111              
112             =item $directory->path_enc
113              
114             Specifies the observed encoding for the path.
115              
116             =item $directory->type
117              
118             The value of this property MUST be C.
119              
120             =back
121              
122              
123             =head2 HELPERS
124              
125             =over
126              
127             =item $directory->TO_JSON
128              
129             Encode the object in JSON.
130              
131             =item $directory->to_hash
132              
133             Return the object HASH.
134              
135             =item $directory->to_string
136              
137             Encode the object in JSON.
138              
139             =item $directory->validate
140              
141             Validate the object using JSON Schema
142             (see L).
143              
144             =back
145              
146              
147             =head1 SUPPORT
148              
149             =head2 Bugs / Feature Requests
150              
151             Please report any bugs or feature requests through the issue tracker
152             at L.
153             You will be notified automatically of any progress on your issue.
154              
155             =head2 Source Code
156              
157             This is open source software. The code repository is available for
158             public review and contribution under the terms of the license.
159              
160             L
161              
162             git clone https://github.com/giterlizzi/perl-STIX.git
163              
164              
165             =head1 AUTHOR
166              
167             =over 4
168              
169             =item * Giuseppe Di Terlizzi
170              
171             =back
172              
173              
174             =head1 LICENSE AND COPYRIGHT
175              
176             This software is copyright (c) 2024 by Giuseppe Di Terlizzi.
177              
178             This is free software; you can redistribute it and/or modify it under
179             the same terms as the Perl 5 programming language system itself.
180              
181             =cut