Damcava35/test pre commit (#256)

* chore: make linter happy for existing code

* fix: add missing test 2.1.2_disable_bsd_intetd.sh

* feat: add basic pre commit

Ensure a check has a corresponding test

---------

Co-authored-by: Damien Cavagnini <damien.cavagnini@corp.ovh.com>
This commit is contained in:
damcav35
2025-06-23 10:23:43 +02:00
committed by GitHub
parent 9a225c6157
commit 99bc575714
8 changed files with 56 additions and 4 deletions

21
hooks/check_has_test.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/bash
test_path="tests/hardening"
failure=0
failed_checks=""
for check in "$@"; do
base_name=$(basename "$check")
if [ ! -f $test_path/"$base_name" ]; then
failure=1
failed_checks="$failed_checks $base_name"
fi
done
if [ $failure -ne 0 ]; then
for check in $failed_checks; do
echo "missing file $test_path/$check"
done
fi
exit $failure