malwareDetector 0.1.8__py3-none-any.whl → 0.1.10__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 +28 -18
- malwareDetector/const.py +1 -1
- {malwareDetector-0.1.8.dist-info → malwareDetector-0.1.10.dist-info}/METADATA +1 -1
- malwareDetector-0.1.10.dist-info/RECORD +10 -0
- malwareDetector-0.1.8.dist-info/RECORD +0 -10
- {malwareDetector-0.1.8.dist-info → malwareDetector-0.1.10.dist-info}/LICENCE.txt +0 -0
- {malwareDetector-0.1.8.dist-info → malwareDetector-0.1.10.dist-info}/WHEEL +0 -0
- {malwareDetector-0.1.8.dist-info → malwareDetector-0.1.10.dist-info}/top_level.txt +0 -0
malwareDetector/config.py
CHANGED
|
@@ -25,6 +25,7 @@ class PathConfig(BaseModel, extra=Extra.allow):
|
|
|
25
25
|
'''
|
|
26
26
|
input: str = DEFAULT_INPUT_PATH
|
|
27
27
|
output: str = DEFAULT_OUT_PATH
|
|
28
|
+
config: str = DEFAULT_CONFIG_PATH
|
|
28
29
|
|
|
29
30
|
def set_param(self, __name: str, __value: Any):
|
|
30
31
|
if hasattr(self, __name):
|
|
@@ -85,10 +86,9 @@ class FolderConfig(BaseModel, extra=Extra.allow):
|
|
|
85
86
|
vectorize: str = VECTORIZE_DIR
|
|
86
87
|
model: str = MODEL_DIR
|
|
87
88
|
predict: str = PREDICT_DIR
|
|
88
|
-
folder_list: List[str] = [dataset, feature, vectorize, model, predict]
|
|
89
89
|
|
|
90
90
|
def update_folder_list(self):
|
|
91
|
-
self.folder_list = [self
|
|
91
|
+
self.folder_list = [getattr(self, folder) for folder in self.__dict__.keys()]
|
|
92
92
|
|
|
93
93
|
def __iter__(self):
|
|
94
94
|
return FolderClassIter(self.folder_list)
|
|
@@ -186,6 +186,12 @@ def parameter_parser(config: Config) -> Config:
|
|
|
186
186
|
help="Embeddings path."
|
|
187
187
|
)
|
|
188
188
|
|
|
189
|
+
parser.add_argument("--config-path","-c",
|
|
190
|
+
dest="config_path",
|
|
191
|
+
nargs="?",
|
|
192
|
+
default=DEFAULT_CONFIG_PATH,
|
|
193
|
+
help="Configuration file path.")
|
|
194
|
+
|
|
189
195
|
parser.add_argument("--dimensions",
|
|
190
196
|
dest="dimensions",
|
|
191
197
|
type=int,
|
|
@@ -242,7 +248,7 @@ def parameter_parser(config: Config) -> Config:
|
|
|
242
248
|
help='Select the model(KNN, LR, MLP, RF, SVM).'
|
|
243
249
|
)
|
|
244
250
|
|
|
245
|
-
parser.add_argument('--classify', '-
|
|
251
|
+
parser.add_argument('--classify', '-f',
|
|
246
252
|
dest="classify",
|
|
247
253
|
action='store_true',
|
|
248
254
|
default=DEFAULT_CLASSIFY,
|
|
@@ -252,6 +258,7 @@ def parameter_parser(config: Config) -> Config:
|
|
|
252
258
|
args = parser.parse_args()
|
|
253
259
|
config.path.input = args.input_path
|
|
254
260
|
config.path.output = args.output_path
|
|
261
|
+
config.path.config = args.config_path
|
|
255
262
|
config.model.dimensions = args.dimensions
|
|
256
263
|
config.model.workers = args.workers
|
|
257
264
|
config.model.epochs = args.epochs
|
|
@@ -264,17 +271,18 @@ def parameter_parser(config: Config) -> Config:
|
|
|
264
271
|
|
|
265
272
|
return config
|
|
266
273
|
|
|
267
|
-
def write_config_to_file(config: Config):
|
|
274
|
+
def write_config_to_file(config: Config, config_file_path=DEFAULT_CONFIG_PATH):
|
|
268
275
|
'''
|
|
269
276
|
Writes the parameter settings of
|
|
270
277
|
the config object to a JSON file in
|
|
271
278
|
the execution folder with the
|
|
272
279
|
default name `config.json`.
|
|
273
280
|
'''
|
|
274
|
-
with open(CONFIG_FILE_NAME, "w", encoding="utf8") as file:
|
|
275
|
-
file.write(config.json())
|
|
276
281
|
|
|
277
|
-
|
|
282
|
+
with open(config_file_path, "w", encoding="utf8") as file:
|
|
283
|
+
file.write(config.json(exclude={"folder": {"folder_list"}}))
|
|
284
|
+
|
|
285
|
+
def detect_config_file(config_file_path=DEFAULT_CONFIG_PATH) -> None:
|
|
278
286
|
'''
|
|
279
287
|
If you run Python using the IPython approach,
|
|
280
288
|
the command line parsing functionality will not be enabled.
|
|
@@ -286,18 +294,21 @@ def detect_config_file() -> None:
|
|
|
286
294
|
logging.info(
|
|
287
295
|
"Creating local config file by argparse."
|
|
288
296
|
)
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
logging.info(f"{
|
|
297
|
+
config = parameter_parser(Config())
|
|
298
|
+
config_file_path = config.path.config
|
|
299
|
+
write_config_to_file(config, config.path.config)
|
|
300
|
+
logging.info(f"{config_file_path} created!")
|
|
301
|
+
elif config_file_path in os.listdir():
|
|
302
|
+
logging.info(f"{config_file_path} detected!")
|
|
293
303
|
else:
|
|
294
304
|
logging.info(
|
|
295
305
|
"config file not found. creating local config file by default config."
|
|
296
306
|
)
|
|
297
|
-
write_config_to_file(Config())
|
|
298
|
-
logging.info(f"{
|
|
307
|
+
write_config_to_file(Config(), config_file_path)
|
|
308
|
+
logging.info(f"{config_file_path} created!")
|
|
309
|
+
return config_file_path
|
|
299
310
|
|
|
300
|
-
def read_config(count=1) -> Config:
|
|
311
|
+
def read_config(config_file_path=DEFAULT_CONFIG_PATH, count=1) -> Config:
|
|
301
312
|
'''
|
|
302
313
|
Reads the settings from the `config.json` file.
|
|
303
314
|
'''
|
|
@@ -307,14 +318,13 @@ def read_config(count=1) -> Config:
|
|
|
307
318
|
if count != 1:
|
|
308
319
|
logging.info(f"Trying to read config time:{count}")
|
|
309
320
|
try:
|
|
310
|
-
|
|
321
|
+
config_file_path = detect_config_file(config_file_path=config_file_path)
|
|
322
|
+
with open(config_file_path, encoding="utf-8") as file:
|
|
311
323
|
config = Config.parse_raw(file.read())
|
|
312
324
|
config.folder.update_folder_list()
|
|
313
325
|
return config
|
|
314
326
|
except Exception as err:
|
|
315
327
|
logging.warning(err)
|
|
316
|
-
|
|
317
|
-
return read_config(count=count+1)
|
|
328
|
+
return read_config(config_file_path=config_file_path, count=count+1)
|
|
318
329
|
|
|
319
|
-
detect_config_file()
|
|
320
330
|
logging.info("config.py got executed")
|
malwareDetector/const.py
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
malwareDetector/__init__.py,sha256=x9kkfeWTUR0g6RQkE13V2sZhY2DSVD3KqzcxOqlNjtA,768
|
|
2
|
+
malwareDetector/config.py,sha256=_Wk3XAaQIcG0O_fxhsz7TwEloM-w6IeEr0gpJJLc4vY,12195
|
|
3
|
+
malwareDetector/const.py,sha256=9XC5FUofRz6meRdFkzUPe3LK8fp-aBVCFHlsSLFD9b0,533
|
|
4
|
+
malwareDetector/detector.py,sha256=IeLfmOoMp20s-io5w8igMc5bJdXt8ir-EarHKBo3C_U,2207
|
|
5
|
+
malwareDetector/utils.py,sha256=kjEX-A-FuwjGwxZ-2JP489NaaeC7HwvdMrDrfPk4pYE,371
|
|
6
|
+
malwareDetector-0.1.10.dist-info/LICENCE.txt,sha256=2XPCaZqZ-jgHh7e1DKa87JUeuOB6DC0jaZonmjDeILM,1088
|
|
7
|
+
malwareDetector-0.1.10.dist-info/METADATA,sha256=SPO7of7kYU9zIKn-cJsJa9wI4qK6icSZ4aSlVgP1YS0,2287
|
|
8
|
+
malwareDetector-0.1.10.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
9
|
+
malwareDetector-0.1.10.dist-info/top_level.txt,sha256=wRXSanQD5XDXRYp3lPh1SjltOo6rpC5jktmR69tqIQo,16
|
|
10
|
+
malwareDetector-0.1.10.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
malwareDetector/__init__.py,sha256=x9kkfeWTUR0g6RQkE13V2sZhY2DSVD3KqzcxOqlNjtA,768
|
|
2
|
-
malwareDetector/config.py,sha256=z24nSzqEQp3M5yldGZeWHosucdTdz4EyQ9F2pk22y_E,11620
|
|
3
|
-
malwareDetector/const.py,sha256=7UtO1bUHKh-_arYMTbjQ-XKdY0-EVBASY2Uy7Lqxu6U,528
|
|
4
|
-
malwareDetector/detector.py,sha256=IeLfmOoMp20s-io5w8igMc5bJdXt8ir-EarHKBo3C_U,2207
|
|
5
|
-
malwareDetector/utils.py,sha256=kjEX-A-FuwjGwxZ-2JP489NaaeC7HwvdMrDrfPk4pYE,371
|
|
6
|
-
malwareDetector-0.1.8.dist-info/LICENCE.txt,sha256=2XPCaZqZ-jgHh7e1DKa87JUeuOB6DC0jaZonmjDeILM,1088
|
|
7
|
-
malwareDetector-0.1.8.dist-info/METADATA,sha256=hX_BOECHz9fHpeNTgUP0AHJTYqgYpXlpPkH5kNadKgM,2286
|
|
8
|
-
malwareDetector-0.1.8.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
9
|
-
malwareDetector-0.1.8.dist-info/top_level.txt,sha256=wRXSanQD5XDXRYp3lPh1SjltOo6rpC5jktmR69tqIQo,16
|
|
10
|
-
malwareDetector-0.1.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|