MCPcopy Index your code
hub / github.com/scality/cloudserver / _validateTree

Function _validateTree

lib/api/apiUtils/bucket/validateSearch.js:29–53  ·  view source on GitHub ↗
(whereClause, possibleAttributes)

Source from the content-addressed store, hash-verified

27const parser = new Parser(sqlConfig);
28
29function _validateTree(whereClause, possibleAttributes) {
30 let invalidAttribute;
31
32 function _searchTree(node) {
33 if (typeof node !== 'object') {
34 invalidAttribute = node;
35 } else {
36 const operator = Object.keys(node)[0];
37 if (operator === 'AND' || operator === 'OR') {
38 _searchTree(node[operator][0]);
39 _searchTree(node[operator][1]);
40 } else {
41 const field = node[operator][0];
42 if (!field.startsWith('tags.') &&
43 !possibleAttributes[field] &&
44 !field.startsWith('replicationInfo.') &&
45 !field.startsWith('x-amz-meta-')) {
46 invalidAttribute = field;
47 }
48 }
49 }
50 }
51 _searchTree(whereClause);
52 return invalidAttribute;
53}
54
55/**
56 * validateSearchParams - validate value of ?search= in request

Callers 1

validateSearchParamsFunction · 0.85

Calls 1

_searchTreeFunction · 0.85

Tested by

no test coverage detected