authress-engineering / dynamodb-armor Goto Github PK
View Code? Open in Web Editor NEWDrop in replacement for DynamoDB, 100% compatible, protects against common production problems
License: Apache License 2.0
Drop in replacement for DynamoDB, 100% compatible, protects against common production problems
License: Apache License 2.0
const keyExpressionTokens = parseExpression(originalParams.KeyConditionExpression);
const filterExpressionTokens = parseExpression(originalParams.FilterExpression);
const matchingFilterExpressionKey = Object.keys(filterExpressionTokens.keys).some(filterKey => Object.keys(keyExpressionTokens.keys)
.some(keyKey => originalParams.ExpressionAttributeNames[keyKey] === originalParams.ExpressionAttributeNames[filterKey]));
// TODO: convert this from a error generation to in memory filtering
if (matchingFilterExpressionKey) {
throw new DynamoDbError({ title: 'DynamoDB disallows having a FilterExpression contain ', key: matchingFilterExpressionKey, parameters: originalParams }, 'InvalidExpression');
}
Example:
for (const partialExpression of partialExpressions) {
const partialExpressionOrderedTokens = (partialExpression || '').replace(/^(DELETE|ADD|SET|REMOVE)\s+/i, '')
.trim().split(',').filter(token => token).map(token => token.trim());
const isValidKey = operand => operand.match(/^#\w+(\.#\w)*$/);
const isValidOperand = operand => operand.match(/^:\w+$/) || operand.match(/^(#\w+(\.#\w)*|:\w+)[-+](#\w+(\.#\w)*|:\w+)$/);
const arrayIterator = partialExpressionOrderedTokens[Symbol.iterator]();
let result;
while ((result = arrayIterator.next()) && !result.done) {
const key = arrayIterator.next().value;
const equalSign = arrayIterator.next().value;
const operand = arrayIterator.next().value;
if (!isValidKey(key) || equalSign !== '=' || !isValidOperand(operand)) {
logger({ code: 'InvalidExpression', expression });
throw new DynamoDbError({
title: 'Invalid Expression: the expression does not match what DynamoDB expects: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html', expression,
tokens: [key, equalSign, operand]
}, 'InvalidExpression');
}
// parseExpressionRecursive(token, orderedTokens);
}
}
Where the latter
comes after former
(we don't want to automatically switch these, because if it isn't intentional, and we want to stop at X, stopping at Y which is later will cause a bug for the implementation.)
To make sure that if an invalid token is used it is alerted on that as an error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.