mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Address more code quality issues
This commit is contained in:
parent
eb9d0bba3e
commit
94f77e1330
4 changed files with 49 additions and 54 deletions
|
|
@ -9,6 +9,19 @@ set -e # Exit on error
|
|||
# Configuration
|
||||
VERSION="${SAFE_CHAIN_VERSION:-}" # Will be fetched from latest release if not set
|
||||
SAFE_CHAIN_BASE="${SAFE_CHAIN_DIR:-${HOME}/.safe-chain}"
|
||||
|
||||
# Validate SAFE_CHAIN_BASE before any filesystem operations
|
||||
case "${SAFE_CHAIN_BASE}" in
|
||||
/*) ;;
|
||||
*) printf '[ERROR] SAFE_CHAIN_DIR must be an absolute path, got: %s\n' "${SAFE_CHAIN_BASE}" >&2; exit 1 ;;
|
||||
esac
|
||||
case "${SAFE_CHAIN_BASE}" in
|
||||
*../*|*/..*|..) printf '[ERROR] SAFE_CHAIN_DIR must not contain path traversal (..)\n' >&2; exit 1 ;;
|
||||
esac
|
||||
if [ "${SAFE_CHAIN_BASE}" = "/" ]; then
|
||||
printf '[ERROR] SAFE_CHAIN_DIR cannot be the root directory\n' >&2; exit 1
|
||||
fi
|
||||
|
||||
INSTALL_DIR="${SAFE_CHAIN_BASE}/bin"
|
||||
REPO_URL="https://github.com/AikidoSec/safe-chain"
|
||||
|
||||
|
|
@ -247,20 +260,6 @@ parse_arguments() {
|
|||
|
||||
# Main installation
|
||||
main() {
|
||||
# Validate SAFE_CHAIN_DIR before using it to write files
|
||||
if [ -n "${SAFE_CHAIN_DIR}" ]; then
|
||||
case "${SAFE_CHAIN_DIR}" in
|
||||
/*) ;; # absolute path — OK
|
||||
*) error "SAFE_CHAIN_DIR must be an absolute path, got: ${SAFE_CHAIN_DIR}" ;;
|
||||
esac
|
||||
case "${SAFE_CHAIN_DIR}" in
|
||||
*../*|*/..*|..) error "SAFE_CHAIN_DIR must not contain path traversal (..)" ;;
|
||||
esac
|
||||
if [ "${SAFE_CHAIN_DIR}" = "/" ]; then
|
||||
error "SAFE_CHAIN_DIR cannot be the root directory"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Initialize argument flags
|
||||
USE_CI_SETUP=false
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue