Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| ------------------- | ------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/threat-feed.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/tool-threat-feed.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
),
},
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/repo/integration/server-schema.golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down
3 changes: 2 additions & 1 deletion test/repo/unit/threat-feed.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions test/repo/unit/tool-threat-feed.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand All @@ -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',
})
})

Expand All @@ -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.
Expand Down
Loading