Sanitize Telegram artifact filenames#553
Conversation
Greptile SummaryThis PR fixes a path-traversal vulnerability in the Telegram target where a bot username containing
Confidence Score: 4/5Safe to merge; the core path-traversal fix is correct and well-tested. The only rough edge is cosmetic. The packages/targets/pkg-snap/src/index.ts — the redundant second Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build called with botUsername] --> B{safeFileStem}
B --> C["replace non-[a-zA-Z0-9._-] with '-'"]
C --> D["strip leading/trailing dots"]
D --> E["strip leading/trailing hyphens"]
E --> F{result empty?}
F -- yes --> G["fallback: 'telegram-bot'"]
F -- no --> H[safe stem]
G --> I["join(ctx.outDir, 'telegram-' + stem + '.json')"]
H --> I
I --> J[artifact path stays inside outDir]
Reviews (1): Last reviewed commit: "Sanitize Telegram artifact filenames" | Re-trigger Greptile |
| } | ||
|
|
||
| function renderSnapcraftYaml(ctx: { projectDir: string; version: string; channel: string }, config: Config): string { | ||
| validateSnapName(config.snapName); |
There was a problem hiding this comment.
Double validation in
build() path
validateSnapName is called inside renderSnapcraftYaml (line 63) AND again explicitly at the start of build() (line 114) before the same renderSnapcraftYaml is invoked. When build() runs, validation fires twice. The explicit guard at line 114 is the one that matters for the "no filesystem side-effects on bad input" guarantee — the call inside renderSnapcraftYaml is redundant and should be removed from there (keeping only the call sites in build and ship directly).
Summary
ctx.outDirFixes #552.
Verification