Skip to content

Fix TestTurbiniaTaskBase to instantiate the requested evidence class - #1640

Draft
rootkiller6788 wants to merge 2 commits into
google:masterfrom
rootkiller6788:fix-1373-evidence-class-test-base
Draft

Fix TestTurbiniaTaskBase to instantiate the requested evidence class#1640
rootkiller6788 wants to merge 2 commits into
google:masterfrom
rootkiller6788:fix-1373-evidence-class-test-base

Conversation

@rootkiller6788

Copy link
Copy Markdown

Summary

TestTurbiniaTaskBase.setUp() accepts an evidence_class parameter and stores it on the instance, but then unconditionally instantiates self.evidence as evidence.RawDisk. As a result, any test that passes a different evidence class silently runs against the wrong evidence type.

For example, VolatilityTaskTest passes evidence_class=RawMemory and then sets self.evidence.profile / self.evidence.module_list, but the object is actually a RawDisk.

Change

Instantiate the requested class instead of hardcoding RawDisk:

self.evidence = self.evidence_class(source_path=test_disk_path)

All evidence classes inherit from Evidence and accept source_path via **kwargs, so this is safe for every existing caller (RawMemory, ReportText, BodyFile, DiskPartition, DockerContainer, ContainerdContainer, BulkExtractorOutput, BinaryExtraction, MachoExtraction, ElfExtraction, PhotorecOutput).

Verification

  • Confirmed against HEAD that evidence_class was stored (workers_test.py:47) but never used, while line 69 hardcoded evidence.RawDisk.
  • Grepped all evidence_class= callers in the test suite to confirm the parameter is genuinely exercised.
  • python -m py_compile passes on the modified file.

Fixes #1373

The evidence_class parameter of TestTurbiniaTaskBase.setUp was stored on
the instance but never used: self.evidence was always instantiated as
RawDisk, so tests passing a different evidence class silently ran
against the wrong type. Instantiate self.evidence_class instead.

Fixes google#1373
@aarontp

aarontp commented Aug 22, 2026

Copy link
Copy Markdown
Member

lgtm, running tests to make sure they pass.

Now that TestTurbiniaTaskBase honors evidence_class (issue google#1373), the
partition enumeration and photorec tests were instantiating their output
evidence classes (DiskPartition, PhotorecOutput) as the task input
evidence. Both tasks consume a raw disk image, so pass evidence.RawDisk
(the base default) as the input evidence class.

Fixes the CI failures in the Turbinia Test Run workflow:
- partitions_test: DiskPartition.name raised TypeError because
  partition_location was None
- photorec_test: PhotorecTask.run accessed evidence.device_path which
  PhotorecOutput does not have
@rootkiller6788

Copy link
Copy Markdown
Author

Thank you for the review and for kicking off the test run! The CI failure it surfaced was caused by the base-class change itself (issue #1373): TestTurbiniaTaskBase now honors evidence_class, and two test files were passing their output evidence classes as the task's input evidence class. partitions_test passed DiskPartition (whose .name raises TypeError because partition_location is None) and photorec_test passed PhotorecOutput (which has no device_path attribute that PhotorecTask.run accesses), producing the 6 test errors. Since both tasks consume a raw disk image as input, I've updated those tests to use evidence.RawDisk (the base default), which restores the previous behavior for these tests while preserving the #1373 fix for any test that supplies a real custom evidence class. I verified all 6 affected tests pass locally. Could you please take another look / re-run the test workflow?

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.

[Bug]: TestTurbiniaTaskBase allows to pass Evidence Class as parameter but instantiates RawDisk anyway

2 participants