forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-file-permissions
More file actions
executable file
·51 lines (47 loc) · 1.42 KB
/
check-file-permissions
File metadata and controls
executable file
·51 lines (47 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
set -eu
INCLUDE_DIRS=(
'.github/'
'admin/'
'app/'
'changelogs/'
'contributing/'
'public/'
'system/'
'tests/'
'user_guide_src/'
'utils/'
'writable/'
)
EXCLUDE_FILES=(
':!.github/scripts/deploy-userguide'
':!admin/release-userguide'
':!admin/release-deploy'
':!admin/apibot'
':!admin/alldocs'
':!admin/release'
':!admin/docbot'
':!admin/release-notes.bb'
':!admin/release-revert'
':!admin/starter/builds'
':!admin/userguide/.github/scripts/deploy.sh'
':!user_guide_src/add-edit-this-page'
':!utils/check-file-permissions'
)
FILES_WITH_WRONG_PERMISSIONS=$(
git ls-files --stage "${INCLUDE_DIRS[@]}" "${EXCLUDE_FILES[@]}" \
| grep --extended-regexp "^100755 " \
| sort -fh
)
if [[ -n "$FILES_WITH_WRONG_PERMISSIONS" ]]; then
printf '\033[41m FAIL \033[0m Files with unnecessary execution permissions were detected:\n'
[[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::group::Non-executable files'
echo "$FILES_WITH_WRONG_PERMISSIONS" | awk '{print " - " $4}'
echo ''
echo "$FILES_WITH_WRONG_PERMISSIONS" | awk '{print $4}' | xargs -n1 printf 'Please run "\033[32msudo chmod\033[0m -x %s".\n'
[[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::endgroup::'
fi
if [[ -n "$FILES_WITH_WRONG_PERMISSIONS" ]]; then
exit 1
fi
printf '\033[42m OK \033[0m No files with unnecessary execution permissions were detected.\n'