Skip to content

Add tmp_dir to task and let output_manager copy locally#282

Merged
Onager merged 5 commits into
masterfrom
output-writer-tmp
Nov 8, 2018
Merged

Add tmp_dir to task and let output_manager copy locally#282
Onager merged 5 commits into
masterfrom
output-writer-tmp

Conversation

@aarontp

@aarontp aarontp commented Oct 28, 2018

Copy link
Copy Markdown
Member

This changes the following:

  • Adds tmp_dir property to TurbiniaTasks to allow tasks to write locally
  • Changes output_manager to allow local files to by copied so that when there are save files or evidence files in the tmp_dir they will be copied into the output_dir
  • Changes plaso task to write to tmp_dir by default because there are problems with sqlite files being written on some shared filesystems
  • Cleans up some output_manager var names

@aarontp

aarontp commented Nov 7, 2018

Copy link
Copy Markdown
Member Author

The CodeFactor error is "Probable insecure usage of temp file/directory", but I think that's a FP. Not sure what the best way to clear that is.

@aarontp aarontp requested a review from Onager November 7, 2018 23:25
Comment thread turbinia/output_manager.py Outdated

def __init__(self):
self._output_writers = None
self.initialized = False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this variable, as this is representing "readiness" or something distinct from initialization (note that this an init method).

Alternatively, can you do the setup in one step, rather than two? Multiple levels of initialization makes things a bit tricky.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point. I changed it to is_setup. I had the setup separately from the init because I usually try to separate anything non-trivial into a separate method.

self.local_output_dir = os.path.join(self.base_output_dir, self.unique_dir)
if not os.path.exists(self.local_output_dir):
def create_output_dir(self, base_path=None):
base_path = base_path if base_path else self.base_output_dir

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please a docstring here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overriding a method in the base class which has a relevant docstring. So far I haven't been copying those in this case, but let me know if you think we should be doing that differently.

blob.upload_from_filename(source_path, client=self.client)
return os.path.join('gs://', self.bucket, destination_path)

def copy_from(self, source_path):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+docstring, as this raises an exception that isn't in the interface. I'd like to see docstrings for all these methods, but I'm not sure what the Turbinia style preference is.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Let's talk out of band about the docstrings for overridden methods. I agree that they should be changed if the overridden method does anything differently, but in the case where everything is the same, I generally prefer to not copy them. No idea if that is considered idiomatic or not, :).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatting sounds good, this is OK for now.

@aarontp aarontp left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick review! PTAL. If we want to make changes to how we handle docstrings for subclassed objects, let's do that in a separate PR.

Comment thread turbinia/output_manager.py Outdated

def __init__(self):
self._output_writers = None
self.initialized = False

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point. I changed it to is_setup. I had the setup separately from the init because I usually try to separate anything non-trivial into a separate method.

self.local_output_dir = os.path.join(self.base_output_dir, self.unique_dir)
if not os.path.exists(self.local_output_dir):
def create_output_dir(self, base_path=None):
base_path = base_path if base_path else self.base_output_dir

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overriding a method in the base class which has a relevant docstring. So far I haven't been copying those in this case, but let me know if you think we should be doing that differently.

blob.upload_from_filename(source_path, client=self.client)
return os.path.join('gs://', self.bucket, destination_path)

def copy_from(self, source_path):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Let's talk out of band about the docstrings for overridden methods. I agree that they should be changed if the overridden method does anything differently, but in the case where everything is the same, I generally prefer to not copy them. No idea if that is considered idiomatic or not, :).

@Onager Onager self-requested a review November 8, 2018 19:23
blob.upload_from_filename(source_path, client=self.client)
return os.path.join('gs://', self.bucket, destination_path)

def copy_from(self, source_path):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chatting sounds good, this is OK for now.

@Onager Onager merged commit 7a79252 into master Nov 8, 2018
@Onager Onager deleted the output-writer-tmp branch November 8, 2018 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants