New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ajv-cmd

Package Overview
Dependencies
Maintainers
0
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajv-cmd - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

56

audit.js
// TODO craft into JSON-Schema Spec
export const audit = (schema, path = []) => {
const issues = []
let issues = []
if (typeof schema !== 'object') {
return issues
}
switch (schema.type) {

@@ -25,3 +28,3 @@ case 'array':

} else {
issues.concat(audit(schema.items, [...path, 'items']))
issues = issues.concat(audit(schema.items, [...path, 'items']))
}

@@ -72,3 +75,3 @@

} else if (Object.hasOwn(schema, 'pattern')) {
if (schema.pattern.substring(0, 1) !== '^') {
if (!checkRegExpStartWith(schema.pattern)) {
issues.push({

@@ -79,3 +82,3 @@ message: 'String RegExp missing `^` at the start of `pattern`',

}
if (schema.pattern.substring(-1) !== '$') {
if (!checkRegExpEndWith(schema.pattern)) {
issues.push({

@@ -146,3 +149,3 @@ message: 'String RegExp missing `$` at the end of `pattern`',

if (Object.hasOwn(schema, 'propertyNames')) {
if (schema.propertyNames.pattern.substring(0, 1) !== '^') {
if (!checkRegExpStartWith(schema.propertyNames.pattern)) {
issues.push({

@@ -154,3 +157,3 @@ message:

}
if (schema.propertyNames.pattern.substring(-1) !== '$') {
if (!checkRegExpEndWith(schema.propertyNames.pattern)) {
issues.push({

@@ -164,3 +167,3 @@ message: 'propertyNames RegExp missing `$` at the end of `pattern`',

for (const property in schema.properties) {
issues.concat(
issues = issues.concat(
audit(schema.properties[property], [

@@ -176,3 +179,3 @@ ...path,

for (const property in schema.patternProperties) {
if (property.substring(0, 1) !== '^') {
if (!checkRegExpStartWith(property)) {
issues.push({

@@ -183,3 +186,3 @@ message: 'RegExp missing `^` at the start of `patternProperties`',

}
if (property.substring(-1) !== '$') {
if (!checkRegExpEndWith(property)) {
issues.push({

@@ -190,3 +193,3 @@ message: 'RegExp missing `$` at the end of `patternProperties`',

}
issues.concat(
issues = issues.concat(
audit(schema.patternProperties[property], [

@@ -203,6 +206,13 @@ ...path,

default:
issues.push({
message: 'missing `type`',
path: path.join('.')
})
if (
!Object.hasOwn(schema, 'if') &&
!Object.hasOwn(schema, 'allOf') &&
!Object.hasOwn(schema, 'anyOf') &&
!Object.hasOwn(schema, 'oneOf')
) {
issues.push({
message: 'missing `type`',
path: path.join('.')
})
}
}

@@ -212,3 +222,5 @@

for (let i = 0, l = schema.allOf.length; i < l; i++) {
issues.concat(audit(schema.allOf[i], [...path, 'allOf', `[${i}]`]))
issues = issues.concat(
audit(schema.allOf[i], [...path, 'allOf', `[${i}]`])
)
}

@@ -218,3 +230,5 @@ }

for (let i = 0, l = schema.anyOf.length; i < l; i++) {
issues.concat(audit(schema.anyOf[i], [...path, 'allOf', `[${i}]`]))
issues = issues.concat(
audit(schema.anyOf[i], [...path, 'anyOf', `[${i}]`])
)
}

@@ -224,3 +238,5 @@ }

for (let i = 0, l = schema.oneOf.length; i < l; i++) {
issues.concat(audit(schema.oneOf[i], [...path, 'allOf', `[${i}]`]))
issues = issues.concat(
audit(schema.oneOf[i], [...path, 'oneOf', `[${i}]`])
)
}

@@ -232,2 +248,8 @@ }

const checkRegExpStartWith = (pattern) =>
pattern.substring(0, 1) === '^' || pattern.substring(0, 2) === '(^'
const checkRegExpEndWith = (pattern) =>
pattern.substring(pattern.length - 1) === '$' ||
pattern.substring(pattern.length - 2) === '$)'
export default audit
{
"name": "ajv-cmd",
"version": "0.6.0",
"version": "0.6.1",
"description": "Deref, Validate, Transpile, and Test JSON-Schema (.json) files using ajv",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc