Skip to content

Commit 8eb088c

Browse files
committed
fix(audits): catch coercions under fallbacks in tools.config.tool, and clarify declared timeout params
1 parent b724ead commit 8eb088c

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎.agents/skills/add-tools/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fallback, or caller-controlled `_context` authority.
190190

191191
A required `'hidden'` param needs an `oauth` declaration or `hosting.apiKeyParam` to supply it (`bun run check:tool-param-reachability`).
192192

193-
A declared `timeout` param goes to the provider as-is; it becomes Sim's millisecond request deadline only when the tool sets `timeoutParamIsDeadline: true` (`http_request`). A `method` param on a tool with a fixed `request.method` would be sent as the HTTP verb, so the same audit rejects it.
193+
A declared `timeout` param is an ordinary tool input — put it in the request body or URL yourself if the provider expects it; it becomes Sim's millisecond request deadline only when the tool sets `timeoutParamIsDeadline: true` (`http_request`). A `method` param on a tool with a fixed `request.method` would be sent as the HTTP verb, so the same audit rejects it.
194194

195195
### Parameter Types
196196
- `'string'` - Text values

‎apps/sim/scripts/check-block-registry.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,15 @@ const COERCION_CALLEES = new Set([
256256
'parseInt',
257257
])
258258

259-
function isCoercion(expression: ts.Expression): boolean {
260-
let inner = expression
261-
while (ts.isParenthesizedExpression(inner) || ts.isAsExpression(inner)) inner = inner.expression
262-
if (ts.isPrefixUnaryExpression(inner)) return inner.operator === ts.SyntaxKind.PlusToken
263-
return ts.isCallExpression(inner) && COERCION_CALLEES.has(inner.expression.getText())
259+
/** Whether `expression` coerces anywhere in it, including under `??`, `||`, or a conditional. */
260+
function isCoercion(expression: ts.Node): boolean {
261+
if (ts.isPrefixUnaryExpression(expression) && expression.operator === ts.SyntaxKind.PlusToken) {
262+
return true
263+
}
264+
if (ts.isCallExpression(expression) && COERCION_CALLEES.has(expression.expression.getText())) {
265+
return true
266+
}
267+
return ts.forEachChild(expression, (child) => (isCoercion(child) ? true : undefined)) ?? false
264268
}
265269

266270
function findSelectorCoercions(file: string, source: ts.SourceFile): string[] {

0 commit comments

Comments
 (0)