Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

ajv

Package Overview
Dependencies
5
Maintainers
2
Versions
354
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.5.0 to 8.6.0

15

dist/compile/jtd/parse.js

@@ -247,5 +247,14 @@ "use strict";

default: {
const [min, max, maxDigits] = type_1.intRange[schema.type];
parseNumber(cxt, maxDigits);
gen.if(codegen_1._ `${data} < ${min} || ${data} > ${max}`, () => parsingError(cxt, codegen_1.str `integer out of range`));
const t = schema.type;
if (!self.opts.int32range && (t === "int32" || t === "uint32")) {
parseNumber(cxt, 16); // 2 ** 53 - max safe integer
if (t === "uint32") {
gen.if(codegen_1._ `${data} < 0`, () => parsingError(cxt, codegen_1.str `integer out of range`));
}
}
else {
const [min, max, maxDigits] = type_1.intRange[t];
parseNumber(cxt, maxDigits);
gen.if(codegen_1._ `${data} < ${min} || ${data} > ${max}`, () => parsingError(cxt, codegen_1.str `integer out of range`));
}
}

@@ -252,0 +261,0 @@ }

3

dist/core.d.ts

@@ -68,2 +68,3 @@ export { Format, FormatDefinition, AsyncFormatDefinition, KeywordDefinition, KeywordErrorDefinition, CodeKeywordDefinition, MacroKeywordDefinition, FuncKeywordDefinition, Vocabulary, Schema, SchemaObject, AnySchemaObject, AsyncSchema, AnySchema, ValidateFunction, AsyncValidateFunction, AnyValidateFunction, ErrorObject, ErrorNoParams, } from "./types";

multipleOfPrecision?: number;
int32range?: boolean;
messages?: boolean;

@@ -92,3 +93,3 @@ code?: CodeOptions;

declare type RequiredInstanceOptions = {
[K in "strictSchema" | "strictNumbers" | "strictTypes" | "strictTuples" | "strictRequired" | "inlineRefs" | "loopRequired" | "loopEnum" | "meta" | "messages" | "schemaId" | "addUsedSchema" | "validateSchema" | "validateFormats" | "unicodeRegExp"]: NonNullable<Options[K]>;
[K in "strictSchema" | "strictNumbers" | "strictTypes" | "strictTuples" | "strictRequired" | "inlineRefs" | "loopRequired" | "loopEnum" | "meta" | "messages" | "schemaId" | "addUsedSchema" | "validateSchema" | "validateFormats" | "int32range" | "unicodeRegExp"]: NonNullable<Options[K]>;
} & {

@@ -95,0 +96,0 @@ code: InstanceCodeOptions;

@@ -63,3 +63,3 @@ "use strict";

function requiredOptions(o) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
const s = o.strict;

@@ -85,2 +85,3 @@ const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize;

unicodeRegExp: (_w = o.unicodeRegExp) !== null && _w !== void 0 ? _w : true,
int32range: (_x = o.int32range) !== null && _x !== void 0 ? _x : true,
};

@@ -87,0 +88,0 @@ }

@@ -14,6 +14,9 @@ "use strict";

const { opts } = it;
const patterns = code_1.schemaProperties(it, schema);
// TODO mark properties matching patterns with always valid schemas as evaluated
if (patterns.length === 0)
const patterns = code_1.allSchemaProperties(schema);
const alwaysValidPatterns = patterns.filter((p) => util_1.alwaysValidSchema(it, schema[p]));
if (patterns.length === 0 ||
(alwaysValidPatterns.length === patterns.length &&
(!it.opts.unevaluated || it.props === true))) {
return;
}
const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties;

@@ -50,12 +53,15 @@ const valid = gen.name("valid");

gen.if(codegen_1._ `${code_1.usePattern(cxt, pat)}.test(${key})`, () => {
cxt.subschema({
keyword: "patternProperties",
schemaProp: pat,
dataProp: key,
dataPropType: util_2.Type.Str,
}, valid);
const alwaysValid = alwaysValidPatterns.includes(pat);
if (!alwaysValid) {
cxt.subschema({
keyword: "patternProperties",
schemaProp: pat,
dataProp: key,
dataPropType: util_2.Type.Str,
}, valid);
}
if (it.opts.unevaluated && props !== true) {
gen.assign(codegen_1._ `${props}[${key}]`, true);
}
else if (!it.allErrors) {
else if (!alwaysValid && !it.allErrors) {
// can short-circuit if `unevaluatedProperties` is not supported (opts.next === false)

@@ -62,0 +68,0 @@ // or if all properties were evaluated (props === true)

@@ -37,3 +37,3 @@ "use strict";

metadata_1.checkMetadata(cxt);
const { data, schema, parentSchema } = cxt;
const { data, schema, parentSchema, it } = cxt;
let cond;

@@ -54,4 +54,12 @@ switch (schema) {

default: {
const [min, max] = exports.intRange[schema];
cond = codegen_1._ `typeof ${data} == "number" && isFinite(${data}) && ${data} >= ${min} && ${data} <= ${max} && !(${data} % 1)`;
const sch = schema;
cond = codegen_1._ `typeof ${data} == "number" && isFinite(${data}) && !(${data} % 1)`;
if (!it.opts.int32range && (sch === "int32" || sch === "uint32")) {
if (sch === "uint32")
cond = codegen_1._ `${cond} && ${data} >= 0`;
}
else {
const [min, max] = exports.intRange[sch];
cond = codegen_1._ `${cond} && ${data} >= ${min} && ${data} <= ${max}`;
}
}

@@ -58,0 +66,0 @@ }

@@ -280,7 +280,15 @@ import type Ajv from "../../core"

default: {
const [min, max, maxDigits] = intRange[schema.type as IntType]
parseNumber(cxt, maxDigits)
gen.if(_`${data} < ${min} || ${data} > ${max}`, () =>
parsingError(cxt, str`integer out of range`)
)
const t = schema.type as IntType
if (!self.opts.int32range && (t === "int32" || t === "uint32")) {
parseNumber(cxt, 16) // 2 ** 53 - max safe integer
if (t === "uint32") {
gen.if(_`${data} < 0`, () => parsingError(cxt, str`integer out of range`))
}
} else {
const [min, max, maxDigits] = intRange[t]
parseNumber(cxt, maxDigits)
gen.if(_`${data} < ${min} || ${data} > ${max}`, () =>
parsingError(cxt, str`integer out of range`)
)
}
}

@@ -287,0 +295,0 @@ }

@@ -132,2 +132,3 @@ export {

multipleOfPrecision?: number
int32range?: boolean // JTD only
messages?: boolean

@@ -221,2 +222,3 @@ code?: CodeOptions // NEW

| "validateFormats"
| "int32range"
| "unicodeRegExp"]: NonNullable<Options[K]>

@@ -251,2 +253,3 @@ } & {code: InstanceCodeOptions}

unicodeRegExp: o.unicodeRegExp ?? true,
int32range: o.int32range ?? true,
}

@@ -253,0 +256,0 @@ }

import type {CodeKeywordDefinition} from "../../types"
import type {KeywordCxt} from "../../compile/validate"
import {schemaProperties, usePattern} from "../code"
import {allSchemaProperties, usePattern} from "../code"
import {_, not, Name} from "../../compile/codegen"
import {checkStrictMode} from "../../compile/util"
import {alwaysValidSchema, checkStrictMode} from "../../compile/util"
import {evaluatedPropsToName, Type} from "../../compile/util"
import {AnySchema} from "../../types"

@@ -15,5 +16,15 @@ const def: CodeKeywordDefinition = {

const {opts} = it
const patterns = schemaProperties(it, schema)
// TODO mark properties matching patterns with always valid schemas as evaluated
if (patterns.length === 0) return
const patterns = allSchemaProperties(schema)
const alwaysValidPatterns = patterns.filter((p) =>
alwaysValidSchema(it, schema[p] as AnySchema)
)
if (
patterns.length === 0 ||
(alwaysValidPatterns.length === patterns.length &&
(!it.opts.unevaluated || it.props === true))
) {
return
}
const checkProperties =

@@ -55,14 +66,18 @@ opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties

gen.if(_`${usePattern(cxt, pat)}.test(${key})`, () => {
cxt.subschema(
{
keyword: "patternProperties",
schemaProp: pat,
dataProp: key,
dataPropType: Type.Str,
},
valid
)
const alwaysValid = alwaysValidPatterns.includes(pat)
if (!alwaysValid) {
cxt.subschema(
{
keyword: "patternProperties",
schemaProp: pat,
dataProp: key,
dataPropType: Type.Str,
},
valid
)
}
if (it.opts.unevaluated && props !== true) {
gen.assign(_`${props}[${key}]`, true)
} else if (!it.allErrors) {
} else if (!alwaysValid && !it.allErrors) {
// can short-circuit if `unevaluatedProperties` is not supported (opts.next === false)

@@ -69,0 +84,0 @@ // or if all properties were evaluated (props === true)

@@ -45,3 +45,3 @@ import type {CodeKeywordDefinition, KeywordErrorDefinition} from "../../types"

checkMetadata(cxt)
const {data, schema, parentSchema} = cxt
const {data, schema, parentSchema, it} = cxt
let cond: Code

@@ -62,4 +62,10 @@ switch (schema) {

default: {
const [min, max] = intRange[schema as IntType]
cond = _`typeof ${data} == "number" && isFinite(${data}) && ${data} >= ${min} && ${data} <= ${max} && !(${data} % 1)`
const sch = schema as IntType
cond = _`typeof ${data} == "number" && isFinite(${data}) && !(${data} % 1)`
if (!it.opts.int32range && (sch === "int32" || sch === "uint32")) {
if (sch === "uint32") cond = _`${cond} && ${data} >= 0`
} else {
const [min, max] = intRange[sch]
cond = _`${cond} && ${data} >= ${min} && ${data} <= ${max}`
}
}

@@ -66,0 +72,0 @@ }

{
"name": "ajv",
"version": "8.5.0",
"version": "8.6.0",
"description": "Another JSON Schema Validator",

@@ -67,3 +67,3 @@ "main": "dist/ajv.js",

"@ajv-validator/config": "^0.3.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-json": "^4.1.0",

@@ -95,10 +95,10 @@ "@rollup/plugin-node-resolve": "^13.0.0",

"karma-mocha": "^2.0.0",
"lint-staged": "^10.2.11",
"lint-staged": "^11.0.0",
"mocha": "^8.0.1",
"node-fetch": "^2.6.1",
"nyc": "^15.0.0",
"prettier": "^2.0.5",
"prettier": "^2.3.1",
"rollup": "^2.44.0",
"rollup-plugin-terser": "^7.0.2",
"ts-node": "^9.0.0",
"ts-node": "^10.0.0",
"tsify": "^5.0.2",

@@ -105,0 +105,0 @@ "typescript": "^4.2.0",

@@ -9,3 +9,3 @@ <img align="right" alt="Ajv logo" width="160" src="https://ajv.js.org/img/ajv.svg">

Supports JSON Schema draft-06/07/2019-09/2020-12 (draft-04 is supported in [version 6](https://github.com/ajv-validator/ajv/tree/v6)) and JSON Type Definition [RFC8927](https://datatracker.ietf.org/doc/rfc8927/).
Supports JSON Schema draft-04/06/07/2019-09/2020-12 ([draft-04 support](https://ajv.js.org/json-schema.html#draft-04) requires ajv-draft-04 package) and JSON Type Definition [RFC8927](https://datatracker.ietf.org/doc/rfc8927/).

@@ -12,0 +12,0 @@ [![build](https://github.com/ajv-validator/ajv/workflows/build/badge.svg)](https://github.com/ajv-validator/ajv/actions?query=workflow%3Abuild)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc