mirror of
https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite.git
synced 2025-12-08 18:11:29 +00:00
update
This commit is contained in:
51
linPEAS/builder/src/fileRecord.py
Normal file
51
linPEAS/builder/src/fileRecord.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from .yamlGlobals import DEFAULTS, ROOT_FOLDER, COMMON_DIR_FOLDERS, COMMON_FILE_FOLDERS
|
||||
|
||||
class FileRecord:
|
||||
def __init__(self,
|
||||
regex: str,
|
||||
bad_regex: str=DEFAULTS["bad_regex"],
|
||||
check_extra_path: str =DEFAULTS["check_extra_path"],
|
||||
files: dict={},
|
||||
good_regex: str=DEFAULTS["good_regex"],
|
||||
just_list_file: bool=DEFAULTS["just_list_file"],
|
||||
line_grep: str=DEFAULTS["line_grep"],
|
||||
only_bad_lines: bool=DEFAULTS["only_bad_lines"],
|
||||
remove_empty_lines: bool=DEFAULTS["remove_empty_lines"],
|
||||
remove_path: str=DEFAULTS["remove_path"],
|
||||
remove_regex: str=DEFAULTS["remove_regex"],
|
||||
search_in: list=DEFAULTS["search_in"],
|
||||
type: str=DEFAULTS["type"],
|
||||
):
|
||||
|
||||
self.regex = regex
|
||||
self.bad_regex = bad_regex
|
||||
self.check_extra_path = check_extra_path
|
||||
self.files = [FileRecord(regex=regex,**fr) for regex,fr in files.items()]
|
||||
self.good_regex = good_regex
|
||||
self.just_list_file = just_list_file
|
||||
self.line_grep = line_grep
|
||||
self.only_bad_lines = only_bad_lines
|
||||
self.remove_regex = remove_regex
|
||||
self.remove_empty_lines = remove_empty_lines
|
||||
self.remove_path = remove_path
|
||||
self.type = type
|
||||
self.search_in = self.__resolve_search_in(search_in)
|
||||
|
||||
def __resolve_search_in(self, search_in):
|
||||
""" Resolve spacial values to the correct directories """
|
||||
|
||||
if "all" in search_in:
|
||||
search_in.remove("all")
|
||||
search_in = ROOT_FOLDER
|
||||
|
||||
if "common" in search_in:
|
||||
search_in.remove("common")
|
||||
if self.type == "d":
|
||||
search_in = list(set(search_in + COMMON_DIR_FOLDERS))
|
||||
else:
|
||||
search_in = list(set(search_in + COMMON_FILE_FOLDERS))
|
||||
|
||||
#Check that folders to search in are specified in ROOT_FOLDER
|
||||
assert all(r in ROOT_FOLDER for r in search_in)
|
||||
|
||||
return search_in
|
||||
Reference in New Issue
Block a user