Open
Conversation
Session files and config.json stored under ~/.martmart-cli/ contain bearer tokens, refresh tokens, and cookies that effectively grant API access. Ensure they are never world- or group-readable: - Call os.Chmod(path, 0600) after os.WriteFile in config.Save and session.SaveProvider, since os.WriteFile only honours the mode argument when it creates a new file — pre-existing files keep their old mode and need an explicit chmod to be narrowed. - Add TestSave_EnforcesFileMode0600 and TestSaveProvider_EnforcesFileMode0600 covering the fresh-write and overwrite paths for both Frisco and Delio session files plus the shared config file. - Document the 0600 guarantee in SECURITY.md.
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.
Summary
~/.martmart-cli/(session tokens +config.json) hold secrets; ensure they are written with0600mode on every save.os.WriteFilehonours the mode argument only when it creates a new file, so a follow-upos.Chmod(path, 0o600)is added inconfig.Saveandsession.SaveProviderto narrow permissions on pre-existing files that may have been left world-readable by older builds.SECURITY.md.Test plan
go vet ./...go test ./... -racego build -o bin/martmart ./cmd/martmartthen./bin/martmart --helpand./bin/martmart config showHOME=$(mktemp -d) ./bin/martmart config set --rate-limit-rps 2, thenstatconfirms-rw-------; repeating with achmod 0644between saves confirms permissions are narrowed back to-rw-------.