Merge pull request #926 from molangning/master

Improved validation process
This commit is contained in:
g0tmi1k 2023-11-24 22:12:22 +00:00 committed by GitHub
commit 7e128ab391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 3 deletions

View File

@ -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)

11
.bin/validators.sh Executable file
View File

@ -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"

View File

@ -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 }}"
./.bin/validators.sh "${{ steps.changed-files.outputs.all_changed_files }}"