Comparing version 0.4.0 to 1.0.0
@@ -73,2 +73,7 @@ /* | ||
{ | ||
if (this.trivial()) { | ||
throw new Error('Cannot serialize empty predicate to LDAP ' | ||
+ 'search filter'); | ||
} | ||
return (krillPrimPrintLDAP(this.p_pred)); | ||
@@ -628,4 +633,8 @@ }; | ||
if (nbKeys === 0) | ||
return ('(*)'); | ||
/* | ||
* Serializing an individual predicate with a number of keys !== 1 -- | ||
* that is an empty predicate, or a predicate with several keys -- to a | ||
* LDAP filter string is not supported. | ||
*/ | ||
mod_assert(nbKeys === 1); | ||
@@ -632,0 +641,0 @@ return (krillOps[key].printLDAP(pred, key)); |
{ | ||
"name": "krill", | ||
"description": "simple boolean filter language with support for C, DTrace and LDAP output", | ||
"version": "0.4.0", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -86,2 +86,32 @@ # krill: simple boolean filter language | ||
Please note however that without knowing the LDAP object schema, it is not | ||
possible to generate a filter that matches all objects. As a result, trivial | ||
predicates cannot be serialized as LDAP search filters: | ||
```javascript | ||
var pred = krill.createPredicate({}); | ||
pred.toLDAPSearchFilter(); | ||
/* Throws the following error: | ||
Error: Cannot serialize empty predicate to LDAP search filter | ||
*/ | ||
``` | ||
The recommended way to handle this case is to check if the predicate is trivial | ||
before calling `toLDAPSearchFilter`: | ||
```javascript | ||
var pred = krill.createPredicate({}); | ||
var ldapSearchFilter; | ||
if (!pred.trivial()) { | ||
ldapSearchFilter = pred.toLDAPFilterString(); | ||
} else { | ||
/* | ||
* This example assumes that when the predicate is trivial, the intention | ||
* is to build a LDAP search filter that includes all entries, but this is | ||
* done only to illustrate a common use case. | ||
*/ | ||
ldapSearchFilter = '(someRDN=*)'; | ||
} | ||
``` | ||
You can also evaluate the predicate for a specific set of values: | ||
@@ -88,0 +118,0 @@ |
@@ -18,3 +18,5 @@ /* | ||
mod_assert.equal('1', pred.toCStyleString()); | ||
mod_assert.equal('(*)', pred.toLDAPFilterString()); | ||
mod_assert.throws(function emptyPredToLDAPFilter() { | ||
pred.toLDAPFilterString() | ||
}, /Cannot serialize empty predicate to LDAP search filter/); | ||
mod_assert.ok(pred.eval({})); | ||
@@ -21,0 +23,0 @@ mod_assert.ok(pred.eval({ 'hostname': 'sharptooth' })); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
60643
1247
1
219
0