sanitizeForPublic rewrites $USER as a word, corrupting the package name #46
Labels
No labels
area/dsh
area/forgejo
experiment
priority/later
priority/next
priority/now
type/bug
type/task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
dsh-plugins/dsh-gitea#46
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
sanitizeForPublic()inlib/mirror-public.jsscrubsprocess.env.USER/USERNAMEas bare-word replacements:On this host
USER=dsh, so every occurrence of the package/plugin namedsh-giteais rewritten touser-giteain mirrored content. On a host where the login equals a common word, the same happens to unrelated text.Impact
gitea_mirror_publicand the newscripts/mirror-public.mjsare meant to produce a sanitized publish tree. WithUSER=dsh, the snapshot's README, package name references and docs are silently mangled while the report still says "sanitized" — a silent data-corruption path in a publishing tool.Workaround
scripts/mirror-public.mjsclearsUSER/USERNAMEaround thesanitizeForPublic()call, so its output is correct. Direct callers (gitea_mirror_public) still hit the bug.Expected
Only scrub the environment user when it is not a substring of the package identity, or drop the env-based scrub entirely and take explicit
username/usernamesoptions (the generic/home/<user>/rewrite already covers paths). Add a regression test withUSER=dshassertingdsh-giteasurvives.Acceptance
sanitizeForPublic('dsh-gitea', {})returnsdsh-giteawithUSER=dsh.username: 'dsh'still scrubs that name.npm testgreen.