Skip to content

Commit 32c7e12

Browse files
committed
fix: harden push payload path handling in session
1 parent 25fb4d9 commit 32c7e12

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/daemon/handlers/session.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,22 @@ export async function handleSessionCommands(params: {
874874
function maybeResolvePushPayloadPath(payloadArg: string, cwd?: string): string {
875875
const trimmed = payloadArg.trim();
876876
const resolvedPath = SessionStore.expandHome(trimmed, cwd);
877-
if (fs.existsSync(resolvedPath)) {
877+
try {
878878
const stat = fs.statSync(resolvedPath);
879879
if (!stat.isFile()) {
880880
throw new AppError('INVALID_ARGS', `Push payload path is not a file: ${resolvedPath}`);
881881
}
882882
return resolvedPath;
883+
} catch (error) {
884+
const code = (error as NodeJS.ErrnoException).code;
885+
if (code === 'EACCES' || code === 'EPERM') {
886+
throw new AppError('INVALID_ARGS', `Push payload file is not readable: ${resolvedPath}`);
887+
}
888+
if (code && code !== 'ENOENT') {
889+
throw new AppError('COMMAND_FAILED', `Unable to read push payload file: ${resolvedPath}`, {
890+
cause: String(error),
891+
});
892+
}
883893
}
884894
if (looksLikeInlineJson(trimmed)) {
885895
return trimmed;

website/docs/docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ agent-device push com.example.app '{"action":"com.example.app.PUSH","extras":{"t
128128
```
129129

130130
- `push <bundle|package> <payload.json|inline-json>` simulates push notification delivery.
131-
- iOS uses `xcrun simctl push` and requires an APNs-style JSON object payload.
131+
- iOS push simulation is simulator-only (`xcrun simctl push`) and requires an APNs-style JSON object payload.
132132
- Android uses `adb shell am broadcast` and accepts payload shape:
133133
`{"action":"<intent-action>","receiver":"<optional component>","extras":{"key":"value","flag":true,"count":3}}`.
134134
- Android extras support `string`, `boolean`, and `number` values.

0 commit comments

Comments
 (0)