#!/usr/bin/env python3 import re from os import listdir from os.path import isdir from audit.system.plugins.localaccount import profile, password_quality class LocalAccount: def __init__(self, arguments): self._profile = profile() self._passwd_quality = password_quality() self._reports = dict() # Create the report self._constructReports() # Report #self._reports[""] = self._apache_directory def runAudit(self): print("Running test for Local account") self._analyzingProfile() self._analyzingPasswordQuality() print(self._reports) def getReports(self) -> dict: return self._reports def _analyzingProfile(self): # Check if the file exist path = self._profile['filename'] try: with open(path, 'rb') as fdata: self._parseFile(fdata) except FileNotFoundError: self._reports['localaccount']['profile']['error'] = \ f'File {path} not found' def _parseFile(self, fdata): data = fdata.read() lines = data.splitlines() for line in lines: line = line.decode('utf-8') for obj in self._profile['data']: grFlag = re.search(f"^{obj['flag']}", line) if grFlag: print(line) def _analyzingPasswordQuality(self): pass def _constructReports(self): """ Construct dictionary for result of the tests Each entry contains: Key: - filename: filename of the test - line: line of the test - parse: Display the line where the vulnerabilites has been found - description: description of the vulnerability - level: high, medium or low """ self._reports['localaccount'] = dict() self._reports['localaccount']['profile'] = dict() self._reports['localaccount']['pwd_quality'] = dict()