From 0080a68f3c22266e325dd81b0c44b8925e7ad770 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Fri, 16 Aug 2024 12:09:26 -0700 Subject: [PATCH] #3 Validate input is file path --- homelab/.sops/decrypt-filter.sh | 6 ++++++ homelab/.sops/encrypt-filter.sh | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/homelab/.sops/decrypt-filter.sh b/homelab/.sops/decrypt-filter.sh index e5d8229e..fadc1942 100755 --- a/homelab/.sops/decrypt-filter.sh +++ b/homelab/.sops/decrypt-filter.sh @@ -2,6 +2,12 @@ # Takes file path from stdin # Outputs to stdout +if ! [[ -f $1 ]]; then + echo "\$1 is not a file" + echo "\$1: $1" + exit 1 +fi + # Set age key file path # If no private key exists at the expected location, # Create the key file at the expected location diff --git a/homelab/.sops/encrypt-filter.sh b/homelab/.sops/encrypt-filter.sh index b0451399..ad691a10 100755 --- a/homelab/.sops/encrypt-filter.sh +++ b/homelab/.sops/encrypt-filter.sh @@ -2,6 +2,12 @@ # Takes file path from stdin # Outputs to stdout +if ! [[ -f $1 ]]; then + echo "\$1 is not a file" + echo "\$1: $1" + exit 1 +fi + # Set age directory and default recipients AGE_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) SOPS_AGE_RECIPIENTS="$(<$AGE_DIR/.age-author-pubkeys)"