fix(targets): sanitize artifact path stems to prevent outDir traversal (#548 #550 #552)#554
Conversation
- chat-telegram: safeFileStem(botUsername) prevents path traversal in
telegram-{username}.json artifact path (fixes profullstack#552)
- mobile-android: safeFileStem(packageName) prevents traversal in
{packageName}-{version}.aab artifact path (fixes profullstack#550)
- browser-edge: safeFileStem(productId) prevents traversal in
packageArtifact() zip path (fixes profullstack#548)
All three adopt the same safeFileStem helper used by browser-firefox:
replace non-alphanumeric characters (except . _ -) with hyphens.
The original values are preserved for API calls, logs, and store URLs.
Greptile SummaryThis PR sanitizes user-controlled config values interpolated into artifact file paths across three target adapters (
Confidence Score: 1/5Not safe to merge: three of the six changed files will not compile, breaking every build that uses pkg-flatpak, pkg-snap, or pkg-winget. The changes to pkg-flatpak, pkg-snap, and pkg-winget each removed a function declaration while leaving the function body at module scope. Those orphaned blocks reference variables that have no binding outside a function, so the TypeScript compiler rejects all three files with 'Cannot find name' and unexpected-token errors. No build using any of those three targets can succeed until the orphaned code is removed. The three adapter fixes (browser-edge, chat-telegram, mobile-android) are clean and would be safe on their own. packages/targets/pkg-winget/src/index.ts, packages/targets/pkg-flatpak/src/index.ts, and packages/targets/pkg-snap/src/index.ts all have orphaned code at module scope that prevents compilation. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Config value\ne.g. productId / botUsername / packageName] --> B{safeFileStem applied?}
B -- "Yes (browser-edge,\nchat-telegram,\nmobile-android)" --> C[Strip non-alphanumeric chars\nreplace with '-']
C --> D[Trim leading/trailing hyphens]
D --> E[Fallback to default stem\nif result is empty]
E --> F[Safe artifact path via path.join]
B -- "No — compile error\n(pkg-flatpak, pkg-snap,\npkg-winget)" --> G[Orphaned validator body\nat module scope]
G --> H[TypeScript: Cannot find name\nUnexpected token]
H --> I[Build fails — target unusable]
|
- browser-edge: fix 'nfunction' typo from sed insertion (was missing newline) - pkg-flatpak: remove duplicate validateAppId function (from merged PR profullstack#535) - pkg-snap: remove duplicate validateSnapName function (from merged PR profullstack#535)
Same fixes as applied to PR profullstack#554 branch: - browser-edge: fix 'nfunction' -> proper newline + function - pkg-flatpak: remove duplicate validateAppId - pkg-snap: remove duplicate validateSnapName
Summary
Fixes path traversal vulnerability in three target adapters where unsanitized config values were interpolated directly into artifact file paths.
Changes
chat-telegrambotUsernamesafeFileStem(botUsername)in artifact pathmobile-androidpackageNamesafeFileStem(packageName)in artifact pathbrowser-edgeproductIdsafeFileStem(productId)in packageArtifact()Each adapter uses the same
safeFileStempattern asbrowser-firefox— strip non-alphanumeric chars for the filename while preserving original values for API/log use.Closes #548, #550, #552