malwareDetector 0.1.7__py3-none-any.whl → 0.1.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of malwareDetector might be problematic. Click here for more details.
- malwareDetector/config.py +47 -11
- {malwareDetector-0.1.7.dist-info → malwareDetector-0.1.9.dist-info}/METADATA +1 -1
- {malwareDetector-0.1.7.dist-info → malwareDetector-0.1.9.dist-info}/RECORD +6 -6
- {malwareDetector-0.1.7.dist-info → malwareDetector-0.1.9.dist-info}/LICENCE.txt +0 -0
- {malwareDetector-0.1.7.dist-info → malwareDetector-0.1.9.dist-info}/WHEEL +0 -0
- {malwareDetector-0.1.7.dist-info → malwareDetector-0.1.9.dist-info}/top_level.txt +0 -0
malwareDetector/config.py
CHANGED
|
@@ -9,17 +9,33 @@ from pydantic import BaseModel, Extra
|
|
|
9
9
|
from typing import List, Any
|
|
10
10
|
from .const import *
|
|
11
11
|
|
|
12
|
-
class PathConfig(BaseModel):
|
|
12
|
+
class PathConfig(BaseModel, extra=Extra.allow):
|
|
13
13
|
'''
|
|
14
14
|
The `PathConfig` class stores the input file path
|
|
15
15
|
and output file path settings for the detector,
|
|
16
16
|
which are obtained from `parameter_parser()`.
|
|
17
17
|
If no additional settings are provided,
|
|
18
18
|
default values will be used.
|
|
19
|
+
|
|
20
|
+
If you wish to create a customized parameter,
|
|
21
|
+
there has two methods to do it.
|
|
22
|
+
1. please refer to the `set_param` and `del_param`
|
|
23
|
+
method of the `PathConfig` class.
|
|
24
|
+
2. directly set the parameter in the `config.json` file.
|
|
19
25
|
'''
|
|
20
26
|
input: str = DEFAULT_INPUT_PATH
|
|
21
27
|
output: str = DEFAULT_OUT_PATH
|
|
22
28
|
|
|
29
|
+
def set_param(self, __name: str, __value: Any):
|
|
30
|
+
if hasattr(self, __name):
|
|
31
|
+
raise AttributeError(f"Parameter {__name} already exists.")
|
|
32
|
+
else:
|
|
33
|
+
setattr(self, __name, __value)
|
|
34
|
+
|
|
35
|
+
def del_param(self, __name: str):
|
|
36
|
+
if hasattr(self, __name):
|
|
37
|
+
delattr(self, __name)
|
|
38
|
+
|
|
23
39
|
class ModelConfig(BaseModel, extra=Extra.allow):
|
|
24
40
|
'''
|
|
25
41
|
The `ModelConfig` class stores the
|
|
@@ -29,8 +45,10 @@ class ModelConfig(BaseModel, extra=Extra.allow):
|
|
|
29
45
|
default values will be used.
|
|
30
46
|
|
|
31
47
|
If you wish to create a customized parameter,
|
|
32
|
-
|
|
33
|
-
the `
|
|
48
|
+
there has two methods to do it.
|
|
49
|
+
1. please refer to the `set_param` and `del_param`
|
|
50
|
+
method of the `ModelConfig` class.
|
|
51
|
+
2. directly set the parameter in the `config.json` file.
|
|
34
52
|
'''
|
|
35
53
|
modelName: str = DEFAULT_MODEL_NAME
|
|
36
54
|
dimensions: int = DEFAULT_DIMENSIONS
|
|
@@ -56,19 +74,20 @@ class FolderConfig(BaseModel, extra=Extra.allow):
|
|
|
56
74
|
The `FolderConfig` class stores the names
|
|
57
75
|
of folders where the stored data is kept.
|
|
58
76
|
|
|
59
|
-
If you wish to create a customized
|
|
60
|
-
|
|
61
|
-
the `
|
|
77
|
+
If you wish to create a customized parameter,
|
|
78
|
+
there has two methods to do it.
|
|
79
|
+
1. please refer to the `set_folder` and `del_folder`
|
|
80
|
+
method of the `FolderConfig` class.
|
|
81
|
+
2. directly set the parameter in the `config.json` file.
|
|
62
82
|
'''
|
|
63
83
|
dataset: str = DATASET_DIR
|
|
64
84
|
feature: str = FEATURE_DIR
|
|
65
85
|
vectorize: str = VECTORIZE_DIR
|
|
66
86
|
model: str = MODEL_DIR
|
|
67
87
|
predict: str = PREDICT_DIR
|
|
68
|
-
folder_list: List[str] = [dataset, feature, vectorize, model, predict]
|
|
69
88
|
|
|
70
89
|
def update_folder_list(self):
|
|
71
|
-
self.folder_list = [self
|
|
90
|
+
self.folder_list = [getattr(self, folder) for folder in self.__dict__.keys()]
|
|
72
91
|
|
|
73
92
|
def __iter__(self):
|
|
74
93
|
return FolderClassIter(self.folder_list)
|
|
@@ -110,7 +129,7 @@ class FolderClassIter(object):
|
|
|
110
129
|
return member
|
|
111
130
|
raise StopIteration
|
|
112
131
|
|
|
113
|
-
class Config(BaseModel):
|
|
132
|
+
class Config(BaseModel, extra=Extra.allow):
|
|
114
133
|
'''
|
|
115
134
|
The `Config` class stores all the external settings
|
|
116
135
|
for the detector, which are obtained from `parameter_parser()`.
|
|
@@ -121,12 +140,28 @@ class Config(BaseModel):
|
|
|
121
140
|
`FolderConfig`: Contains configurations for folders and directories.
|
|
122
141
|
`ModelConfig`: Includes settings specific to the model.
|
|
123
142
|
`classify`: Determines whether the task is malware family classification or simple malware detection.
|
|
143
|
+
|
|
144
|
+
If you wish to create a customized parameter,
|
|
145
|
+
there has two methods to do it.
|
|
146
|
+
1. please refer to the `set_param` and `del_param`
|
|
147
|
+
method of the `Config` class.
|
|
148
|
+
2. directly set the parameter in the `config.json` file.
|
|
124
149
|
'''
|
|
125
150
|
path: PathConfig = PathConfig()
|
|
126
151
|
folder: FolderConfig = FolderConfig()
|
|
127
152
|
model: ModelConfig = ModelConfig()
|
|
128
153
|
classify: bool = DEFAULT_CLASSIFY
|
|
129
154
|
|
|
155
|
+
def set_param(self, __name: str, __value: Any):
|
|
156
|
+
if hasattr(self, __name):
|
|
157
|
+
raise AttributeError(f"Parameter {__name} already exists.")
|
|
158
|
+
else:
|
|
159
|
+
setattr(self, __name, __value)
|
|
160
|
+
|
|
161
|
+
def del_param(self, __name: str):
|
|
162
|
+
if hasattr(self, __name):
|
|
163
|
+
delattr(self, __name)
|
|
164
|
+
|
|
130
165
|
def parameter_parser(config: Config) -> Config:
|
|
131
166
|
'''
|
|
132
167
|
A method for parsing command line parameters
|
|
@@ -233,10 +268,11 @@ def write_config_to_file(config: Config):
|
|
|
233
268
|
Writes the parameter settings of
|
|
234
269
|
the config object to a JSON file in
|
|
235
270
|
the execution folder with the
|
|
236
|
-
default name `
|
|
271
|
+
default name `config.json`.
|
|
237
272
|
'''
|
|
273
|
+
|
|
238
274
|
with open(CONFIG_FILE_NAME, "w", encoding="utf8") as file:
|
|
239
|
-
file.write(config.json())
|
|
275
|
+
file.write(config.json(exclude={"folder": {"folder_list"}}))
|
|
240
276
|
|
|
241
277
|
def detect_config_file() -> None:
|
|
242
278
|
'''
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
malwareDetector/__init__.py,sha256=x9kkfeWTUR0g6RQkE13V2sZhY2DSVD3KqzcxOqlNjtA,768
|
|
2
|
-
malwareDetector/config.py,sha256=
|
|
2
|
+
malwareDetector/config.py,sha256=VaXlljXeR9MG_aFVvc47JnZLWdr-uCiNXLrBqf-zUck,11569
|
|
3
3
|
malwareDetector/const.py,sha256=7UtO1bUHKh-_arYMTbjQ-XKdY0-EVBASY2Uy7Lqxu6U,528
|
|
4
4
|
malwareDetector/detector.py,sha256=IeLfmOoMp20s-io5w8igMc5bJdXt8ir-EarHKBo3C_U,2207
|
|
5
5
|
malwareDetector/utils.py,sha256=kjEX-A-FuwjGwxZ-2JP489NaaeC7HwvdMrDrfPk4pYE,371
|
|
6
|
-
malwareDetector-0.1.
|
|
7
|
-
malwareDetector-0.1.
|
|
8
|
-
malwareDetector-0.1.
|
|
9
|
-
malwareDetector-0.1.
|
|
10
|
-
malwareDetector-0.1.
|
|
6
|
+
malwareDetector-0.1.9.dist-info/LICENCE.txt,sha256=2XPCaZqZ-jgHh7e1DKa87JUeuOB6DC0jaZonmjDeILM,1088
|
|
7
|
+
malwareDetector-0.1.9.dist-info/METADATA,sha256=7I0tfwIqcVAmTkr1y9i9DfAulLOVesuSoKa3znX6Oko,2286
|
|
8
|
+
malwareDetector-0.1.9.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
9
|
+
malwareDetector-0.1.9.dist-info/top_level.txt,sha256=wRXSanQD5XDXRYp3lPh1SjltOo6rpC5jktmR69tqIQo,16
|
|
10
|
+
malwareDetector-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|