Skip to content
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

Add evidence path to metadata file #501

Merged
merged 2 commits into from Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions turbinia/output_manager.py
Expand Up @@ -143,6 +143,7 @@ def save_evidence(self, evidence_, result):

if evidence_.save_metadata:
metadata = evidence_.config.copy()
metadata['evidence_path'] = path
metadata_path = '{0:s}.metadata.json'.format(local_path)
try:
json_str = json.dumps(metadata)
Expand Down
9 changes: 6 additions & 3 deletions turbinia/output_manager_test.py
Expand Up @@ -16,6 +16,7 @@

from __future__ import unicode_literals

import json
import unittest
import os
import shutil
Expand Down Expand Up @@ -142,7 +143,8 @@ def testSaveEvidenceWithMetadata(self):
dst_file = os.path.join(local_dir, test_file)
test_evidence = evidence.Evidence()
test_evidence.save_metadata = True
test_evidence.config = {'foo': 'bar'}
config_input = {'foo': 'bar'}
test_evidence.config = config_input

with open(src_file, 'w') as fh:
fh.write(test_contents)
Expand All @@ -155,9 +157,10 @@ def testSaveEvidenceWithMetadata(self):
self.assertIsInstance(return_evidence, evidence.Evidence)
self.assertIn(dst_file, return_evidence.saved_path)
metadata_file = '{0:s}.metadata.json'.format(dst_file)
metadata_contents = b'{"foo": "bar"}'
self.assertTrue(os.path.exists(metadata_file))
self.assertEqual(open(metadata_file, 'rb').read(), metadata_contents)
config_input['evidence_path'] = dst_file
metadata_contents = json.loads(open(metadata_file, 'rb').read())
self.assertDictEqual(config_input, metadata_contents)


class TestLocalOutputWriter(unittest.TestCase):
Expand Down