malwareDetector 0.1.12__py3-none-any.whl → 0.1.13__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
@@ -39,11 +39,8 @@ class PathConfig(BaseModel, extra=Extra.allow):
39
39
 
40
40
  class ModelConfig(BaseModel, extra=Extra.allow):
41
41
  '''
42
- The `ModelConfig` class stores the
43
- hyperparameters of model for the detector,
44
- which are obtained from `parameter_parser()`.
45
- If no additional settings are provided,
46
- default values will be used.
42
+ The `ModelConfig` class is designed to store the
43
+ parameters and hyperparameters for the detector model.
47
44
 
48
45
  If you wish to create a customized parameter,
49
46
  there has two methods to do it.
@@ -51,15 +48,6 @@ class ModelConfig(BaseModel, extra=Extra.allow):
51
48
  method of the `ModelConfig` class.
52
49
  2. directly set the parameter in the `config.json` file.
53
50
  '''
54
- modelName: str = DEFAULT_MODEL_NAME
55
- dimensions: int = DEFAULT_DIMENSIONS
56
- workers: int = DEFAULT_WORKERS
57
- epochs: int = DEFAULT_EPOCHS
58
- min_count: int = DEFAULT_MIN_COUNT
59
- wl_iterations: int = DEFAULT_WL_ITERATIONS
60
- learning_rate: float = DEFAULT_LEARNING_RATE
61
- down_sampling: float = DEFAULT_DOWN_SAMPLING
62
-
63
51
  def set_param(self, __name: str, __value: Any):
64
52
  if hasattr(self, __name):
65
53
  raise AttributeError(f"Parameter {__name} already exists.")
@@ -192,62 +180,6 @@ def parameter_parser(config: Config) -> Config:
192
180
  default=DEFAULT_CONFIG_PATH,
193
181
  help="Configuration file path.")
194
182
 
