Skip to content

Commit c682f75

Browse files
committed
change discoverGhsaIds to use coana cli command 'find-vulnerabilities'
bump coana version
1 parent 71aa15b commit c682f75

File tree

5 files changed

+25
-35
lines changed

5 files changed

+25
-35
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [1.1.40](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.40) - 2025-12-02
8+
9+
### Fixed
10+
- Fix a bug where vulnerabilities were not found correctly during `socket fix`.
11+
12+
### Changed
13+
- Updated the Coana CLI to v `14.12.110`.
14+
715
## [1.1.39](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.39) - 2025-12-01
816

917
### Added

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socket",
3-
"version": "1.1.39",
3+
"version": "1.1.40",
44
"description": "CLI for Socket.dev",
55
"homepage": "https://github.com/SocketDev/socket-cli",
66
"license": "MIT AND OFL-1.1",
@@ -94,7 +94,7 @@
9494
"@babel/preset-typescript": "7.27.1",
9595
"@babel/runtime": "7.28.4",
9696
"@biomejs/biome": "2.2.4",
97-
"@coana-tech/cli": "14.12.107",
97+
"@coana-tech/cli": "14.12.110",
9898
"@cyclonedx/cdxgen": "11.11.0",
9999
"@dotenvx/dotenvx": "1.49.0",
100100
"@eslint/compat": "1.3.2",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/fix/coana-fix.mts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
GQL_PR_STATE_OPEN,
2828
} from '../../constants.mts'
2929
import { handleApiCall } from '../../utils/api.mts'
30-
import { cmdFlagValueToArray } from '../../utils/cmd.mts'
3130
import { spawnCoanaDlx } from '../../utils/dlx.mts'
3231
import { getErrorCause } from '../../utils/errors.mts'
3332
import {
@@ -66,7 +65,6 @@ type DiscoverGhsaIdsOptions = {
6665
async function discoverGhsaIds(
6766
orgSlug: string,
6867
tarHash: string,
69-
fixConfig: FixConfig,
7068
options?: DiscoverGhsaIdsOptions | undefined,
7169
): Promise<string[]> {
7270
const {
@@ -79,31 +77,15 @@ async function discoverGhsaIds(
7977
} as DiscoverGhsaIdsOptions
8078

8179
const foundCResult = await spawnCoanaDlx(
82-
[
83-
'compute-fixes-and-upgrade-purls',
84-
cwd,
85-
'--manifests-tar-hash',
86-
tarHash,
87-
...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []),
88-
...(fixConfig.minimumReleaseAge
89-
? ['--minimum-release-age', fixConfig.minimumReleaseAge]
90-
: []),
91-
...(fixConfig.include.length ? ['--include', ...fixConfig.include] : []),
92-
...(fixConfig.exclude.length ? ['--exclude', ...fixConfig.exclude] : []),
93-
...(fixConfig.disableMajorUpdates ? ['--disable-major-updates'] : []),
94-
...(fixConfig.showAffectedDirectDependencies
95-
? ['--show-affected-direct-dependencies']
96-
: []),
97-
...fixConfig.unknownFlags,
98-
],
80+
['find-vulnerabilities', cwd, '--manifests-tar-hash', tarHash],
9981
orgSlug,
10082
{ cwd, spinner },
83+
{ stdio: 'pipe' },
10184
)
10285

10386
if (foundCResult.ok) {
104-
const foundIds = cmdFlagValueToArray(
105-
/(?<=Vulnerabilities found:).*/.exec(foundCResult.data),
106-
)
87+
// Coana prints ghsaIds as json-formatted string on the final line of the output
88+
const foundIds = JSON.parse(foundCResult.data.split('\n').pop() || '[]')
10789
return limit !== undefined ? foundIds.slice(0, limit) : foundIds
10890
}
10991
return []
@@ -206,7 +188,7 @@ export async function coanaFix(
206188

207189
let ids: string[]
208190
if (isAll && limit > 0) {
209-
ids = await discoverGhsaIds(orgSlug, tarHash, fixConfig, {
191+
ids = await discoverGhsaIds(orgSlug, tarHash, {
210192
cwd,
211193
limit,
212194
spinner,
@@ -312,7 +294,7 @@ export async function coanaFix(
312294
let ids: string[] | undefined
313295

314296
if (shouldSpawnCoana && isAll) {
315-
ids = await discoverGhsaIds(orgSlug, tarHash, fixConfig, {
297+
ids = await discoverGhsaIds(orgSlug, tarHash, {
316298
cwd,
317299
limit: adjustedLimit,
318300
spinner,

src/commands/fix/handle-fix-limit.test.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ describe('socket fix --limit behavior verification', () => {
223223
// First call is for discovery (returns vulnerability IDs).
224224
mockSpawnCoanaDlx.mockResolvedValueOnce({
225225
ok: true,
226-
data: 'Vulnerabilities found: GHSA-aaaa-aaaa-aaaa,GHSA-bbbb-bbbb-bbbb',
226+
data: JSON.stringify(['GHSA-aaaa-aaaa-aaaa', 'GHSA-bbbb-bbbb-bbbb']),
227227
})
228228

229229
// Second call is to apply fixes to the discovered IDs.
@@ -245,7 +245,7 @@ describe('socket fix --limit behavior verification', () => {
245245

246246
// First call is discovery (no --apply-fixes-to).
247247
const discoveryArgs = mockSpawnCoanaDlx.mock.calls[0]?.[0] as string[]
248-
expect(discoveryArgs).toContain('compute-fixes-and-upgrade-purls')
248+
expect(discoveryArgs).toContain('find-vulnerabilities')
249249
expect(discoveryArgs).not.toContain('--apply-fixes-to')
250250

251251
// Second call applies fixes to discovered IDs.
@@ -284,7 +284,7 @@ describe('socket fix --limit behavior verification', () => {
284284
// First call returns the IDs to process.
285285
mockSpawnCoanaDlx.mockResolvedValueOnce({
286286
ok: true,
287-
data: `Vulnerabilities found: ${ghsas.join(',')}`,
287+
data: JSON.stringify(ghsas.join(',')),
288288
})
289289

290290
// Subsequent calls are for individual GHSA fixes.
@@ -327,7 +327,7 @@ describe('socket fix --limit behavior verification', () => {
327327

328328
mockSpawnCoanaDlx.mockResolvedValueOnce({
329329
ok: true,
330-
data: `Vulnerabilities found: ${ghsas.join(',')}`,
330+
data: JSON.stringify(ghsas.join(',')),
331331
})
332332

333333
mockSpawnCoanaDlx.mockResolvedValue({

0 commit comments

Comments
 (0)