Skip to content

Commit 140bee9

Browse files
committed
HBASE-29878 Monkey-patch YETUS-1266 fix for author_postcompile function
YETUS-1266 Escape regex metacharacters in author plugin ignore list The author_postcompile function writes --author-ignore-list entries directly into a grep -E filter file without escaping. Filenames containing regex metacharacters (parentheses, brackets, etc.) are silently misinterpreted as pattern syntax, causing those files to pass through unfiltered.
1 parent f36218b commit 140bee9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

dev-support/hbase-personality.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,56 @@ function docker_do_env_adds
6161
done
6262
}
6363

64+
# This is a workaround to fix the author check until YETUS-1266 is releases.
65+
# TODO: Remove this when we upgraded to Yetus having YETUS-1266!
66+
## @description Check the current directory for @author tags
67+
## @audience private
68+
## @stability evolving
69+
## @replaceable no
70+
## @return 0 on success
71+
## @return 1 on failure
72+
function author_postcompile
73+
{
74+
# shellcheck disable=SC2155
75+
declare -r appname=$(basename "${BASH_SOURCE-$0}")
76+
declare -a globalignore
77+
78+
if [[ "${BUILDMODE}" != full ]]; then
79+
return
80+
fi
81+
82+
big_console_header "Checking for @author tags: ${BUILDMODE}"
83+
84+
start_clock
85+
86+
if [[ -f "${PATCH_DIR}/excluded.txt" ]]; then
87+
globalignore=("${GREP}" "-v" "-f" "${PATCH_DIR}/excluded.txt")
88+
else
89+
globalignore=("cat")
90+
fi
91+
92+
"${GIT}" grep -n -I --extended-regexp -i -e '^[^-].*@author' \
93+
| "${GREP}" -v "${appname}" \
94+
| "${globalignore[@]}" \
95+
>> "${PATCH_DIR}/author-tags-git.txt"
96+
97+
if [[ -z "${AUTHOR_IGNORE_LIST[0]}" ]]; then
98+
cp -p "${PATCH_DIR}/author-tags-git.txt" "${PATCH_DIR}/${AUTHOR_LOGNAME}"
99+
else
100+
for i in "${AUTHOR_IGNORE_LIST[@]}"; do
101+
printf "%s\n" "${i}"
102+
done \
103+
| "${SED}" 's/[][\\.^$*+?{}()|]/\\&/g' \
104+
| "${SED}" 's/^/^/' \
105+
> "${PATCH_DIR}/author-tags-filter.txt"
106+
"${GREP}" -v -E \
107+
-f "${PATCH_DIR}/author-tags-filter.txt" \
108+
"${PATCH_DIR}/author-tags-git.txt" \
109+
> "${PATCH_DIR}/${AUTHOR_LOGNAME}"
110+
fi
111+
112+
author_generic
113+
}
64114

65115
## @description Globals specific to this personality
66116
## @audience private

0 commit comments

Comments
 (0)