From 35b417d226fc3d11ac0015abdcb3594d2c696c2e Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Sat, 27 Apr 2024 02:18:05 +0200 Subject: fix(db): check valid target repo on db remove Return an error and abort operation when an invalid target repo is passed. Component: pkgctl db remove Signed-off-by: Levente Polyak --- src/lib/db/remove.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/lib/db/remove.sh b/src/lib/db/remove.sh index 6ca091d..cddcc1d 100644 --- a/src/lib/db/remove.sh +++ b/src/lib/db/remove.sh @@ -12,6 +12,8 @@ source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/pacman.sh # shellcheck source=src/lib/util/term.sh source "${_DEVTOOLS_LIBRARY_DIR}"/lib/util/term.sh +# shellcheck source=src/lib/valid-repos.sh +source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-repos.sh set -e @@ -92,6 +94,11 @@ pkgctl_db_remove() { PKGBASES+=("$@") pkgnames=("${PKGBASES[@]}") + # check if the target repo is valid + if ! in_array "${REPO}" "${DEVTOOLS_VALID_REPOS[@]}"; then + die "Invalid repository target: %s" "${REPO}" + fi + # update pacman cache to query all pkgnames if (( ! partial )); then case ${REPO} in -- cgit v1.2.3-70-g09d2