Prevent disabling all checks

Prevent users from disabling both the license and vulnerability check by
checking if both are set to `false` and throwing if that's the case.
This commit is contained in:
Eric Cornelissen
2022-10-28 22:08:55 +02:00
parent 31279d265a
commit c5af7ff272
2 changed files with 11 additions and 0 deletions

View File

@@ -215,6 +215,14 @@ test('it parses the vulnerability-check input', async () => {
expect(options.vulnerability_check).toEqual(true)
})
test('it is not impossible to disable both checks', async () => {
setInput('license-check', 'false')
setInput('vulnerability-check', 'false')
expect(() => {
readConfig()
}).toThrow("Can't disable both license-check and vulnerability-check")
})
describe('licenses that are not valid SPDX licenses', () => {
beforeAll(() => {
jest.spyOn(Utils, 'isSPDXValid').mockReturnValue(false)

View File

@@ -90,6 +90,9 @@ export function readInlineConfig(): ConfigurationOptions {
.boolean()
.default(true)
.parse(getOptionalBoolean('vulnerability-check'))
if (license_check === false && vulnerability_check === false) {
throw new Error("Can't disable both license-check and vulnerability-check")
}
const base_ref = getOptionalInput('base-ref')
const head_ref = getOptionalInput('head-ref')