@existdb/node-exist
Advanced tools
@@ -21,2 +21,9 @@ // createCollection | ||
| // convenience function | ||
| // throws an exception if and only if | ||
| // the collection exists but cannot be written by the user | ||
| function existsAndCanOpen (client, name) { | ||
| return client.promisedMethodCall('existsAndCanOpenCollection', [name]) | ||
| } | ||
| module.exports = { | ||
@@ -26,3 +33,4 @@ create, | ||
| describe, | ||
| read | ||
| read, | ||
| existsAndCanOpen | ||
| } |
+1
-1
@@ -58,3 +58,3 @@ { | ||
| }, | ||
| "version": "4.3.2" | ||
| "version": "4.4.0" | ||
| } |
+13
-0
@@ -286,2 +286,15 @@ # node-exist | ||
| #### existsAndCanOpen | ||
| This function checks if the collection exists and if it does, if the current user can access it. | ||
| - returns `true` if the collection exists and the current user can open it | ||
| - returns `false` if the collection does not exist | ||
| - throws an exception if the collection exists but the current user cannot | ||
| access it | ||
| ```js | ||
| db.collections.existsAndCanOpen(collectionPath) | ||
| ``` | ||
| ### App | ||
@@ -288,0 +301,0 @@ |
| const test = require('tape') | ||
| const { connect } = require('../../index') | ||
| const connectionOptions = require('../connection') | ||
| const asGuest = Object.assign({}, | ||
| connectionOptions, | ||
| { basic_auth: { user: 'guest', pass: 'guest' } } | ||
| ) | ||
@@ -66,1 +70,66 @@ test('get collection info', function (t) { | ||
| }) | ||
| test('collection exists and guest cannot open it', function (t) { | ||
| const db = connect(asGuest) | ||
| db.collections.existsAndCanOpen('/db/system/security') | ||
| .then(function () { | ||
| t.fail() | ||
| t.end() | ||
| }) | ||
| .catch(function (e) { | ||
| t.ok(e, '/db/system/security exists and user guest cannot access it') | ||
| t.end() | ||
| }) | ||
| }) | ||
| test('collection exists and guest can open it', function (t) { | ||
| const db = connect(asGuest) | ||
| db.collections.existsAndCanOpen('/db/apps/dashboard') | ||
| .then(function (success) { | ||
| t.true(success, '/db/apps/dashboard exists and user guest can access it') | ||
| t.end() | ||
| }) | ||
| .catch(function (e) { | ||
| t.fail(e) | ||
| t.end() | ||
| }) | ||
| }) | ||
| test('collection does not exist (guest)', function (t) { | ||
| const db = connect(asGuest) | ||
| db.collections.existsAndCanOpen('/db/apps/asdf') | ||
| .then(function (success) { | ||
| t.false(success, '/db/apps/asdf does not exist') | ||
| t.end() | ||
| }) | ||
| .catch(function (e) { | ||
| t.fail(e) | ||
| t.end() | ||
| }) | ||
| }) | ||
| test('collection exists and admin can open it', function (t) { | ||
| const db = connect(connectionOptions) | ||
| db.collections.existsAndCanOpen('/db/system/security') | ||
| .then(function (success) { | ||
| t.true(success) | ||
| t.end() | ||
| }) | ||
| .catch(function (e) { | ||
| t.fail(e) | ||
| t.end() | ||
| }) | ||
| }) | ||
| test('collection does not exist (admin)', function (t) { | ||
| const db = connect(connectionOptions) | ||
| db.collections.existsAndCanOpen('/db/apps/asdf') | ||
| .then(function (success) { | ||
| t.false(success, '/db/apps/asdf does not exist') | ||
| t.end() | ||
| }) | ||
| .catch(function (e) { | ||
| t.fail(e) | ||
| t.end() | ||
| }) | ||
| }) |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
70454
3.5%1150
6.58%494
2.7%