fix(cmd): address security, bugs, and maintainability in plikd CLI#620
Merged
fix(cmd): address security, bugs, and maintainability in plikd CLI#620
Conversation
Security: - Remove database connection strings from export/import log output - Require explicit --file, --upload, or --all flag for file delete (no more silent fallthrough to mass-delete) - Reorder deleteUser: soft-delete uploads → clean data → delete user to prevent orphaned blobs Bugs: - Add missing os.Exit(1) in import.go (no-arg invocation would panic) - Move os.Exit out of sync.Once closures in init functions - Fix copy-paste error messages in token.go - Refactor signal handling to block on channel directly Maintainability: - Extract parseMaxSize/parseMaxTTL helpers (remove ~50 lines duplication) - Use cmd.Flags().Changed() consistently in updateUser - Add success confirmation messages to delete operations - Add progress output to clean command Documentation: - Add cobra Example fields to all subcommands - Document positional args in import/export Use strings - Add config search order to --config flag help text - Update ARCHITECTURE.md cmd table
- New operations/server-cli.md page covering user, token, file, and clean commands with flags, examples, and warnings - Fix stale sample output in import-export.md (remove connection strings) - Add Server CLI entry to sidebar navigation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Comprehensive review and fix of the
plikdserver CLI (server/cmd/), addressing security issues, bugs, maintainability, and documentation gaps.Why
A critical review of the CLI code surface uncovered several issues ranging from a panic on
plikd importwith no arguments, to a dangerous silent fallthrough to mass-delete infile delete, to credential leakage in log output.Changes
Security
export.go,import.gono longer printConnectionString(may contain credentials)file deletenow requires--file,--upload, or--allinstead of silently falling through to mass-delete when no flag is provideddeleteUsernow soft-deletes uploads → cleans data backend → deletes user metadata, preventing orphaned blobsBugs
plikd importwith no arguments would panic due to missingos.Exit(1)after error messageos.Exitinsync.Once— Init functions now store errors and check afterDo(), avoiding fragileos.Exitinside closuresShutdown()Maintainability
parseMaxSize/parseMaxTTLhelpers — Removes ~50 lines of duplicated parsing logic betweencreateUserandupdateUsercmd.Flags().Changed()consistently —updateUsernow checks all fields (includingname/email) viaChanged()instead of mixing empty-string checksclean— Prints start/completion messagesDocumentation
Examplefields — All subcommands now have cobraExamplefor--helpoutputimport/exportUsestrings now show[input-file]/[output-file]--configflag help text now documents the full search orderTesting
make lint✅make client server✅make test✅ (full test suite, exit 0)