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 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.dataset, self.feature, self.vectorize, self.model, self.predict]
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', '-c',
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
- def detect_config_file() -> None:
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
- write_config_to_file(parameter_parser(Config()))
290
- logging.info(f"{CONFIG_FILE_NAME} created!")
291
- elif CONFIG_FILE_NAME in os.listdir():
292
- logging.info(f"{CONFIG_FILE_NAME} detected!")
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"{CONFIG_FILE_NAME} created!")
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
- with open(CONFIG_FILE_NAME, encoding="utf-8") as file:
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
- detect_config_file(argparse=False)
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
@@ -1,8 +1,8 @@
1
1
  '''
2
2
  Save the variables of the system's default constants.
3
3
  '''
4
- CONFIG_FILE_NAME="config.json"
5
4
 
5
+ DEFAULT_CONFIG_PATH="./config.json"
6
6
  DEFAULT_INPUT_PATH="./Dataset/malware"
7
7
  DEFAULT_OUT_PATH="./Feature/feature.csv"
8
8
  DEFAULT_MODEL_NAME="SVM"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: malwareDetector
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: Malware detector specification for NTUST isLab
5
5
  Author: PO-LIN LAI
6
6
  Author-email: bolin8017@gmail.com
@@ -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,,