Skip to content

Commit f5c024c

Browse files
committed
fix(github): await comment operations so path errors return 400
1 parent ac2889f commit f5c024c

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎apps/sim/lib/internal/github/execute-tool.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export const executeGitHubTool: InternalToolOperationHandler = async (request) =
2222
try {
2323
switch (request.toolId) {
2424
case 'github_comment':
25-
return executeToolOperationImplementation(executeGitHubCommentOperation, request)
25+
return await executeToolOperationImplementation(executeGitHubCommentOperation, request)
2626
case 'github_comment_v2':
27-
return executeToolOperationImplementation(executeGitHubCommentV2Operation, request)
27+
return await executeToolOperationImplementation(executeGitHubCommentV2Operation, request)
2828
case 'github_latest_commit':
2929
case 'github_latest_commit_v2': {
3030
const parsed = inputSchema.safeParse(request.input)

‎apps/sim/tools/github/request-paths.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2+
import { executeGitHubTool } from '@/lib/internal/github/execute-tool'
23
import { getGitHubLatestCommit } from '@/lib/internal/github/operations'
34
import { compareCommitsTool } from '@/tools/github/compare_commits'
45
import { deleteBranchTool } from '@/tools/github/delete_branch'
@@ -127,4 +128,20 @@ describe('GitHub request paths', () => {
127128
message: 'owner cannot be ".." (path traversal is not allowed)',
128129
})
129130
})
131+
132+
it('answers a traversal owner in the PR comment operation with a 400', async () => {
133+
const response = await executeGitHubTool({
134+
toolId: 'github_comment',
135+
input: { owner: 'octo', repo: '..', body: 'hi', pullNumber: 1, apiKey: 'ghp_test' },
136+
headers: new Headers(),
137+
context: { workflowId: 'workflow-1' },
138+
requestId: 'test-request',
139+
})
140+
141+
expect(response.status).toBe(400)
142+
expect(await response.json()).toEqual({
143+
success: false,
144+
error: 'repo cannot be ".." (path traversal is not allowed)',
145+
})
146+
})
130147
})

0 commit comments

Comments
 (0)