diff --git a/.bin/new-line-and-empty-line-checker.py b/.bin/new-line-and-empty-line-checker.py new file mode 100755 index 00000000..2818198c --- /dev/null +++ b/.bin/new-line-and-empty-line-checker.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +# test string: ./.bin/new-line-checker.py "Fuzzing/file-extensions-all-cases.txt Fuzzing/file-extensions-lower-case.txt Fuzzing/file-extensions-upper-case.txt Fuzzing/file-extensions.txt" + +import os +import sys + +print("[+] New line check") + +if not sys.argv[1]: + exit(0) + +files=sys.argv[1].split(" ") + +for i in files: + if not os.path.isfile(i): + print("[!] %s does not exist!"%(i)) + exit(2) + +for i in files: + f=open(i,"r") + contents=f.read() + + if contents[-1] == '\n': + print("[!] %s ends with a new line!"%(i)) + exit(2) + print("[+] %s passed new line check!"%(i)) + + counter=1 + + for line in contents.split('\n'): + if len(line)==0: + print("[!] %s has an empty entry at line %i!"%(i,counter)) + exit(2) + counter+=1 + print("[+] %s passed empty line check!"%(i)) + +print("[+] All files passed checks") +# exit(0) diff --git a/.bin/validators.sh b/.bin/validators.sh new file mode 100755 index 00000000..bf2e3f18 --- /dev/null +++ b/.bin/validators.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# https://stackoverflow.com/questions/3822621/how-to-exit-if-a-command-failed + +set -e +set -o pipefail + +# wrapper for all the checking scripts +echo $1 +./.bin/check-file-for-starting-slash "$1" +./.bin/new-line-and-empty-line-checker.py "$1" \ No newline at end of file diff --git a/.github/workflows/wordlist-validator_verify_entries_for_starting_with_slash.yml b/.github/workflows/wordlist-validator.yml similarity index 72% rename from .github/workflows/wordlist-validator_verify_entries_for_starting_with_slash.yml rename to .github/workflows/wordlist-validator.yml index a40be7cd..80a94422 100644 --- a/.github/workflows/wordlist-validator_verify_entries_for_starting_with_slash.yml +++ b/.github/workflows/wordlist-validator.yml @@ -2,8 +2,10 @@ # Sources: # https://dev.to/scienta/get-changed-files-in-github-actions-1p36 # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions -# https://github.com/marketplace/actions/changed-files -name: Wordlist Validator - Verify if any file entry start with a slash +# https://github.com/marketplace/actions/changed-files\ +# +# Modified to add a validator script +name: Wordlist Validator - Runs a validator script to check for dangerous pushes on: push: paths: @@ -26,4 +28,4 @@ jobs: uses: tj-actions/changed-files@v34 - name: Analyze all added or modified files run: | - ./.bin/check-file-for-starting-slash "${{ steps.changed-files.outputs.all_changed_files }}" \ No newline at end of file + ./.bin/validators.sh "${{ steps.changed-files.outputs.all_changed_files }}"