195
- parser.add_argument("--dimensions",
196
- dest="dimensions",
197
- type=int,
198
- default=DEFAULT_DIMENSIONS,
199
- help="Number of dimensions. Default is 128."
200
- )
201
-
202
- parser.add_argument("--workers",
203
- dest="workers",
204
- type=int,
205
- default=DEFAULT_WORKERS,
206
- help="Number of workers. Default is 4."
207
- )
208
-
209
- parser.add_argument("--epochs",
210
- dest="epochs",
211
- type=int,
212
- default=DEFAULT_EPOCHS,
213
- help="Number of epochs. Default is 10."
214
- )
215
-
216
- parser.add_argument("--min-count",
217
- dest="min_count",
218
- type=int,
219
- default=DEFAULT_MIN_COUNT,
220
- help="Minimal structural feature count. Default is 5."
221
- )
222
-
223
- parser.add_argument("--wl-iterations",
224
- dest="wl_iterations",
225
- type=int,
226
- default=DEFAULT_WL_ITERATIONS,
227
- help="Number of Weisfeiler-Lehman iterations. Default is 2."
228
- )
229
-
230
- parser.add_argument("--learning-rate",
231
- dest="learning_rate",
232
- type=float,
233
- default=DEFAULT_LEARNING_RATE,
234
- help="Initial learning rate. Default is 0.025."
235
- )
236
-
237
- parser.add_argument("--down-sampling",
238
- dest="down_sampling",
239
- type=float,
240
- default=DEFAULT_DOWN_SAMPLING,
241
- help="Down sampling rate of features. Default is 0.0001."
242
- )
243
-
244
- parser.add_argument('--model','-m',
245
- dest="model",
246
- nargs='?',
247
- default=DEFAULT_MODEL_NAME,
248
- help='Select the model(KNN, LR, MLP, RF, SVM).'
249
- )
250
-
251
183
  parser.add_argument('--classify', '-f',
252
184
  dest="classify",
253
185
  action='store_true',
@@ -259,14 +191,6 @@ def parameter_parser(config: Config) -> Config:
259
191
  config.path.input = args.input_path
260
192
  config.path.output = args.output_path
261
193
  config.path.config = args.config_path
262
- config.model.dimensions = args.dimensions
263
- config.model.workers = args.workers
264
- config.model.epochs = args.epochs
265
- config.model.min_count = args.min_count
266
- config.model.wl_iterations = args.wl_iterations
267
- config.model.learning_rate = args.learning_rate
268
- config.model.down_sampling = args.down_sampling
269
- config.model.modelName = args.model
270
194
  config.classify = args.classify
271
195
 
272
196
  return config
malwareDetector/const.py CHANGED
@@ -2,17 +2,9 @@
2
2
  Save the variables of the system's default constants.
3
3
  '''
4
4
 
5
- DEFAULT_INPUT_PATH="./Dataset/malware"
6
- DEFAULT_OUT_PATH="./Feature/feature.csv"
5
+ DEFAULT_INPUT_PATH="./Dataset/program"
6
+ DEFAULT_OUT_PATH="./Predict/predict.json"
7
7
  DEFAULT_CONFIG_PATH="./config.json"
8
- DEFAULT_MODEL_NAME="SVM"
9
- DEFAULT_DIMENSIONS=128
10
- DEFAULT_WORKERS=4
11
- DEFAULT_EPOCHS=50
12
- DEFAULT_MIN_COUNT=1
13
- DEFAULT_WL_ITERATIONS=2
14
- DEFAULT_LEARNING_RATE=0.025
15
- DEFAULT_DOWN_SAMPLING=0.0001
16
8
  DEFAULT_CLASSIFY=False
17
9
 
18
10
  DATASET_DIR="./Dataset/"
@@ -1,15 +1,19 @@
1
1
  import os
2
2
  import numpy as np
3
+
3
4
  from typing import Any
4
5
  from .config import read_config
5
6
  from .utils import platform_info
7
+ from .const import DEFAULT_CONFIG_PATH
6
8
 
7
9
  class detector(object):
8
- def __init__(self) -> None:
10
+ def __init__(self, config_path=None) -> None:
9
11
  '''
10
12
  read config.json by `read_config` function in `config.py`
11
13
  '''
12
- self.config = read_config()
14
+ if config_path is None:
15
+ config_path = DEFAULT_CONFIG_PATH
16
+ self.config = read_config(config_path)
13
17
 
14
18
  def extractFeature(self) -> Any:
15
19
  '''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: malwareDetector
3
- Version: 0.1.12
3
+ Version: 0.1.13
4
4
  Summary: Malware detector specification for NTUST isLab
5
5
  Author: PO-LIN LAI
6
6
  Author-email: bolin8017@gmail.com
@@ -11,49 +11,45 @@ License-File: LICENCE.txt
11
11
  Requires-Dist: numpy
12
12
  Requires-Dist: pydantic
13
13
 
14
- malwareDetector
15
- ===============
14
+ # malwareDetector
16
15
 
17
16
  * Source code: https://github.com/louiskyee/malwareDetector.git
18
17
  * Wiki: https://github.com/louiskyee/malwareDetector/wiki
19
18
  * PyPI: https://pypi.org/project/malwareDetector/
20
19
 
21
- Description
22
- -----------
20
+ ## Description
23
21
 
24
22
  This is a malware detector specification for NTUST isLab.
25
23
  The `malwareDetector` is a base class designed for malicious software detection. It enables straightforward utilization of Python's inheritance feature. By inheriting from `malwareDetector` and implementing the required functions, you can achieve your specific goals. Additionally, it offers convenient configuration management. For more detailed instructions, please refer to the [GitHub Wiki](https://github.com/louiskyee/malwareDetector/wiki).
26
24
 
27
- Requirements
28
- ------------
29
- Tool | Version |Source |
30
- |---|---|---|
31
- | Python | `>= 3.10` | https://www.python.org/downloads |
25
+ ## Requirements
32
26
 
33
- Installation
34
- ------------
27
+ Tool | Version | Source
28
+ -----|---------|-------
29
+ Python | `>= 3.10` | https://www.python.org/downloads
30
+
31
+ ## Installation
35
32
 
36
33
  Use the package manager [pip](https://pip.pypa.io/en/stable/) to install `malwareDetector`.
37
34
  * Example: `pip install malwareDetector`
38
35
 
39
- Usage
40
- -----
36
+ ## Usage
41
37
 
42
- ### import
43
- * import class `detector` from `malwareDetector.detector`
44
- ```python=
38
+ ### Import
39
+ * Import class `detector` from `malwareDetector.detector`
40
+ ```python
45
41
  from malwareDetector.detector import detector
46
42
  ```
47
43
 
48
- ### Examples:
49
- ```python=
50
- from malwareDetector.detector import detector
51
- from typing import Any
44
+ ### Example:
45
+ ```python
52
46
  import numpy as np
47
+ from typing import Any
48
+ from malwareDetector.detector import detector
53
49
 
54
50
  class subDetector(detector):
55
- def __init__(self) -> None:
56
- super().__init__()
51
+ def __init__(self, config_path=None) -> None:
52
+ super().__init__(config_path)
57
53
 
58
54
  def extractFeature(self) -> Any:
59
55
  return 'This is the implementation of the extractFeature function from the derived class.'
@@ -61,9 +57,22 @@ class subDetector(detector):
61
57
  def vectorize(self) -> np.array:
62
58
  return 'This is the implementation of the vectorize function from the derived class.'
63
59
 
64
- def model(self) -> Any:
60
+ def model(self, training: bool = True) -> Any:
65
61
  return 'This is the implementation of the model function from the derived class.'
66
62
 
67
63
  def predict(self) -> np.array:
68
64
  return 'This is the implementation of the predict function from the derived class.'
69
65
  ```
66
+
67
+ ## Configuration
68
+
69
+ The `malwareDetector` uses a configuration system that can be customized through a JSON file or command-line arguments. The default configuration file is `config.json` in the current directory, but you can specify a custom path when initializing the detector.
70
+
71
+ ### Key Configuration Classes:
72
+
73
+ - `Config`: Stores all external settings for the detector.
74
+ - `PathConfig`: Manages input and output file paths.
75
+ - `FolderConfig`: Handles folder configurations for data storage.
76
+ - `ModelConfig`: Stores model-specific parameters and hyperparameters.
77
+
78
+ For detailed information on configuration options and usage, please refer to the [GitHub Wiki](https://github.com/louiskyee/malwareDetector/wiki).
@@ -0,0 +1,10 @@
1
+ malwareDetector/__init__.py,sha256=x9kkfeWTUR0g6RQkE13V2sZhY2DSVD3KqzcxOqlNjtA,768
2
+ malwareDetector/config.py,sha256=EOAFPqLyKMFvg8fEc9utpadCqdTeMGYL-312E9hF6Hs,9397
3
+ malwareDetector/const.py,sha256=JJCGc9eniIpyrV5YGtCqjEPbeQYkJw3jTiaJb_Dt9EE,341
4
+ malwareDetector/detector.py,sha256=nyfnLjoxr0l3eL-HyuWJ-6EoBn28_lYEYwStsYH7dog,2358
5
+ malwareDetector/utils.py,sha256=kjEX-A-FuwjGwxZ-2JP489NaaeC7HwvdMrDrfPk4pYE,371
6
+ malwareDetector-0.1.13.dist-info/LICENCE.txt,sha256=2XPCaZqZ-jgHh7e1DKa87JUeuOB6DC0jaZonmjDeILM,1088
7
+ malwareDetector-0.1.13.dist-info/METADATA,sha256=ZokOssLklL5ZTNNtJNTjkb6_Gb_gvHts2mgAZojZ91I,3014
8
+ malwareDetector-0.1.13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
9
+ malwareDetector-0.1.13.dist-info/top_level.txt,sha256=wRXSanQD5XDXRYp3lPh1SjltOo6rpC5jktmR69tqIQo,16
10
+ malwareDetector-0.1.13.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- malwareDetector/__init__.py,sha256=x9kkfeWTUR0g6RQkE13V2sZhY2DSVD3KqzcxOqlNjtA,768
2
- malwareDetector/config.py,sha256=a00Whtx_2vdaJQH7luJECEMOIlyfaMLHbDHyfncMo-k,12430
3
- malwareDetector/const.py,sha256=8TKTqjS70sU3cBFSwFUaWmoLiguRbi0ul63xswtA_Ho,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.12.dist-info/LICENCE.txt,sha256=2XPCaZqZ-jgHh7e1DKa87JUeuOB6DC0jaZonmjDeILM,1088
7
- malwareDetector-0.1.12.dist-info/METADATA,sha256=uE3uqGROsWh6Yy9UDTWB6EaGsropygdRX7a38Z3Svuw,2287
8
- malwareDetector-0.1.12.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
9
- malwareDetector-0.1.12.dist-info/top_level.txt,sha256=wRXSanQD5XDXRYp3lPh1SjltOo6rpC5jktmR69tqIQo,16
10
- malwareDetector-0.1.12.dist-info/RECORD,,