forked from danielmiessler/SecLists
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request danielmiessler#800 from righettod/feature_gha_chec…
…k_file_slash Add Github workflow to check for entries starting with "/".
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
# Script to verify if a file contain any entries starting with a slash and show a warning into the github action result UI. | ||
# Received as input a list of file paths to check separated by a space. | ||
# More precisely the result of the "tj-actions/changed-files" github action. | ||
## References: | ||
# See https://github.com/tj-actions/changed-files | ||
modified_files="$1" | ||
for modified_file in $modified_files | ||
do | ||
echo "[+] Check $modified_file ..." | ||
matches=$(grep -cE '^/[a-zA-Z0-9\._]+' $modified_file) | ||
echo "Entries identified starting with a slash: $matches" | ||
if [ $matches -ne 0 ] | ||
then | ||
echo "::warning file=$modified_file,line=1,col=1,endColumn=1::$matches entries start with a slash." | ||
fi | ||
done |
30 changes: 30 additions & 0 deletions
30
.github/workflows/wordlist-validator_verify_entries_for_starting_with_slash.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Validate that no entry start with a "/" for every modified or added files. | ||
# 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 | ||
on: | ||
push: | ||
paths: | ||
- "**.txt" | ||
pull_request: | ||
paths: | ||
- "**.txt" | ||
workflow_dispatch: | ||
jobs: | ||
check_files_changed: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Get changed files | ||
id: changed-files | ||
with: | ||
files: "**/*.txt" | ||
uses: tj-actions/changed-files@v34 | ||
- name: Analyze all added or modified files | ||
run: | | ||
chmod +x ./.bin/check-file-for-starting-slash | ||
./.bin/check-file-for-starting-slash "${{ steps.changed-files.outputs.all_changed_files }}" |