diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-11 18:32:19 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-11 18:32:19 -0500 |
| commit | 1ff51146d9de6ed76e67945fea9f9ca61acdda00 (patch) | |
| tree | 45dc80733c69c4d0486f4a9763dd6c4ed851c96a /todo.org | |
| parent | 24e3c8497c69011ae5f4e35c35deac4996b45d2c (diff) | |
| download | archsetup-1ff51146d9de6ed76e67945fea9f9ca61acdda00.tar.gz archsetup-1ff51146d9de6ed76e67945fea9f9ca61acdda00.zip | |
feat(archsetup): add input validation for config and username
A new `validate_config()` runs whenever `--config-file` is used and rejects bad values up front instead of letting the install run partway and die: `DESKTOP_ENV` must be dwm/hyprland/none (previously only caught in the display-server step), `AUTOLOGIN`/`NO_GPU_DRIVERS` must be yes/no (previously silently ignored), `LOCALE` gets a basic shape check, and the six `*_REPO` URLs get a scheme plus no-whitespace/no-leading-dash check before they reach `git clone`.
I also pulled the username regex and reserved-names check out of `preflight_checks()` into a `validate_username()` helper, and call it from both `preflight_checks()` and `validate_config()`. That closes a gap: the old inline check only ran when the username was prompted, so a config-supplied `USERNAME=root` went through unchecked.
This is not a security boundary: `load_config` sources the config as bash, so a hostile config can already do anything. It is about catching typos with a clear message. Verified with `bash -n` and a smoke-test matrix. The next `make test` run confirms valid configs still install.
Diffstat (limited to 'todo.org')
| -rw-r--r-- | todo.org | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -96,12 +96,16 @@ May have licensing issues for redistribution. Line 1781: =curl | sh= from claude.ai — should be behind a config flag. Not all users want AI tooling; curl-pipe-bash is a red flag for reviewers. -*** TODO [#B] Add input validation for username and paths +*** DOING [#B] Add input validation for username and paths Variables like ~$username~, ~$source_dir~, and paths are not validated. Special characters or malicious input could break the script or cause security issues. Should validate inputs match expected patterns (alphanumeric, valid paths, etc.). -cj: you can probably do this one on your own +**** 2026-05-11 Mon @ 18:20:49 -0500 AI Response: validate_config + validate_username added +Added two pre-flight validators to =archsetup= (right after =load_config=, before any install step): +- =validate_username()= — the lowercase / starts-with-letter / =[a-z0-9_]= / not-reserved check, extracted from the inline block in =preflight_checks()=. Fixes an existing gap: the inline check only ran on the *prompted* path, so a config with =USERNAME=root= (or =USERNAME=foo bar=) slipped through unvalidated. Now both =preflight_checks= and =validate_config= call it. +- =validate_config()= — runs whenever =--config-file= is used: rejects unknown =DESKTOP_ENV= (must be dwm/hyprland/none) early instead of dying in step 7-9; rejects =AUTOLOGIN=/=NO_GPU_DRIVERS= values that aren't =yes=/=no= (currently silently ignored); basic shape check on =LOCALE=; and a scheme + no-whitespace/no-leading-dash check on the six =*_REPO= URLs that get passed to =git clone= (rejects e.g. =--upload-pack=…= injection). Plain =echo …>&2; exit 1= (the logging helpers aren't defined that early). =$source_dir= needs no separate check — it's =/home/$username/.local/src=, derived from the now-always-validated =$username=. +Not a security boundary (=load_config= sources the config as bash; a hostile config can already run anything) — it's typo-catching. Verified with =bash -n= and a smoke-test matrix of good/bad inputs through both functions. The next =make test= run confirms valid configs still install. Leaving as DOING for review. *** TODO [#B] Move battery out of waybar sysmonitor group Battery module is inside =group/sysmonitor= which bundles cpu, temp, memory, disk, and battery together. Battery should be a standalone module in =modules-right= so it's visible on laptops without the full sysmonitor group. |
