-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToolClass.py
More file actions
127 lines (101 loc) · 3.79 KB
/
ToolClass.py
File metadata and controls
127 lines (101 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from abc import ABC, abstractmethod
# abstract class for tool
class ToolClass(ABC):
def __init__(self) -> None:
super().__init__()
@abstractmethod
def check_readiness(self) -> None:
"""
Future work
Params: None
Returns: None
"""
pass
@abstractmethod
def get_tool_type(self) -> str:
"""
Constant function to indicate the type of tool
Params: None
Returns: string "SAT"
"""
pass
@abstractmethod
def is_compilation_required(self) -> bool:
"""
Inform pipeline whether the pre-analysis step is needed
Params: None
Returns: boolean
"""
pass
@abstractmethod
def get_supported_languages(self) -> list:
"""
Tool's information on the supported languages
Params: None
Returns: list
"""
pass
@abstractmethod
def get_result_location(self) -> str:
"""
Future work
Params: None
Returns: None
"""
pass
@abstractmethod
def count_result(self, output_filename: str) -> int:
"""
Called after the execution to count the warnings on each commit for a quick execution summary
Params: output_filename of the commit as specified by the pipeline
Returns: integer
"""
pass
@abstractmethod
def get_pre_analysis_commands(self) -> list:
"""
Mandatory commands that must be run before the actual SAT execution i.e., the pre-compilation script
Params: None
Returns: None
"""
pass
@abstractmethod
def does_analysis_use_shell(self) -> bool:
"""
Passing Shell flag to python subprocess command https://docs.python.org/3/library/subprocess.html#subprocess.run
Params: None
Returns: bool
"""
pass
@abstractmethod
def get_analysis_commands(self, output_filename: str) -> list:
"""
Main SAT execution commands, either single ot multiple sets of commands
Params: output_filename of the commit as specified by the pipeline
Returns: list
"""
pass
@abstractmethod
def get_expected_analysis_commands_return_codes(self) -> list:
"""
Normally the successful execution should return thecode 0, but some SATs may return different returncodes
Params: None
Returns: list of returncodes that are considered successful for the command, when the list is empty pipeline expects returncode 0
"""
pass
@abstractmethod
def get_post_analysis_commands(self, output_filename: str) -> list:
"""
Final commands that should be run after the main SAT execution. For example, deleting the unnecessary outputs that may take up diskspace. Not that the pipeline already takes care of commit checkout process. This script should not manage the commit clean up.
Params: output_filename of the commit as specified by the pipeline
Returns: list
"""
pass
@abstractmethod
def get_transaction_result(self, output_filename: str) -> list:
"""
Get the list of warnings in a common format, containing the essential information i.e., location_hash, location_file, location_start_line, location_start_column, location_end_line, location_end_column, warning_rule_id, warning_rule_name, warning_message, warning_weakness, and warning_severity. This function should read and extract information from the warning file and prepare SATResult objects with all necessary information, especially warning_weakness and warning_severity, mapped.
Params: output_filename of the commit as specified by the pipeline
Returns: list of objects in SATResult class
"""
pass