Skip to content

Commit ad86f79

Browse files
authored
Fix namedspaced purl parsing for package commands (#426)
1 parent a52ef66 commit ad86f79

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

src/commands/package/fetch-purl-deep-score.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { getDefaultToken } from '../../utils/sdk'
99
const { SOCKET_CLI_ISSUES_URL } = constants
1010

1111
export async function fetchPurlDeepScore(purl: string) {
12+
logger.info(`Requesting deep score data for this purl: ${purl}`)
13+
1214
const apiToken = getDefaultToken()
1315
if (!apiToken) {
1416
throw new AuthError(

src/commands/package/fetch-purls-shallow-score.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
export async function fetchPurlsShallowScore(
1313
purls: string[]
1414
): Promise<SocketSdkReturnType<'batchPackageFetch'> | undefined> {
15-
logger.error(
15+
logger.info(
1616
`Requesting shallow score data for ${purls.length} package urls (purl): ${purls.join(', ')}`
1717
)
1818

src/commands/package/parse-package-specifiers.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ describe('parse-package-specifiers', async () => {
2121
`)
2222
})
2323

24+
it('should support npm scoped packages', () => {
25+
expect(
26+
parsePackageSpecifiers('npm', ['@babel/core'])
27+
).toMatchInlineSnapshot(`
28+
{
29+
"purls": [
30+
"pkg:npm/@babel/core",
31+
],
32+
"valid": true,
33+
}
34+
`)
35+
})
36+
2437
it('should parse a simple purl without prefix', () => {
2538
expect(parsePackageSpecifiers('npm/babel', [])).toMatchInlineSnapshot(`
2639
{
@@ -52,7 +65,7 @@ describe('parse-package-specifiers', async () => {
5265
).toMatchInlineSnapshot(`
5366
{
5467
"purls": [
55-
"pkg:golang/foo",
68+
"pkg:npm/golang/foo",
5669
"pkg:npm/babel",
5770
"pkg:npm/tenko",
5871
],

src/commands/package/parse-package-specifiers.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ export function parsePackageSpecifiers(
1919
} else if (pkg.startsWith('pkg:')) {
2020
// keep
2121
purls.push(pkg)
22-
} else if (pkg.includes('/')) {
23-
// Looks like this arg was already namespaced
24-
purls.push('pkg:' + pkg)
2522
} else {
2623
purls.push('pkg:' + ecosystem + '/' + pkg)
2724
}

0 commit comments

Comments
 (0)