From 607736efd409bab8341d6d094acae907f630ab3a Mon Sep 17 00:00:00 2001 From: Mo Langning <133737702+molangning@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:42:25 +0000 Subject: [PATCH] Used env vars as input instead and removed debug line --- .bin/validators.py | 15 ++++++++++++--- .github/workflows/wordlist-validator.yml | 4 +++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.bin/validators.py b/.bin/validators.py index 3f225fd4..28d504f4 100755 --- a/.bin/validators.py +++ b/.bin/validators.py @@ -12,7 +12,6 @@ import os,subprocess,sys -args=sys.argv[1] files=[] STEP_SUMMARY_LOCATION="summary.md" IS_RUNNING_AS_ACTIONS=False @@ -73,6 +72,18 @@ ERROR_MSG="Errors in file %s on lines %s" WARNING_STRING="::warning file=%s,line=%s,col=%s,endColumn=%s::%s" ERROR_STRING="::error file=%s,line=%s,col=%s,endColumn=%s::%s" +if "CHANGED_FILES" not in os.environ: + print("[!] CHANGED_FILES environment variable not found!") + print("[-] This error may occur if you are running this script in your own machine\n") + if len(sys.argv) < 2: + print("[!] No arguments set, exiting.") + exit(2) + + args=sys.argv[1] +else: + args=os.environ["CHANGED_FILES"] + + if "GITHUB_STEP_SUMMARY" not in os.environ: print("[!] GITHUB_STEP_SUMMARY not found in system environments!") print("[-] This error may occur if you are running this script in your own machine\n") @@ -300,8 +311,6 @@ else: warn_msg=WARN_MSG%(file,', '.join(current_warnings)) check_results[checker_name]["warn"].append(warn_msg) - print(check_results) - for checker,results in check_results.items(): if len(results["error"])>0: diff --git a/.github/workflows/wordlist-validator.yml b/.github/workflows/wordlist-validator.yml index a7ca903d..6bbab8bb 100644 --- a/.github/workflows/wordlist-validator.yml +++ b/.github/workflows/wordlist-validator.yml @@ -28,4 +28,6 @@ jobs: uses: tj-actions/changed-files@v34 - name: Analyze all added or modified files run: | - ./.bin/validators.py "${{ steps.changed-files.outputs.all_changed_files }}" + ./.bin/validators.py + env: + CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} \ No newline at end of file