Skip to content

Commit 1683db0

Browse files
Promoted --performance-check flag from beta to official, fixed major bug in zipping
- Removed "Beta Mode" label from the --performance-check help text - Flag is now considered stable and ready for general use - Removed the memory usage section as it is unreliable and in very low values and is also influenced by other system apps - Renamed vulnscan folder and items to be bug free, as old name resulted in the files getting zipped - Found bug in vulnscan that causes a critical crash, will fix in next commit Signed-off-by: Shahm Najeeb <[email protected]>
1 parent 02f68ce commit 1683db0

File tree

9 files changed

+23
-52
lines changed

9 files changed

+23
-52
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ $RECYCLE.BIN/
319319
*.pyc
320320
/CODE/SysInternal_Suite/.sys.ignore
321321
/ACCESS/
322-
/CODE/VulnScan/tools/NN features/
322+
/CODE/vulnscan/tools/NN features/
323323
/CODE/logicytics/User_History.json.gz
324324
/CODE/logicytics/User_History.json
325325
/CODE/SysInternal_Suite/psfile.exe

.idea/Logicytics.iml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/webResources.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CODE/Logicytics.py

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from concurrent.futures import ThreadPoolExecutor, as_completed
88
from datetime import datetime
99

10-
import psutil
1110
from prettytable import PrettyTable
1211

1312
from logicytics import Log, execute, check, get, file_management, flag, DEBUG, DELETE_LOGS, config
@@ -198,54 +197,28 @@ def __performance(self):
198197
log.warning("Advised to turn on DEBUG logging!!")
199198

200199
execution_times = []
201-
memory_usage = []
202-
process = psutil.Process(os.getpid())
203200

204201
for file in range(len(self.execution_list)):
205202
gc.collect()
206203
start_time = datetime.now()
207-
start_memory = process.memory_full_info().uss / 1024 / 1024 # MB
208204
log.execution(execute.script(self.execution_list[file]))
209205
end_time = datetime.now()
210-
end_memory = process.memory_full_info().uss / 1024 / 1024 # MB
211206
elapsed_time = end_time - start_time
212-
memory_delta = max(0, end_memory - start_memory) # Clamps negative delta to 0
213-
memory_usage.append((self.execution_list[file], f"{memory_delta}"))
214207
execution_times.append((self.execution_list[file], elapsed_time))
215208
log.info(f"{self.execution_list[file]} executed in {elapsed_time}")
216-
try:
217-
if (end_memory - start_memory) < 0:
218-
log.info(
219-
f"{self.execution_list[file]} used {memory_delta:.3f}MB of memory - \033[33mPossible Affected by outside processes\033[0m")
220-
else:
221-
log.info(f"{self.execution_list[file]} used {memory_delta:.3f}MB of memory")
222-
except Exception as e:
223-
log.warning("Failed to log memory usage delta, reason: " + str(e))
224-
log.debug(f"Started with {start_memory:.3f}MB of memory and ended with {end_memory:.3f}MB of memory")
225209

226210
table = PrettyTable()
227-
table.field_names = ["Script", "Execution Time", "Memory Usage (MB)"]
211+
table.field_names = ["Script", "Execution Time"]
228212
for script, elapsed_time in execution_times:
229-
try:
230-
memory = f"{float(next(m[1] for m in memory_usage if m[0] == script)):.3f}"
231-
except StopIteration:
232-
log.warning(f"No memory data found for {script}")
233-
memory = "N/A"
234-
except Exception as e:
235-
log.warning(f"Failed to log memory usage for {script}, reason: " + str(e))
236-
memory = "N/A"
237-
table.add_row([script, elapsed_time, f"{memory}"])
213+
table.add_row([script, elapsed_time])
238214

239215
try:
240216
with open(
241217
f"../ACCESS/LOGS/PERFORMANCE/Performance_Summary_"
242218
f"{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.txt", "w"
243219
) as f:
244220
f.write(table.get_string())
245-
f.write(
246-
"\nSome values may be negative, Reason may be due to external resources playing with memory usage,\n"
247-
"Close background tasks to get more accurate readings\n\n")
248-
f.write("Note: This is not a low-level memory logger, data here isn't 100% accurate!\n")
221+
f.write("\nNote: This test only measures execution time.\n")
249222
log.info("Performance check complete! Performance log found in ACCESS/LOGS/PERFORMANCE")
250223
except Exception as e:
251224
log.error(f"Error writing performance log: {e}")
@@ -444,12 +417,12 @@ def handle_sub_action():
444417
"""
445418
log.info("Completed successfully!")
446419
log.newline()
447-
if ACTION == "performance_check":
448-
return # Do not handle sub actions for performance check
449-
if SUB_ACTION == "shutdown":
450-
subprocess.call("shutdown /s /t 3", shell=False)
451-
elif SUB_ACTION == "reboot":
452-
subprocess.call("shutdown /r /t 3", shell=False)
420+
# Do not handle sub actions for performance check
421+
if ACTION != "performance_check":
422+
if SUB_ACTION == "shutdown":
423+
subprocess.call("shutdown /s /t 3", shell=False)
424+
elif SUB_ACTION == "reboot":
425+
subprocess.call("shutdown /r /t 3", shell=False)
453426

454427

455428
@log.function

CODE/logicytics/FileManagement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __get_files_to_zip(path: str) -> list:
9292
"""
9393
excluded_extensions = (".py", ".exe", ".bat", ".ps1", ".pkl", ".pth")
9494
excluded_prefixes = ("config.ini", "SysInternal_Suite",
95-
"__pycache__", "logicytics", "VulnScan")
95+
"__pycache__", "logicytics", "vulnscan")
9696

9797
return [
9898
f for f in os.listdir(path)

CODE/logicytics/Flag.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,11 @@ def __available_arguments(cls) -> tuple[argparse.Namespace, argparse.ArgumentPar
463463
help="Run Logicytics in minimal mode. Just bare essential scraping using only quick scripts",
464464
)
465465

466-
# TODO v3.6.0 -> Out of beta
467466
parser.add_argument(
468467
"--performance-check",
469468
action="store_true",
470469
help="Run's Logicytics default while testing its performance and time, "
471470
"this then shows a table with the file names and time to executed. "
472-
f"{cls.__colorify('- Beta Mode -', 'y')}"
473471
)
474472

475473
parser.add_argument(

CODE/vulnscan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async def scan_worker(scan_file):
185185
"C:\\Program Files",
186186
"C:\\Program Files (x86)"
187187
]
188-
vulnscan = VulnScan("vulnscan/Model SenseMini .3n3.pth", "vulnscan/Vectorizer .3n3.pkl")
188+
vulnscan = VulnScan("vulnscan/SenseMini.3n3.pth", "vulnscan/vectorizer.3n3.pkl")
189189
vulnscan.scan_directory(base_paths)
190190
except KeyboardInterrupt:
191191
log.warning("User interrupted. Exiting gracefully.")
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)