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

asl-validator

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asl-validator - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

37

dist/src/checks/duplicate-payload-template-fields.js

@@ -14,17 +14,24 @@ "use strict";

var errorMessages = [];
(0, jsonpath_plus_1.JSONPath)({
json: definition,
// this uses some extensions to the original JSONPath spec supported by the lib
//
// extension 1: @property.match enables matching on the matched property name.
// This finds and selects all nodes with a name ending in .$
// extension 2: ^ operator twice at the end selects the parent node instead of the value for the node
//
// also, don't miss the array offset [0] before selecting the grandparent.
// There may be multiple fields within a node that could be in conflict.
// We're checking all the keys in the parent node, so we only need a single
// result for that parent.
path: "$..[Parameters,ResultSelector]..*[?(@property.match(/^.+\\.\\$$/))][0]^^"
})
.forEach(function (parent) {
var valuesToInspect = [];
try {
valuesToInspect = (0, jsonpath_plus_1.JSONPath)({
json: definition,
// this uses some extensions to the original JSONPath spec supported by the lib
//
// extension 1: @property.match enables matching on the matched property name.
// This finds and selects all nodes with a name ending in .$
// extension 2: ^ operator twice at the end selects the parent node instead of the value for the node
//
// also, don't miss the array offset [0] before selecting the grandparent.
// There may be multiple fields within a node that could be in conflict.
// We're checking all the keys in the parent node, so we only need a single
// result for that parent.
path: "$..[Parameters,ResultSelector]..*[?(@property.match(/^.+\\.\\$$/))][0]^^"
});
}
catch (err) {
// need to revisit this since the JSONPath lib throws an error when it encounters an array
// Error: jsonPath: _$_property.match is not a function: _$_property.match(/^.+\.\$$/)
}
valuesToInspect.forEach(function (parent) {
var keys = {};

@@ -31,0 +38,0 @@ Object.keys(parent).forEach(function (key) {

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

instancePath: error.instancePath,
schemaPath: error.schemaPath
schemaPath: decodeURIComponent(error.schemaPath)
}

@@ -105,0 +105,0 @@ });

@@ -40,3 +40,3 @@ {

{
"$ref": "#/definitions/_asl_payload_template"
"$ref": "#/definitions/_payload_template_object"
}

@@ -43,0 +43,0 @@ ]

{
"name": "asl-validator",
"version": "3.0.2",
"version": "3.0.3",
"description": "Amazon States Language validator",

@@ -5,0 +5,0 @@ "main": "./dist/src/validator.js",

@@ -12,31 +12,38 @@ import {JSONPath} from 'jsonpath-plus';

const errorMessages: StateMachineError[] = [];
JSONPath<Record<string, unknown>[]>({
json: definition,
// this uses some extensions to the original JSONPath spec supported by the lib
//
// extension 1: @property.match enables matching on the matched property name.
// This finds and selects all nodes with a name ending in .$
// extension 2: ^ operator twice at the end selects the parent node instead of the value for the node
//
// also, don't miss the array offset [0] before selecting the grandparent.
// There may be multiple fields within a node that could be in conflict.
// We're checking all the keys in the parent node, so we only need a single
// result for that parent.
path: `$..[Parameters,ResultSelector]..*[?(@property.match(/^.+\\.\\$$/))][0]^^`
})
.forEach((parent) => {
const keys: Record<string, number> = {};
Object.keys(parent).forEach((key) => {
const keyPostEval = key.endsWith(".$") ? key.substring(0, key.length - 2) : key;
const current = keys[keyPostEval];
if (current) {
errorMessages.push({
'Error code': StateMachineErrorCode.DuplicateFieldName,
Message: `A duplicate field will exist after renaming to strip the ".$" suffix from: ${key}.$`,
});
}
keys[keyPostEval] = current ? current + 1 : 1;
});
let valuesToInspect: Record<string, unknown>[] = [];
try {
valuesToInspect = JSONPath<Record<string, unknown>[]>({
json: definition,
// this uses some extensions to the original JSONPath spec supported by the lib
//
// extension 1: @property.match enables matching on the matched property name.
// This finds and selects all nodes with a name ending in .$
// extension 2: ^ operator twice at the end selects the parent node instead of the value for the node
//
// also, don't miss the array offset [0] before selecting the grandparent.
// There may be multiple fields within a node that could be in conflict.
// We're checking all the keys in the parent node, so we only need a single
// result for that parent.
path: `$..[Parameters,ResultSelector]..*[?(@property.match(/^.+\\.\\$$/))][0]^^`
})
} catch (err: unknown) {
// need to revisit this since the JSONPath lib throws an error when it encounters an array
// Error: jsonPath: _$_property.match is not a function: _$_property.match(/^.+\.\$$/)
}
valuesToInspect.forEach((parent) => {
const keys: Record<string, number> = {};
Object.keys(parent).forEach((key) => {
const keyPostEval = key.endsWith(".$") ? key.substring(0, key.length - 2) : key;
const current = keys[keyPostEval];
if (current) {
errorMessages.push({
'Error code': StateMachineErrorCode.DuplicateFieldName,
Message: `A duplicate field will exist after renaming to strip the ".$" suffix from: ${key}.$`,
});
}
keys[keyPostEval] = current ? current + 1 : 1;
});
});
return errorMessages;
}
}

@@ -96,5 +96,5 @@ import Ajv, {ErrorObject} from 'ajv';

instancePath: error.instancePath,
schemaPath: error.schemaPath
schemaPath: decodeURIComponent(error.schemaPath)
}
}));
}
}

@@ -40,3 +40,3 @@ {

{
"$ref": "#/definitions/_asl_payload_template"
"$ref": "#/definitions/_payload_template_object"
}

@@ -43,0 +43,0 @@ ]

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