Skip to content

Commit

Permalink
Validate that deny-packages purls are complete
Browse files Browse the repository at this point in the history
  • Loading branch information
juxtin authored Apr 29, 2024
1 parent fcc66c2 commit 5f0808f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
8 changes: 8 additions & 0 deletions __tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ test('it raises an error when an invalid package-url is used for deny-packages',
await expect(readConfig()).rejects.toThrow(`Error parsing package-url`)
})

test('it raises an error when a nameless package-url is used for deny-packages', async () => {
setInput('deny-packages', 'pkg:npm/@namespace/')

await expect(readConfig()).rejects.toThrow(
`Error parsing package-url: name is required`
)
})

test('it raises an error when an argument to deny-groups is missing a namespace', async () => {
setInput('deny-groups', 'pkg:npm/my-fun-org')

Expand Down
12 changes: 12 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ const PackageURL = z
message: `Error parsing package-url: ${purl.error}`
})
}
if (!purl.name) {
context.addIssue({
code: z.ZodIssueCode.custom,
message: `Error parsing package-url: name is required`
})
}
})

const PackageURLWithNamespace = z
Expand Down

0 comments on commit 5f0808f

Please sign in to comment.