diff --git a/.bin/checkers/check-if-auto-updated.py b/.bin/checkers/check-if-auto-updated.py new file mode 100755 index 00000000..eb76df67 --- /dev/null +++ b/.bin/checkers/check-if-auto-updated.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 + +import os,sys,json + +if not sys.argv[1]: + exit(0) + +IS_WRAPPED=False + +if "IS_RUNNING_UNDER_CALLER_SCRIPT" in os.environ: + IS_WRAPPED=os.environ['IS_RUNNING_UNDER_CALLER_SCRIPT']=="1" + +def print_normal(msg): + + if IS_WRAPPED: + return + print(msg) + +def print_err(file,line_number): + + if IS_WRAPPED: + print("E,%s,%s"%(file,line_number)) + +def print_warn(file,line_number): + + if IS_WRAPPED: + print("W,%s,%s"%(file,line_number)) + +print_normal("[+] Remote wordlist overwrite check") +if IS_WRAPPED: + print("Remote wordlist overwrite check") + print("Files that the script catches will be overwritten next update.") + +files=sys.argv[1].split(" ") + +for i in files: + if not os.path.isfile(i): + print_err(i,0) + print_normal("[!] %s does not exist!"%(i)) + exit(2) + +overall_pass_status=True + +sources = json.load(open(".bin/wordlist-updaters/sources.json")) +overwritten_paths = { + "dirs": [], + "files": [] +} + +for source in sources: + found_paths = [] + + if "output" in source.keys(): + found_paths.append(source["output"]) + + if "additional_paths" in source.keys(): + found_paths += source["additional_paths"] + + for path in found_paths: + + if os.path.isdir(path): + overwritten_paths["dirs"].append(path) + + elif os.path.isfile(path): + overwritten_paths["files"].append(path) + +print(overwritten_paths) + +for i in files: + + for dir_path in overwritten_paths["dirs"]: + if i.startswith(dir_path): + print_normal(f"[!] Warning: file {i} is in a directory that will get overwritten!") + print_err(i, 0) + overall_pass_status=False + break + + for file_path in overwritten_paths["files"]: + if i == file_path: + print_normal(f"[!] Warning: file {i} will get overwritten!") + print_err(i, 0) + overall_pass_status=False + break + +if overall_pass_status: + print_normal("[+] All files passed overwrite checks") + exit(0) + +print_normal("[!] Warning: One or more files failed to pass the overwrite checks") + +if IS_WRAPPED: + exit(0) +else: + exit(2) diff --git a/.bin/wordlist-updaters/README.md b/.bin/wordlist-updaters/README.md index b16370b5..e4bf7e7c 100644 --- a/.bin/wordlist-updaters/README.md +++ b/.bin/wordlist-updaters/README.md @@ -40,6 +40,8 @@ All fields are required unless otherwise stated. `post_run_script` is the script to be run after pulling the list successfully. This field is optional. +`additional_paths` is the additional paths that the workflow script should alert if there is a pull request for the file. This field is optional and won't be used for the updater, but rather the checker. + - - - Example status.json diff --git a/.bin/wordlist-updaters/sources.json b/.bin/wordlist-updaters/sources.json index 1d68cf3b..b7aeb216 100644 --- a/.bin/wordlist-updaters/sources.json +++ b/.bin/wordlist-updaters/sources.json @@ -13,6 +13,10 @@ "source": "https://github.com/trickest/wordlists.git", "output": ".working_space", "post_run_script": ".bin/trickest-patcher.py", - "update_time": "1030" + "update_time": "1030", + "additional_paths": [ + "Discovery/Web-Content/trickest-robots-disallowed-wordlists/", + "Discovery/Web-Content/CMS/trickest-cms-wordlist/" + ] } ] \ No newline at end of file