@lifeomic/abac
Advanced tools
Comparing version 4.0.2 to 4.1.0
@@ -391,3 +391,23 @@ 'use strict'; | ||
/** | ||
* Synchronously determines if a given attribute path is in the list of rules | ||
* Return true iff left is a path prefix of right | ||
*/ | ||
const isPathPrefix = (left, right) => { | ||
const lhs = left.split('.'); | ||
const rhs = right.split('.'); | ||
if (lhs.length > rhs.length) { | ||
return false; | ||
} | ||
for (let i = 0; i < lhs.length; ++i) { | ||
if (lhs[i] !== rhs[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
/** | ||
* Synchronously determines if a given attribute path is used in the rules | ||
* for a given policy. This may be useful for determining if additional metadata | ||
@@ -402,3 +422,16 @@ * should be fetched before enforcing a policy. | ||
const rules = (0, _values2.default)(policy.rules).filter(rule => Array.isArray(rule)).reduce((left, right) => left.concat(right), []); | ||
return rules.some(rule => rule.hasOwnProperty(attribute)); | ||
for (const rule of rules) { | ||
for (const key in rule) { | ||
if (isPathPrefix(attribute, key)) { | ||
return true; | ||
} else { | ||
const target = rule[key].target; | ||
if (target && isPathPrefix(attribute, target)) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
@@ -405,0 +438,0 @@ |
@@ -534,3 +534,23 @@ 'use strict'; | ||
/** | ||
* Synchronously determines if a given attribute path is in the list of rules | ||
* Return true iff left is a path prefix of right | ||
*/ | ||
var isPathPrefix = function isPathPrefix(left, right) { | ||
var lhs = left.split('.'); | ||
var rhs = right.split('.'); | ||
if (lhs.length > rhs.length) { | ||
return false; | ||
} | ||
for (var i = 0; i < lhs.length; ++i) { | ||
if (lhs[i] !== rhs[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
/** | ||
* Synchronously determines if a given attribute path is used in the rules | ||
* for a given policy. This may be useful for determining if additional metadata | ||
@@ -549,5 +569,38 @@ * should be fetched before enforcing a policy. | ||
}, []); | ||
return rules.some(function (rule) { | ||
return rule.hasOwnProperty(attribute); | ||
}); | ||
var _iteratorNormalCompletion7 = true; | ||
var _didIteratorError7 = false; | ||
var _iteratorError7 = undefined; | ||
try { | ||
for (var _iterator7 = _getIterator(rules), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { | ||
var rule = _step7.value; | ||
for (var key in rule) { | ||
if (isPathPrefix(attribute, key)) { | ||
return true; | ||
} else { | ||
var target = rule[key].target; | ||
if (target && isPathPrefix(attribute, target)) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError7 = true; | ||
_iteratorError7 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion7 && _iterator7.return) { | ||
_iterator7.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError7) { | ||
throw _iteratorError7; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
@@ -554,0 +607,0 @@ |
@@ -367,3 +367,23 @@ 'use strict'; | ||
/** | ||
* Synchronously determines if a given attribute path is in the list of rules | ||
* Return true iff left is a path prefix of right | ||
*/ | ||
const isPathPrefix = (left, right) => { | ||
const lhs = left.split('.'); | ||
const rhs = right.split('.'); | ||
if (lhs.length > rhs.length) { | ||
return false; | ||
} | ||
for (let i = 0; i < lhs.length; ++i) { | ||
if (lhs[i] !== rhs[i]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
/** | ||
* Synchronously determines if a given attribute path is used in the rules | ||
* for a given policy. This may be useful for determining if additional metadata | ||
@@ -378,3 +398,16 @@ * should be fetched before enforcing a policy. | ||
const rules = _Object$values(policy.rules).filter(rule => Array.isArray(rule)).reduce((left, right) => left.concat(right), []); | ||
return rules.some(rule => rule.hasOwnProperty(attribute)); | ||
for (const rule of rules) { | ||
for (const key in rule) { | ||
if (isPathPrefix(attribute, key)) { | ||
return true; | ||
} else { | ||
const target = rule[key].target; | ||
if (target && isPathPrefix(attribute, target)) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
@@ -381,0 +414,0 @@ |
{ | ||
"name": "@lifeomic/abac", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"description": "Lifeomic Attribute Based Access Control Support Module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
149756
35
1973