TSA/tsca: anchor CA state to the script directory and make --force deletion safe #5
Labels
No labels
nagonag
nagonag/ignore
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
heiko/mailseal#5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
TSA/tscaperforms destructive and secret-generating operations relative to the caller's current working directory:Running
TSA/tscafrom the repository root already creates a separate root-levelca/; running it from another directory can overwrite or delete an unrelated./ca.--forceis especially dangerous because the target is not anchored or sanity-checked.The OpenSSL configuration is resolved relative to the script, but key/certificate/serial paths from
openssl.cnfstill depend on the working directory.Checklist analogue: #12 (project/path organization; avoid implicit working-directory state).
Proposed fix
script_dirwith a robust absolute path and place all test CA state under a single documented directory such as$script_dir/ca.cd -- "$script_dir"after validating it.rm -rf, require a nonempty absolute expected path and reject/,., the current directory, and paths outside the test fixture directory.$0uses.mktemp -dfixture for tests.Acceptance criteria
TSA/, or another directory uses the same safe fixture location.--forcecannot delete any path outside that location.Reviewed against
948b7a9onmaster(Go 1.26.2).CA state is anchored to the script directory (safe
--force, 0600 keys, path-with-spaces safe), with functional isolation tests.Implementation:
a6ca68d— anchor generated CA state to script directoryTests:
2e4584b— functionally verify script-anchoring and --force safetyMerged to master in
8616f1c.(Closed manually: these commits predate the (closes #N) subject convention.)