malwareDetector 0.1.9__tar.gz → 0.1.10__tar.gz

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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: malwareDetector
3
- Version: 0.1.9
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
@@ -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):
@@ -185,6 +186,12 @@ def parameter_parser(config: Config) -> Config:
185
186
  help="Embeddings path."
186
187
  )
187
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
+
188
195
  parser.add_argument("--dimensions",
189
196
  dest="dimensions",
190
197
  type=int,
@@ -241,7 +248,7 @@ def parameter_parser(config: Config) -> Config:
241
248
  help='Select the model(KNN, LR, MLP, RF, SVM).'
242
249
  )
243
250
 
244
- parser.add_argument('--classify', '-c',
251
+ parser.add_argument('--classify', '-f',
245
252
  dest="classify",
246
253
  action='store_true',
247
254
  default=DEFAULT_CLASSIFY,
@@ -251,6 +258,7 @@ def parameter_parser(config: Config) -> Config:
251
258
  args = parser.parse_args()
252
259
  config.path.input = args.input_path
253
260
  config.path.output = args.output_path
261
+ config.path.config = args.config_path
254
262
  config.model.dimensions = args.dimensions
255
263
  config.model.workers = args.workers
256
264
  config.model.epochs = args.epochs
@@ -263,7 +271,7 @@ def parameter_parser(config: Config) -> Config:
263
271
 
264
272
  return config
265
273
 
266
- def write_config_to_file(config: Config):
274
+ def write_config_to_file(config: Config, config_file_path=DEFAULT_CONFIG_PATH):
267
275
  '''
268
276
  Writes the parameter settings of
269
277
  the config object to a JSON file in
@@ -271,10 +279,10 @@ def write_config_to_file(config: Config):
271
279
  default name `config.json`.
272
280
  '''
273
281
 
274
- with open(CONFIG_FILE_NAME, "w", encoding="utf8") as file:
282
+ with open(config_file_path, "w", encoding="utf8") as file:
275
283
  file.write(config.json(exclude={"folder": {"folder_list"}}))
276
284
 
277
- def detect_config_file() -> None:
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")
@@ -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.9
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
@@ -11,7 +11,7 @@ required_packages = [
11
11
  setup(
12
12
  name='malwareDetector',
13
13
  packages=find_packages(include=['malwareDetector']),
14
- version='0.1.9',
14
+ version='0.1.10',
15
15
  description='Malware detector specification for NTUST isLab',
16
16
  long_description=long_description,
17
17
  long_description_content_type="text/markdown",