Fix TestTurbiniaTaskBase to instantiate the requested evidence class - #1640
Fix TestTurbiniaTaskBase to instantiate the requested evidence class#1640rootkiller6788 wants to merge 2 commits into
Conversation
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
|
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
|
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? |
Summary
TestTurbiniaTaskBase.setUp()accepts anevidence_classparameter and stores it on the instance, but then unconditionally instantiatesself.evidenceasevidence.RawDisk. As a result, any test that passes a different evidence class silently runs against the wrong evidence type.For example,
VolatilityTaskTestpassesevidence_class=RawMemoryand then setsself.evidence.profile/self.evidence.module_list, but the object is actually aRawDisk.Change
Instantiate the requested class instead of hardcoding
RawDisk:All evidence classes inherit from
Evidenceand acceptsource_pathvia**kwargs, so this is safe for every existing caller (RawMemory, ReportText, BodyFile, DiskPartition, DockerContainer, ContainerdContainer, BulkExtractorOutput, BinaryExtraction, MachoExtraction, ElfExtraction, PhotorecOutput).Verification
evidence_classwas stored (workers_test.py:47) but never used, while line 69 hardcodedevidence.RawDisk.evidence_class=callers in the test suite to confirm the parameter is genuinely exercised.python -m py_compilepasses on the modified file.Fixes #1373