fix chat telegram artifact filename sanitization#558
Conversation
Greptile SummaryThis PR fixes a path-traversal risk in the Telegram adapter's
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to the artifact path construction in build(), the fix is correct, and the new test directly covers the path-traversal case. The sanitization logic is straightforward: normalizeUsername strips the @ prefix, safeFilename converts every non-alphanumeric character to _, and path.join assembles the final path. All three steps are necessary and work correctly together. The test input (../demo/bot → telegram-___demo_bot.json) exercises the primary concern and the expectation is verified end-to-end. No other code paths are affected by this change. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[build called with config.botUsername] --> B[normalizeUsername\nstrip leading '@', trim whitespace]
B --> C{empty after normalization?}
C -- yes --> D[throw 'botUsername is required']
C -- no --> E[safeFilename\nreplace non-alphanumeric with '_']
E --> F[path.join outDir, 'telegram-' + safeUsername + '.json']
F --> G[return artifact path]
Reviews (1): Last reviewed commit: "fix chat telegram artifact filename sani..." | Re-trigger Greptile |
Fixes #552.
Summary
ctx.outDirt.meURLs../demo/botusernameTests