Skip to content

Commit f6f6816

Browse files
committed
merge with v1.x
2 parents 096e520 + cdd5971 commit f6f6816

File tree

5 files changed

+36
-37
lines changed

5 files changed

+36
-37
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ 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-01
7+
## [1.1.41](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.40) - 2025-12-02
88

99
### Added
1010
- Added `--reach-version` flag to `socket scan create` and `socket scan reach` to override the @coana-tech/cli version used for reachability analysis.
1111
- Added `--fix-version` flag to `socket fix` to override the @coana-tech/cli version used for fix analysis.
1212

13+
## [1.1.40](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.40) - 2025-12-02
14+
15+
### Fixed
16+
- Fix a bug where vulnerabilities were not found correctly during `socket fix`.
17+
18+
### Changed
19+
- Updated the Coana CLI to v `14.12.110`.
20+
1321
## [1.1.39](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.39) - 2025-12-01
1422

1523
### 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.40",
3+
"version": "1.1.41",
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: 16 additions & 25 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 {
@@ -57,6 +56,7 @@ type DiscoverGhsaIdsOptions = {
5756
cwd?: string | undefined
5857
limit?: number | undefined
5958
spinner?: Spinner | undefined
59+
coanaVersion?: string | undefined
6060
}
6161

6262
/**
@@ -66,7 +66,6 @@ type DiscoverGhsaIdsOptions = {
6666
async function discoverGhsaIds(
6767
orgSlug: string,
6868
tarHash: string,
69-
fixConfig: FixConfig,
7069
options?: DiscoverGhsaIdsOptions | undefined,
7170
): Promise<string[]> {
7271
const {
@@ -79,31 +78,21 @@ async function discoverGhsaIds(
7978
} as DiscoverGhsaIdsOptions
8079

8180
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-
],
81+
['find-vulnerabilities', cwd, '--manifests-tar-hash', tarHash],
9982
orgSlug,
100-
{ coanaVersion: fixConfig.coanaVersion, cwd, spinner },
83+
{ cwd, spinner, coanaVersion: options?.coanaVersion },
84+
{ stdio: 'pipe' },
10185
)
10286

10387
if (foundCResult.ok) {
104-
const foundIds = cmdFlagValueToArray(
105-
/(?<=Vulnerabilities found:).*/.exec(foundCResult.data),
106-
)
88+
// Coana prints ghsaIds as json-formatted string on the final line of the output
89+
const foundIds: string[] = []
90+
try {
91+
const ghsaIdsRaw = foundCResult.data.trim().split('\n').pop()
92+
if (ghsaIdsRaw) {
93+
foundIds.push(...JSON.parse(ghsaIdsRaw))
94+
}
95+
} catch {}
10796
return limit !== undefined ? foundIds.slice(0, limit) : foundIds
10897
}
10998
return []
@@ -207,10 +196,11 @@ export async function coanaFix(
207196

208197
let ids: string[]
209198
if (isAll && limit > 0) {
210-
ids = await discoverGhsaIds(orgSlug, tarHash, fixConfig, {
199+
ids = await discoverGhsaIds(orgSlug, tarHash, {
211200
cwd,
212201
limit,
213202
spinner,
203+
coanaVersion,
214204
})
215205
} else if (limit > 0) {
216206
ids = ghsas.slice(0, limit)
@@ -313,10 +303,11 @@ export async function coanaFix(
313303
let ids: string[] | undefined
314304

315305
if (shouldSpawnCoana && isAll) {
316-
ids = await discoverGhsaIds(orgSlug, tarHash, fixConfig, {
306+
ids = await discoverGhsaIds(orgSlug, tarHash, {
317307
cwd,
318308
limit: adjustedLimit,
319309
spinner,
310+
coanaVersion,
320311
})
321312
} else if (shouldSpawnCoana) {
322313
ids = ghsas.slice(0, adjustedLimit)

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),
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),
331331
})
332332

333333
mockSpawnCoanaDlx.mockResolvedValue({

0 commit comments

Comments
 (0)