File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
volatility3/framework/layers Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ # This file is Copyright 2022 Volatility Foundation and licensed under the Volatility Software License 1.0
2+ # which is available at https://www.volatilityfoundation.org/license/vsl-v1.0
3+ #
4+
5+ import logging
6+ import urllib .parse
7+ from typing import Optional , Any , List
8+
9+ try :
10+ import s3fs
11+ HAS_S3FS = True
12+ except ImportError :
13+ HAS_S3FS = False
14+
15+ try :
16+ import gcsfs
17+ HAS_GCSFS = True
18+ except ImportError :
19+ HAS_GCSFS = False
20+
21+ from volatility3 .framework import exceptions
22+ from volatility3 .framework .layers import resources
23+
24+ vollog = logging .getLogger (__file__ )
25+
26+ class S3FileSystemHandler (resources .VolatilityHandler ):
27+ if HAS_S3FS :
28+ @classmethod
29+ def non_cached_schemes (cls ) -> List [str ]:
30+ return ["s3" ]
31+
32+ @staticmethod
33+ def default_open (req : urllib .request .Request ) -> Optional [Any ]:
34+ """Handles the request if it's the s3 scheme."""
35+ if req .type == "s3" :
36+ object_uri = "://" .join (req .full_url .split ("://" )[1 :])
37+ return s3fs .S3FileSystem ().open (object_uri )
38+ else :
39+ raise exceptions .LayerException ("s3 requirement is missing." )
40+
41+
42+ class GSFileSystemHandler (resources .VolatilityHandler ):
43+ if HAS_GCSFS :
44+ @classmethod
45+ def non_cached_schemes (cls ) -> List [str ]:
46+ return ["gs" ]
47+
48+ @staticmethod
49+ def default_open (req : urllib .request .Request ) -> Optional [Any ]:
50+ """Handles the request if it's the gs scheme."""
51+ if req .type == "gs" :
52+ object_uri = "://" .join (req .full_url .split ("://" )[1 :])
53+ return gcsfs .GCSFileSystem ().open (object_uri )
54+ return None
55+ else :
56+ raise exceptions .LayerException ("gcsfs requirement is missing." )
You can’t perform that action at this time.
0 commit comments