-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Remote analysis on cloud object-storage. #1037
Merged
ikelos
merged 6 commits into
volatilityfoundation:develop
from
forensicxlab:feature/bucket-s3
Dec 1, 2023
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fa2b840
Object Storage Layer for PR #1037
k1nd0ne f8e3464
Forgot to return 'None' in the s3 scheme
k1nd0ne ceac912
Adding requirements
k1nd0ne fd5c828
Renaming file, handling url parsing using urllib, changing logger and…
k1nd0ne ed98d45
Changing requirements + formating
k1nd0ne 1f5a18d
patch running black
k1nd0ne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# This file is Copyright 2022 Volatility Foundation and licensed under the Volatility Software License 1.0 | ||
# which is available at https://www.volatilityfoundation.org/license/vsl-v1.0 | ||
# | ||
|
||
import logging | ||
import urllib.parse | ||
from typing import Optional, Any, List | ||
|
||
try: | ||
import s3fs | ||
HAS_S3FS = True | ||
except ImportError: | ||
HAS_S3FS = False | ||
|
||
try: | ||
import gcsfs | ||
HAS_GCSFS = True | ||
except ImportError: | ||
HAS_GCSFS = False | ||
|
||
from volatility3.framework import exceptions | ||
from volatility3.framework.layers import resources | ||
|
||
vollog = logging.getLogger(__file__) | ||
|
||
class S3FileSystemHandler(resources.VolatilityHandler): | ||
if HAS_S3FS: | ||
@classmethod | ||
def non_cached_schemes(cls) -> List[str]: | ||
return ["s3"] | ||
|
||
@staticmethod | ||
def default_open(req: urllib.request.Request) -> Optional[Any]: | ||
"""Handles the request if it's the s3 scheme.""" | ||
if req.type == "s3": | ||
object_uri = "://".join(req.full_url.split("://")[1:]) | ||
return s3fs.S3FileSystem().open(object_uri) | ||
return None | ||
else: | ||
raise exceptions.LayerException("s3 requirement is missing.") | ||
|
||
|
||
class GSFileSystemHandler(resources.VolatilityHandler): | ||
if HAS_GCSFS: | ||
@classmethod | ||
def non_cached_schemes(cls) -> List[str]: | ||
return ["gs"] | ||
|
||
@staticmethod | ||
def default_open(req: urllib.request.Request) -> Optional[Any]: | ||
"""Handles the request if it's the gs scheme.""" | ||
if req.type == "gs": | ||
object_uri = "://".join(req.full_url.split("://")[1:]) | ||
return gcsfs.GCSFileSystem().open(object_uri) | ||
return None | ||
else: | ||
raise exceptions.LayerException("gcsfs requirement is missing.") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Unused import Note