Skip to content

fix(scripts): pass args safely; drop bash -c usage#218

Merged
b23prodtm merged 4 commits intofix/composefrom
chunk/fix-shell-safe-arg-passing-drop-bash-c-1771189119040
Feb 16, 2026
Merged

fix(scripts): pass args safely; drop bash -c usage#218
b23prodtm merged 4 commits intofix/composefrom
chunk/fix-shell-safe-arg-passing-drop-bash-c-1771189119040

Conversation

@circleci-app
Copy link

@circleci-app circleci-app bot commented Feb 16, 2026

Prompt Given

the way I pass "$@" as variable args to function is causing the configuration issue

This change replaces unsafe string-based command execution with direct invocation and proper argument forwarding across several scripts.

  • Update shell_prompt to accept a script plus optional prompt flag and forward remaining args; run via "$script" "$@" instead of bash -c.
  • Replace bash -c with direct calls and "$@" in Scripts/bootstrap.sh, Scripts/composer.sh, and migrate-database.sh.
  • Adjust call sites to pass flags as separate, quoted args (e.g., -f "$hash", -p "$password" -s "$salt" -f "$file"), and prefer "$@" over $*.
  • Improve usage/help text and simplify prompt logic and case patterns.

Benefits:

  • Preserves whitespace and special characters in args
  • Reduces risk of injection and masked errors
  • Aligns scripts to consistent, safe argument handling

Give feedback on this PR

### What changed
- Use Docker BuildKit secret mount for `master_password` in `Dockerfile.x86_64`.
- Read secret from `/run/secrets/master_password` into `MASTER_PASSWORD` during `RUN`.
- Pass `-p` to `./configure.sh` only when `MASTER_PASSWORD` is set using `${MASTER_PASSWORD:+-p "$MASTER_PASSWORD"}`.
- Keep database migration steps unchanged.

### Why
- Prevents leaking credentials into image layers, env, or build args.
- Allows builds to proceed without a password by omitting the `-p` flag when unset.

### Build notes
- Requires BuildKit: set `DOCKER_BUILDKIT=1`.
- Provide the secret at build time, e.g.:
  `docker build --secret id=master_password,src=./master_password.txt .`
This change replaces unsafe string-based command execution with direct invocation and proper argument forwarding across several scripts.

- Update `shell_prompt` to accept a script plus optional prompt flag and forward remaining args; run via `"$script" "$@"` instead of `bash -c`.
- Replace `bash -c` with direct calls and `"$@"` in `Scripts/bootstrap.sh`, `Scripts/composer.sh`, and `migrate-database.sh`.
- Adjust call sites to pass flags as separate, quoted args (e.g., `-f "$hash"`, `-p "$password" -s "$salt" -f "$file"`), and prefer `"$@"` over `$*`.
- Improve usage/help text and simplify prompt logic and case patterns.

Benefits:
- Preserves whitespace and special characters in args
- Reduces risk of injection and masked errors
- Aligns scripts to consistent, safe argument handling
Copy link
Owner

@b23prodtm b23prodtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good chunk

@b23prodtm b23prodtm changed the base branch from chunk/buildkit-secret-master-password-1771185716586 to fix/compose February 16, 2026 23:18
@b23prodtm b23prodtm changed the base branch from fix/compose to chunk/buildkit-secret-master-password-1771185716586 February 16, 2026 23:27
@b23prodtm b23prodtm changed the base branch from chunk/buildkit-secret-master-password-1771185716586 to fix/compose February 16, 2026 23:33
@b23prodtm b23prodtm merged commit 599b158 into fix/compose Feb 16, 2026
1 of 8 checks passed
@b23prodtm b23prodtm deleted the chunk/fix-shell-safe-arg-passing-drop-bash-c-1771189119040 branch February 16, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments