Skip to content

Commit e61c34f

Browse files
committed
feat: harden schema validators
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent aa8ddb1 commit e61c34f

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/_optPlug.node/__jsonValidators/ajv.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ import addFormats2019 from 'ajv-formats-draft2019'
2727
import type { ValidationError } from '../../validation/types'
2828
import type { Functionality, Validator } from '../jsonValidator'
2929

30-
const ajvOptions: AjvOptions = Object.freeze({
30+
const ajvOptions: Readonly<AjvOptions> = Object.freeze({
3131
// no defaults => no data alteration
3232
useDefaults: false,
3333
strict: false,
3434
strictSchema: false,
35-
addUsedSchema: false
36-
})
35+
addUsedSchema: false,
36+
loadSchema: (uri: string) => {
37+
throw new Error(`Remote schemas are disabled: ${uri}`);
38+
}
39+
} satisfies AjvOptions)
3740

3841
/** @internal */
3942
export default (async function (schemaPath: string, schemaMap: Record<string, string> = {}): Promise<Validator> {

src/_optPlug.node/__xmlValidators/libxmljs2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const xmlParseOptions: Readonly<ParserOptions> = Object.freeze({
3434
// see https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1061
3535
noent: false,
3636
dtdload: false
37-
})
37+
} satisfies ParserOptions)
3838

3939
/** @internal */
4040
export default (async function (schemaPath: string): Promise<Validator> {

0 commit comments

Comments
 (0)