1
1
2
2
import os
3
- import rdflib
4
- from rdflib import RDF , OWL , BNode , Literal
5
3
from dfvfs .lib import definitions as dfvfs_definitions
6
4
from plaso .storage import zip_file
7
5
@@ -26,13 +24,10 @@ def __init__(self, document):
26
24
self .document = document
27
25
# Add 'plaso' prefix used by custom property bundles to internal graph.
28
26
self .document .graph .namespace_manager .bind ('plaso' , PLASO )
29
- self ._path_spec_traces = {}
30
- self ._event_traces = {}
31
27
self ._event_exporters = {}
32
28
33
- def get_event_exporter (self , event ):
34
- """Retrieves event exporter for given event."""
35
- data_type = event .data_type
29
+ def get_event_exporter (self , data_type ):
30
+ """Retrieves event exporter for given event data_type."""
36
31
if data_type not in self ._event_exporters :
37
32
self ._event_exporters [data_type ] = EventExporter .from_data_type (
38
33
data_type , self .document )
@@ -43,43 +38,10 @@ def export_path_spec(self, path_spec):
43
38
44
39
Returns: tuple containing URIRefs for Trace and File property bundle.
45
40
"""
46
- comparable = path_spec .comparable
47
- if comparable in self ._path_spec_traces :
48
- # TODO: When filestat events call this, it will want to add more timestamps to the file pb.
49
- return self ._path_spec_traces [comparable ]
50
-
51
- trace = self .document .create_trace ()
52
- file_pb = trace .create_property_bundle ('File' )
53
-
54
- self ._path_spec_traces [comparable ] = (trace , file_pb )
55
-
56
- # Add file path information.
57
- location = getattr (path_spec , 'location' , None )
58
- if location :
59
- file_pb .add ('filePath' , location )
60
- file_name , extension = os .path .splitext (os .path .basename (location ))
61
- file_pb .add ('fileName' , file_name )
62
- file_pb .add ('extension' , extension )
63
-
64
- file_pb .add (
65
- 'fileSystemType' , mappings .FileSystemType .get (path_spec .type_indicator , None ))
66
-
67
- # If path spec has a parent, create the parent then create a relationship
68
- # object pointing to its parent.
69
- if path_spec .HasParent ():
70
- parent_trace , _ = self .export_path_spec (path_spec .parent )
71
- relationship = self .document .create_relationship (
72
- source = trace ,
73
- target = parent_trace ,
74
- kindOfRelationship = mappings .kindOfRelationship .get (
75
- path_spec .type_indicator , mappings .kindOfRelationship ['_default' ]),
76
- # TODO: Not exactly sure what isDirectional means..
77
- isDirectional = True )
78
-
79
- # Add a property bundle to relationship if available.
80
- property_bundles .construct (path_spec .type_indicator , relationship )
81
-
82
- return trace , file_pb
41
+ # The event exporter for 'fs:stat' contains functionality to export
42
+ # path_specs.
43
+ file_stat_exporter = self .get_event_exporter ('fs:stat' )
44
+ return file_stat_exporter .export_path_spec (path_spec )
83
45
84
46
def export_event_source (self , event_source ):
85
47
if event_source .file_entry_type == dfvfs_definitions .FILE_ENTRY_TYPE_DEVICE :
@@ -96,20 +58,9 @@ def export_event_source(self, event_source):
96
58
pass
97
59
98
60
def export_event (self , event ):
99
- # Append extra file stat information to the "File" property bundle.
100
- if event .data_type == 'fs:stat' :
101
- trace , file_pb = self .export_path_spec (event .pathspec )
102
- file_pb .add (
103
- 'fileSystemType' , mappings .FileSystemType .get (event .file_system_type , None ))
104
- file_pb .add ('isAllocated' , event .is_allocated )
105
- file_pb .add ('fileSize' , getattr (event , 'file_size' , None ))
106
-
107
- # # Add extra file system specific property bundles. (eg. MFtRecord, Inode)
108
- # property_bundles.construct(event.data_type, trace, event)
109
-
110
- else :
111
- event_exporter = self .get_event_exporter (event )
112
- event_exporter .export_event (event )
61
+ """Exports the given plaso EventObject into the graph."""
62
+ event_exporter = self .get_event_exporter (event .data_type )
63
+ event_exporter .export_event (event )
113
64
114
65
def export_storage_file (self , storage_file ):
115
66
"""Extracts and exports plaso event data and sources into the graph."""
0 commit comments