V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 2m2s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 2m2s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -122,6 +122,7 @@ ciss_secrets_wiper() {
|
||||
readonly -f ciss_secrets_wiper
|
||||
|
||||
#######################################
|
||||
# Purpose:
|
||||
# Parsing of only "*.value" keys from 'SECRETS.yaml' into Bash globals.
|
||||
# If the file contains SOPS markers, decrypt once (streaming) with sops/age, then yq parses in a single pass.
|
||||
# No base64, plain values preserved (including newlines). No repeated per-key decrypts or yq calls.
|
||||
@@ -143,8 +144,6 @@ readonly -f ciss_secrets_wiper
|
||||
# ERR_MISSING_AGE_KEY: on failure
|
||||
#######################################
|
||||
yaml_secret() {
|
||||
# TODO: Remove debug echos
|
||||
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -r SOPS_AGE_KEY_FILE="${CISS_SECRETS_AGE}"
|
||||
declare -a __names=()
|
||||
@@ -155,8 +154,7 @@ yaml_secret() {
|
||||
__umask=$(umask)
|
||||
umask 0077
|
||||
|
||||
# TODO: guard_trace on
|
||||
#guard_trace on
|
||||
guard_trace on
|
||||
|
||||
secrets_encrypted="$(yq -r '.secrets.x_files // false' -- "${secrets_if}")" || secrets_encrypted="false"
|
||||
do_log "debug" "file_only" "1256() 'secrets_encrypted' according to secrets.x_files: '${secrets_encrypted}'."
|
||||
@@ -209,6 +207,8 @@ yaml_secret() {
|
||||
# shellcheck disable=SC1091 source=./${__SECRETS}
|
||||
source "${__SECRETS}"
|
||||
|
||||
ciss_secrets_wiper "${__SECRETS}"
|
||||
|
||||
# shellcheck disable=SC2312
|
||||
mapfile -t __names < <(printf '%s\n' "${!secrets_@}")
|
||||
|
||||
@@ -216,33 +216,30 @@ yaml_secret() {
|
||||
|
||||
### Keep only *_value variables
|
||||
[[ "${__name}" == *_value ]] || continue
|
||||
echo "__name ${__name}"
|
||||
|
||||
### Validate strict Bash identifier (defensive: strip accidental CR).
|
||||
__name="${__name%$'\r'}"
|
||||
[[ "${__name}" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]] || continue
|
||||
echo "__name ${__name}"
|
||||
|
||||
### Only read if actually set; indirect check without triggering nounset.
|
||||
if [[ -n "${!__name+x}" ]]; then
|
||||
|
||||
__val="${!__name}"
|
||||
echo "__val ${__val}"
|
||||
|
||||
else
|
||||
|
||||
__val=""
|
||||
echo "__val ${__val}"
|
||||
|
||||
fi
|
||||
|
||||
### Strip suffix/prefix for the map key.
|
||||
__base="${__name%_value}"
|
||||
echo "__base ${__base}"
|
||||
__path_wo_prefix="${__base#secrets_}"
|
||||
echo "__path_wo_prefix ${__path_wo_prefix}"
|
||||
|
||||
### Canonical CISS name.
|
||||
__varname="$(ciss_secret_varname_from_path "${__path_wo_prefix}")"
|
||||
echo "__varname ${__varname}"
|
||||
|
||||
# Assign verbatim (preserves newlines)
|
||||
### Assign verbatim (preserves newlines).
|
||||
unset -v "${__varname}"
|
||||
declare -g "${__varname}"
|
||||
printf -v "${__varname}" '%s' "${__val}"
|
||||
@@ -253,16 +250,14 @@ yaml_secret() {
|
||||
|
||||
### Hygiene: remove the intermediate variables to reduce secret surface, e.g., unset 'secrets_*_value' after transfer.
|
||||
for __name in "${__names[@]}"; do
|
||||
|
||||
unset -v "${__name}"
|
||||
|
||||
done
|
||||
|
||||
umask "${__umask}"
|
||||
|
||||
echo "Inside 1256()"
|
||||
sleep 60
|
||||
|
||||
# TODO: guard_trace off
|
||||
#guard_trace off
|
||||
guard_trace off
|
||||
|
||||
guard_dir; return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user