background-agents icon indicating copy to clipboard operation
background-agents copied to clipboard

fix(types): validate Linear OAuth token boundaries

Open open-inspect opened this issue 5 months ago • 1 comments

This is an automated nightly unsafe-cast remediation sweep. It replaces selected high-risk TypeScript assertions at Linear OAuth trust boundaries with Zod parsing, following the TypeScript Coding Standards unsafe-cast / parse-don't-assert guidance and the Zod boundary-validation pattern established in PR #807.

Finding Risk Cast Removed Fix
packages/linear-bot/src/utils/linear-client.ts:59 HIGH await tokenRes.json() as OAuthTokenResponse Added package-local oauthTokenResponseSchema and parse helper using safeParse before token use.
packages/linear-bot/src/utils/linear-client.ts:78 HIGH JSON.parse(raw) as StoredTokenData Added package-local storedTokenDataSchema and parse helper; malformed persisted token data preserves existing null path.
packages/linear-bot/src/utils/linear-client.ts:129 HIGH await res.json() as OAuthTokenResponse Reused oauthTokenResponseSchema for refresh responses; malformed refresh data preserves existing caught-error/null path.

Verification:

Command Result
npm install Passed; lockfile diff is limited to @open-inspect/linear-bot gaining existing zod@^4.4.3.
npm run build -w @open-inspect/shared Passed.
npm run build -w @open-inspect/linear-bot Passed.
npm run typecheck Passed.
npm run lint Passed.
npm run format Passed.
npm test -w @open-inspect/linear-bot Passed: 9 files, 117 tests.

open-inspect avatar Jul 02 '26 06:07 open-inspect

Terraform Validation Results

Step Status
Format ✅
Init ✅
Validate ✅

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @open-inspect[bot], Action: pull_request

github-actions[bot] avatar Jul 02 '26 06:07 github-actions[bot]