File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -110,3 +110,8 @@ repos:
110110 language : system
111111 files : ^resources/.*\.php$
112112 exclude : ^resources/lib/UnityHTTPD\.php$
113+ - id : assert-forbidden-used
114+ name : Assert forbidden() is used
115+ entry : bash ./test/assert-forbidden-used.bash
116+ language : system
117+ files : ^webroot/admin/.*\.php$
Original file line number Diff line number Diff line change 2222 This will enable strict mode and throw an exception rather than returning ` false ` .
2323- ` UnityHTTPD ` 's user-facing error functionality (ex: ` badRequest ` ) should only be called from ` webroot/**/*.php ` .
2424 ` resources/**/*.php ` should throw exceptions instead.
25+ - all pages under ` webroot/admin/ ` must check for ` $USER->isAdmin() ` and call ` UnityHTTPD::forbidden() ` if not admin.
2526
2627This repository will automatically check PRs for linting compliance.
2728
Original file line number Diff line number Diff line change 1+ set -euo pipefail
2+ trap ' s=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
3+ if [[ $# -lt 1 ]]; then
4+ echo " at least one argument required"
5+ exit 1
6+ fi
7+
8+ rc=0
9+ for file in " $@ " ; do
10+ grep_rc=0; grep -q UnityHTTPD::forbidden " $file " || grep_rc=$?
11+ case " $grep_rc " in
12+ 0)
13+ : ;; # code is good, do nothing
14+ 1)
15+ echo " UnityHTTPD::forbidden() was not called in file '$file '!" ; rc=1 ;;
16+ * )
17+ echo " grep failed!" ; rc=1 ;;
18+ esac
19+ done
20+ exit " $rc "
You can’t perform that action at this time.
0 commit comments