mirror of
https://github.com/opnsense/core.git
synced 2026-02-03 20:39:42 -05:00
make: add lint-acl and finish first script iteration #7821
This commit is contained in:
parent
4de945bdae
commit
c02aabc109
2 changed files with 44 additions and 8 deletions
5
Makefile
5
Makefile
|
|
@ -395,6 +395,9 @@ lint-model:
|
|||
done; \
|
||||
done
|
||||
|
||||
lint-acl:
|
||||
@${.CURDIR}/Scripts/dashboard-acl.sh
|
||||
|
||||
SCRIPTDIRS!= find ${.CURDIR}/src/opnsense/scripts -type d -depth 1
|
||||
|
||||
lint-exec:
|
||||
|
|
@ -412,7 +415,7 @@ LINTBIN?= ${.CURDIR}/contrib/parallel-lint/parallel-lint
|
|||
lint-php:
|
||||
@${LINTBIN} src
|
||||
|
||||
lint: plist-check lint-shell lint-xml lint-model lint-exec lint-php
|
||||
lint: plist-check lint-shell lint-xml lint-model lint-acl lint-exec lint-php
|
||||
|
||||
sweep:
|
||||
find ${.CURDIR}/src -type f -name "*.map" -print0 | \
|
||||
|
|
|
|||
|
|
@ -25,18 +25,51 @@
|
|||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
WIDGETS=$(find -s src/opnsense/www/js/widgets -name "*.js")
|
||||
WIDGETDIR=src/opnsense/www/js/widgets
|
||||
|
||||
WIDGETS=$(find -s ${WIDGETDIR} -name "*.js")
|
||||
METADATA=$(find -s ${WIDGETDIR}/Metadata -name "*.xml")
|
||||
|
||||
for WIDGET in ${WIDGETS}; do
|
||||
ENDPOINTS=$(grep -o 'this\.ajaxCall([^,)]*' ${WIDGET} | cut -c 15- |
|
||||
tr -d "'" | tr -d '`' | sed 's:\$.*:*:')
|
||||
if [ -z "${ENDPOINTS}" ]; then
|
||||
FILENAME=$(basename ${WIDGET})
|
||||
if [ -z "${FILENAME%Base*}" ]; then
|
||||
# ignore base classes
|
||||
continue
|
||||
fi
|
||||
|
||||
echo ">>> $(basename ${WIDGET%.js}):"
|
||||
ENDPOINTS=$((grep -o 'this\.ajaxCall([^,)]*' ${WIDGET} | cut -c 15-;
|
||||
grep -o 'super\.openEventSource([^,)]*' ${WIDGET} | cut -c 23-) |
|
||||
tr -d "'" | tr -d '`' | sed 's:\$.*:*:' | sort -u)
|
||||
|
||||
for ENDPOINT in ${ENDPOINTS}; do
|
||||
echo "${ENDPOINT}"
|
||||
if [ -z "${ENDPOINTS}" ]; then
|
||||
echo "No endpoints found for ${WIDGET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REGISTERED=
|
||||
|
||||
for METAFILE in ${METADATA}; do
|
||||
if grep -q "<filename>${FILENAME}</filename>" ${METAFILE}; then
|
||||
REGISTERED=$(xmllint ${METAFILE} --xpath '//*[filename="'"${FILENAME}"'"]//endpoints//endpoint' |
|
||||
sed -e 's:^[^>]*>::' -e 's:<[^<]*$::' | sort)
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "${REGISTERED}" ]; then
|
||||
echo "Did not find metadata for ${WIDGET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${REGISTERED}" != "${ENDPOINTS}" ]; then
|
||||
echo "Registered widget endpoints do not match:"
|
||||
echo "<<<<<<< ${WIDGET}"
|
||||
echo "${ENDPOINTS}"
|
||||
echo ========
|
||||
echo "${REGISTERED}"
|
||||
echo ">>>>>>> ${METAFILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# XXX finally, check the registered endpoints against actual ACL defintions
|
||||
done
|
||||
|
|
|
|||
Loading…
Reference in a new issue