Skip to content

Commit 5f0808f

Browse files
authored
Validate that deny-packages purls are complete
1 parent fcc66c2 commit 5f0808f

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

__tests__/config.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ test('it raises an error when an invalid package-url is used for deny-packages',
6060
await expect(readConfig()).rejects.toThrow(`Error parsing package-url`)
6161
})
6262

63+
test('it raises an error when a nameless package-url is used for deny-packages', async () => {
64+
setInput('deny-packages', 'pkg:npm/@namespace/')
65+
66+
await expect(readConfig()).rejects.toThrow(
67+
`Error parsing package-url: name is required`
68+
)
69+
})
70+
6371
test('it raises an error when an argument to deny-groups is missing a namespace', async () => {
6472
setInput('deny-groups', 'pkg:npm/my-fun-org')
6573

dist/index.js

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

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/schemas.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ const PackageURL = z
1818
message: `Error parsing package-url: ${purl.error}`
1919
})
2020
}
21+
if (!purl.name) {
22+
context.addIssue({
23+
code: z.ZodIssueCode.custom,
24+
message: `Error parsing package-url: name is required`
25+
})
26+
}
2127
})
2228

2329
const PackageURLWithNamespace = z

0 commit comments

Comments
 (0)