-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
144 lines (123 loc) · 4.57 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import os
from dataclasses import dataclass
import hashlib
from datetime import datetime
import logging
logger = logging.getLogger(__name__)
logger.setLevel(os.getenv('MERGELOGGING', 'INFO'))
class MergeConfig():
DO_COMPARE: bool
DO_COPY: bool
DO_DELETE: bool
DO_MKDIR: bool
DO_CLEANUP_SOURCE: bool
IGNORE_DOT_UNDERSCORE_FILES: bool
DO_QUIET: bool
DO_STATS: bool
SECURITY_TIMEOUT: int
DO_SHALLOW: bool
DO_IGNORE: bool
IGNORE_PATH: str
LOG_FILE_NOT_FOUND_ERRORS: bool
AUDIT_LOG_FILE: str
DO_SUPRESS_UNKNOWN_EXCEPTIONS: bool
# init with safe values
def __init__(self):
self.DO_COMPARE = True
self.DO_COPY = False
self.DO_DELETE = False
self.DO_MKDIR = False
self.DO_CLEANUP_SOURCE = False
self.IGNORE_DOT_UNDERSCORE_FILES = False
self.DO_QUIET = True
self.DO_STATS = True
self.SECURITY_TIMEOUT = 60
self.DO_SHALLOW = False
self.DO_IGNORE = False
self.IGNORE_PATH = ""
self.LOG_FILE_NOT_FOUND_ERRORS = False
self.AUDIT_LOG_FILE= f'{os.getcwd()}/AUDIT_LOG_FILE.log'
self.DO_SUPRESS_UNKNOWN_EXCEPTIONS = False
def show_config(self):
config_formatted = f"""
We will execute with the following options:
* Run quietly: {self.DO_QUIET}
* Copy source files to destination: {self.DO_COPY}
* Compare files before copying: {self.DO_COMPARE}
* Do a shallow comparison (compare only metadata): {self.DO_SHALLOW}
* Create subdirectories in target if they don't exist: {self.DO_MKDIR}
* Delete source files after processing: {self.DO_DELETE}
* Delete subdirectories on source after processing: {self.DO_CLEANUP_SOURCE}
* Ignore ._* files (special MAC files): {self.IGNORE_DOT_UNDERSCORE_FILES}
* Log Files not found: {self.LOG_FILE_NOT_FOUND_ERRORS}
* Continue even with unknown file handling exceptions: {self.DO_SUPRESS_UNKNOWN_EXCEPTIONS}"
* Log File: {self.AUDIT_LOG_FILE}
* Show Stats: {self.DO_STATS}
* Wait {self.SECURITY_TIMEOUT} seconds before continuining for safety reasons
"""
return config_formatted
class ScanConfig():
IGNORE_DOT_UNDERSCORE_FILES: bool
DO_QUIET: bool
DO_STATS: bool
SECURITY_TIMEOUT: int
DATASTORE: str
SESSION_ID: str
LOG_FILE_NOT_FOUND_ERRORS: bool
AUDIT_LOG_FILE: str
DO_SUPRESS_UNKNOWN_EXCEPTIONS: bool
BUF_SIZE: int
SIZE_THRESHOLD: int
HASH_SHALLOW_BLOCKS: int
DO_SHALLOW_HASH: bool
HASH_FUNCTION: callable
TIMESTAMP: str
UNDER_THRESHOLD_TEXT: str
PHYSICAL_DELETE: bool
# init with safe values
def __init__(self):
self.IGNORE_DOT_UNDERSCORE_FILES = False
self.DO_QUIET = True
self.DO_STATS = True
self.SECURITY_TIMEOUT = 60
self.LOG_FILE_NOT_FOUND_ERRORS = False
self.AUDIT_LOG_FILE= f'{os.getcwd()}/AUDIT_LOG_FILE.log'
self.DO_SUPRESS_UNKNOWN_EXCEPTIONS = False
self.BUF_SIZE = 32*1024 # lets read stuff in 32kb chunks!
self.SIZE_THRESHOLD = 32*1024 # read stuff in 32kb chunks!
self.HASH_SHALLOW_BLOCKS = 10 # minimum number of blocks that the file has to be to run a shallow hash
self.DO_SHALLOW_HASH = True # minimum number of blocks that the file has to be to run a shallow hash
self.HASH_FUNCTION = hashlib.md5
self.DATASTORE = 'datastore.db'
self.TIMESTAMP = datetime.now().isoformat(timespec='microseconds')
self.SESSION_ID = ''
self.UNDER_THRESHOLD_TEXT = "UNDER THRESHOLD"
self.PHYSICAL_DELETE = False
def show_config(self):
config_formatted = f"""
We will execute with the following options:
* Run quietly: {self.DO_QUIET}
* Ignore ._* files (special MAC files): {self.IGNORE_DOT_UNDERSCORE_FILES}
* Delete files physically (false means just report): {self.PHYSICAL_DELETE}
* Log Files not found: {self.LOG_FILE_NOT_FOUND_ERRORS}
* Continue even with unknown file handling exceptions: {self.DO_SUPRESS_UNKNOWN_EXCEPTIONS}"
* Log File: {self.AUDIT_LOG_FILE}
* Show Stats: {self.DO_STATS}
* Wait {self.SECURITY_TIMEOUT} seconds before continuining for safety reasons
"""
return config_formatted
class DataConfig():
DATASTORE:str
UNDER_THRESHOLD_TEXT: str
DRY_RUN: bool
# init with safe values
def __init__(self):
self.DATASTORE = 'datastore.db'
self.UNDER_THRESHOLD_TEXT = "UNDER THRESHOLD"
self.DRY_RUN = True
def show_config(self):
config_formatted = f"""
DRY_RUN: {self.DRY_RUN}
DataStore: {self.DATASTORE}
"""
return config_formatted