@@ -69,6 +69,34 @@ def __init__(
69
69
self ._test_sources_path = test_sources_path
70
70
self ._tools_path = tools_path
71
71
72
+ def _GetLoggingOptions (self , command , logging_options ):
73
+ """Determines the logging options.
74
+
75
+ Args:
76
+ command (str): command the logging options are for.
77
+ logging_options (list[str]): logging options from the test definition.
78
+
79
+ Returns:
80
+ [str]: logging options.
81
+ """
82
+ return [
83
+ option .replace ('%command%' , command ).replace (
84
+ '%results%' , self ._test_results_path )
85
+ for option in logging_options ]
86
+
87
+ def _GetProfilinggOptions (self , profiling_options ):
88
+ """Determines the profiling options.
89
+
90
+ Args:
91
+ profiling_options (list[str]): profiling options from the test definition.
92
+
93
+ Returns:
94
+ [str]: profiling options.
95
+ """
96
+ return [
97
+ option .replace ('%results%' , self ._test_results_path )
98
+ for option in profiling_options ]
99
+
72
100
def _RunCommand (self , command , stdout = None , stderr = None ):
73
101
"""Runs a command.
74
102
@@ -632,9 +660,10 @@ def _RunPsort(
632
660
if output_filter :
633
661
output_options .append (output_filter )
634
662
635
- logging_options = [
636
- option .replace ('%command%' , 'psort' )
637
- for option in test_definition .logging_options ]
663
+ logging_options = self ._GetLoggingOptions (
664
+ 'psort' , test_definition .logging_options )
665
+ profiling_options = self ._GetProfilinggOptions (
666
+ test_definition .profiling_options )
638
667
639
668
stdout_file = os .path .join (
640
669
temp_directory , '{0:s}-psort.out' .format (test_definition .name ))
@@ -646,7 +675,7 @@ def _RunPsort(
646
675
command .extend (output_options )
647
676
command .extend (logging_options )
648
677
command .extend (['--status-view' , 'none' , '--unattended' ])
649
- command .extend (test_definition . profiling_options )
678
+ command .extend (profiling_options )
650
679
651
680
with open (stdout_file , 'w' , encoding = 'utf-8' ) as stdout :
652
681
with open (stderr_file , 'w' , encoding = 'utf-8' ) as stderr :
@@ -758,18 +787,20 @@ def _RunLog2Timeline(
758
787
self ._test_sources_path , yara_rules_path )
759
788
extract_options .extend (['--yara-rules' , yara_rules_path ])
760
789
761
- logging_options = [
762
- option .replace ('%command%' , 'log2timeline' )
763
- for option in test_definition .logging_options ]
790
+ logging_options = self ._GetLoggingOptions (
791
+ 'log2timeline' , test_definition .logging_options )
792
+ profiling_options = self ._GetProfilinggOptions (
793
+ test_definition .profiling_options )
764
794
765
795
stdout_file = os .path .join (
766
796
temp_directory , '{0:s}-log2timeline.out' .format (test_definition .name ))
767
797
stderr_file = os .path .join (
768
798
temp_directory , '{0:s}-log2timeline.err' .format (test_definition .name ))
799
+
769
800
command = [self ._log2timeline_path ]
770
801
command .extend (extract_options )
771
802
command .extend (logging_options )
772
- command .extend (test_definition . profiling_options )
803
+ command .extend (profiling_options )
773
804
command .extend (['--storage-file' , storage_file , source_path ])
774
805
775
806
with open (stdout_file , 'w' , encoding = 'utf-8' ) as stdout :
@@ -972,9 +1003,10 @@ def _RunPsteal(
972
1003
temp_directory , test_definition .output_file )
973
1004
psteal_options .extend (['-w' , output_file_path ])
974
1005
975
- logging_options = [
976
- option .replace ('%command%' , 'psteal' )
977
- for option in test_definition .logging_options ]
1006
+ logging_options = self ._GetLoggingOptions (
1007
+ 'psteal' , test_definition .logging_options )
1008
+ profiling_options = self ._GetProfilinggOptions (
1009
+ test_definition .profiling_options )
978
1010
979
1011
stdout_file = os .path .join (
980
1012
temp_directory , '{0:s}-psteal.out' .format (test_definition .name ))
@@ -986,7 +1018,7 @@ def _RunPsteal(
986
1018
command .extend (logging_options )
987
1019
command .extend (output_options )
988
1020
command .extend (['--status-view' , 'none' , '--unattended' ])
989
- command .extend (test_definition . profiling_options )
1021
+ command .extend (profiling_options )
990
1022
991
1023
with open (stdout_file , 'w' , encoding = 'utf-8' ) as stdout :
992
1024
with open (stderr_file , 'w' , encoding = 'utf-8' ) as stderr :
@@ -1451,9 +1483,10 @@ def _RunImageExport(self, test_definition, temp_directory, source_path):
1451
1483
1452
1484
output_options = ['-w' , exported_files_path ]
1453
1485
1454
- logging_options = [
1455
- option .replace ('%command%' , 'image_export' )
1456
- for option in test_definition .logging_options ]
1486
+ logging_options = self ._GetLoggingOptions (
1487
+ 'image_export' , test_definition .logging_options )
1488
+ profiling_options = self ._GetProfilinggOptions (
1489
+ test_definition .profiling_options )
1457
1490
1458
1491
stdout_file = os .path .join (
1459
1492
temp_directory , '{0:s}-image_export.out' .format (test_definition .name ))
@@ -1464,7 +1497,7 @@ def _RunImageExport(self, test_definition, temp_directory, source_path):
1464
1497
command .extend (export_options )
1465
1498
command .extend (output_options )
1466
1499
command .extend (logging_options )
1467
- command .extend (test_definition . profiling_options )
1500
+ command .extend (profiling_options )
1468
1501
command .append (source_path )
1469
1502
1470
1503
with open (stdout_file , 'w' , encoding = 'utf-8' ) as stdout :
0 commit comments