Skip to content

Commit 7dcf13e

Browse files
committed
catch errors when parsing output of coana cmd 'find-vulnerabilities'
1 parent e74ab7a commit 7dcf13e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/commands/fix/coana-fix.mts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,13 @@ async function discoverGhsaIds(
8585

8686
if (foundCResult.ok) {
8787
// Coana prints ghsaIds as json-formatted string on the final line of the output
88-
const foundIds = JSON.parse(
89-
foundCResult.data.trim().split('\n').pop() || '[]',
90-
)
88+
const foundIds: string[] = []
89+
try {
90+
const ghsaIdsRaw = foundCResult.data.trim().split('\n').pop()
91+
if (ghsaIdsRaw) {
92+
foundIds.push(...JSON.parse(ghsaIdsRaw))
93+
}
94+
} catch {}
9195
return limit !== undefined ? foundIds.slice(0, limit) : foundIds
9296
}
9397
return []

0 commit comments

Comments
 (0)