Skip to content

Follow-ups to #13: DRY up log hashing + salt is empty when analytics disabled #18

Description

@aaronbrethorst

Tracking minor follow-ups from the review of #13 (hash phone numbers in logs). The PR is correct and merged as-is; these are polish items.

1. Extract a hashPhone helper to DRY the ~24 call sites

analytics.HashPhoneNumber(x, h.analyticsHashSalt) is repeated ~24 times across handlers/sms.go and the three voice handlers. A small unexported helper per package would centralize the hashing choice, shorten the log lines (a couple were forced to wrap), and let us drop the new oba-twilio/analytics import from find_stop.go, menu_action.go, and start.go (only handler.go would need it):

// handlers/sms.go
func (h *SMSHandler) hashPhone(p string) string { return analytics.HashPhoneNumber(p, h.analyticsHashSalt) }
// handlers/voice/handler.go
func (h *Handler) hashPhone(p string) string { return analytics.HashPhoneNumber(p, h.analyticsHashSalt) }

2. Logged hashes are unsalted when analytics is disabled

ANALYTICS_HASH_SALT is only required when analytics is enabled (analytics/config_loader.go:20-24), and DefaultConfig leaves HashSalt empty (analytics/config.go:54). In the default deployment (analytics disabled) every HashPhoneNumber(phone, "") is an unsalted SHA256 of a low-entropy phone number — trivially reversible via brute force / rainbow tables. This still satisfies #10 (no plaintext numbers in logs) and matches the pre-existing analytics behavior, but the privacy benefit is weak without a salt. Consider requiring/deriving a stable salt independent of whether analytics is enabled.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions