From 7dbef8dcccd73213f1be00d8721b59b39b82035f Mon Sep 17 00:00:00 2001 From: Gerardo Sabetta Date: Fri, 4 Dec 2026 13:48:47 -0300 Subject: [PATCH] fix(threat_feed): use startAfterCursor instead of deprecated page_cursor (SURF-2363) The threat-feed spec marks page_cursor and nextPageCursor as deprecated aliases of startAfterCursor and endCursor. Send startAfterCursor and document endCursor as the next-page cursor, matching the alerts tool. --- docs/service.md | 4 ++-- lib/threat-feed.mts | 4 ++-- lib/tool-threat-feed.mts | 4 ++-- test/repo/integration/server-schema.golden.json | 2 +- test/repo/unit/threat-feed.test.mts | 3 ++- test/repo/unit/tool-threat-feed.test.mts | 8 ++++---- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/service.md b/docs/service.md index b94412af..1ed96a97 100644 --- a/docs/service.md +++ b/docs/service.md @@ -101,7 +101,7 @@ List the latest security alerts for one Socket organization: supply-chain, vulne ### threat_feed -Look up items in a Socket organization's threat feed: packages recently flagged as malware, typosquats, obfuscated code, and similar. Backed by `GET /v0/orgs/{org_slug}/threat-feed`. The response carries a `nextPageCursor`; pass it as `cursor` to page forward. +Look up items in a Socket organization's threat feed: packages recently flagged as malware, typosquats, obfuscated code, and similar. Backed by `GET /v0/orgs/{org_slug}/threat-feed`. The response carries an `endCursor`; pass it as `cursor` to page forward. | Parameter | Type | Required | Default | Description | | ------------------- | ------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------ | @@ -116,7 +116,7 @@ Look up items in a Socket organization's threat feed: packages recently flagged | `updated_after` | String | No | - | ISO timestamp; only items updated after this | | `created_after` | String | No | - | ISO timestamp; only items created after this | | `per_page` | Integer | No | `30` | Results per page (1–100) | -| `cursor` | String | No | - | Pagination cursor - the `nextPageCursor` from a previous response | +| `cursor` | String | No | - | Pagination cursor - the `endCursor` from a previous response | ### package_files diff --git a/lib/threat-feed.mts b/lib/threat-feed.mts index 4dec2104..594168e8 100644 --- a/lib/threat-feed.mts +++ b/lib/threat-feed.mts @@ -6,7 +6,7 @@ import { UpstreamHttpError } from './tool-outcome.mts' export interface ThreatFeedFilters { // 1..100. API caps at 100 and defaults to 30. perPage?: number | undefined - // Pagination cursor from a previous response. + // Pagination cursor from a previous response's endCursor. cursor?: string | undefined // Sort field: id | created_at | updated_at (default updated_at). sort?: 'id' | 'created_at' | 'updated_at' | undefined @@ -56,7 +56,7 @@ export function buildThreatFeedQuery( params.set('per_page', String(f.perPage)) } if (f.cursor) { - params.set('page_cursor', f.cursor) + params.set('startAfterCursor', f.cursor) } if (f.sort) { params.set('sort', f.sort) diff --git a/lib/tool-threat-feed.mts b/lib/tool-threat-feed.mts index 2ac5bd3b..0d12e422 100644 --- a/lib/tool-threat-feed.mts +++ b/lib/tool-threat-feed.mts @@ -90,7 +90,7 @@ const threatFeedSchema = defineToolSchema( cursor: Type.Optional( Type.String({ description: - 'Pagination cursor — the `nextPageCursor` from a previous response', + 'Pagination cursor — the `endCursor` from a previous response', }), ), }, @@ -103,7 +103,7 @@ export function defineThreatFeedTool(): ValidatedToolSpec { name: 'threat_feed', title: 'Threat Feed Tool', description: - "Look up items in the Socket organization threat feed with the `threat_feed` tool. Requires `org_slug` — call the `organizations` tool first if you don't have it. Returns recently flagged packages (malware, typosquats, obfuscated code, etc.) along with a `nextPageCursor` for pagination. Use `filter` to narrow the threat category (default `mal` for malware), `ecosystem` to scope to a registry, or `name`/`version` to look up a specific package. Pass the previous response's cursor as `cursor` to fetch the next page.", + "Look up items in the Socket organization threat feed with the `threat_feed` tool. Requires `org_slug` — call the `organizations` tool first if you don't have it. Returns recently flagged packages (malware, typosquats, obfuscated code, etc.) along with an `endCursor` for pagination. Use `filter` to narrow the threat category (default `mal` for malware), `ecosystem` to scope to a registry, or `name`/`version` to look up a specific package. Pass the previous response's `endCursor` as `cursor` to fetch the next page.", ...threatFeedSchema, annotations: { readOnlyHint: true, diff --git a/test/repo/integration/server-schema.golden.json b/test/repo/integration/server-schema.golden.json index 97152d69..eb13888e 100644 --- a/test/repo/integration/server-schema.golden.json +++ b/test/repo/integration/server-schema.golden.json @@ -292,7 +292,7 @@ "type": "integer" }, "cursor": { - "description": "Pagination cursor — the `nextPageCursor` from a previous response", + "description": "Pagination cursor — the `endCursor` from a previous response", "type": "string" } }, diff --git a/test/repo/unit/threat-feed.test.mts b/test/repo/unit/threat-feed.test.mts index ed9509c1..e127d551 100644 --- a/test/repo/unit/threat-feed.test.mts +++ b/test/repo/unit/threat-feed.test.mts @@ -33,7 +33,8 @@ describe('buildThreatFeedQuery', () => { ecosystem: 'npm', }) expect(qs.get('per_page')).toBe('30') - expect(qs.get('page_cursor')).toBe('c1') + expect(qs.get('startAfterCursor')).toBe('c1') + expect(qs.has('page_cursor')).toBe(false) expect(qs.get('sort')).toBe('created_at') expect(qs.get('direction')).toBe('asc') expect(qs.get('updated_after')).toBe('2026-01-01T00:00:00Z') diff --git a/test/repo/unit/tool-threat-feed.test.mts b/test/repo/unit/tool-threat-feed.test.mts index 79190149..d910e19d 100644 --- a/test/repo/unit/tool-threat-feed.test.mts +++ b/test/repo/unit/tool-threat-feed.test.mts @@ -23,7 +23,7 @@ describe('threat_feed tool handler', () => { .matchHeader('authorization', 'Bearer tok') .get('/v0/orgs/my-org/threat-feed') .query({ filter: 'mal', ecosystem: 'npm' }) - .reply(200, { results: [{ id: 'a' }], nextPageCursor: 'c2' }) + .reply(200, { results: [{ id: 'a' }], endCursor: 'c2' }) const result = await defineThreatFeedTool().handler( { org_slug: 'my-org', filter: 'mal', ecosystem: 'npm' }, @@ -32,7 +32,7 @@ describe('threat_feed tool handler', () => { expect(result.isError).toBeUndefined() expect(JSON.parse(result.content[0]!.text)).toEqual({ results: [{ id: 'a' }], - nextPageCursor: 'c2', + endCursor: 'c2', }) }) @@ -46,13 +46,13 @@ describe('threat_feed tool handler', () => { filter: 'typ', is_human_reviewed: 'true', name: 'reqeusts', - page_cursor: 'cursor-2', + startAfterCursor: 'cursor-2', per_page: '50', sort: 'created_at', updated_after: '2026-01-01T00:00:00Z', version: '1.0.0', }) - .reply(200, { results: [], nextPageCursor: undefined }) + .reply(200, { results: [], endCursor: undefined }) // The interceptor's query matcher is the assertion: it only matches when // every snake_case tool argument reaches its curated query parameter.