Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
enrise-lock
Advanced tools
An elasticsearch based lock mechanism for resources and ownership.
This module provides abstraction methods to lock a resource with an owner. The owner is the name of the process requesting a lock. The resource would be the specific element/index/endpoint/etc.. that requires locking.
NPM: npm install enrise-lock --save
Yarn: yarn add enrise-lock
Require and instantiate the locker.
const lock = new require('enrise-lock')(config: Object);
Where config
is an object with the following options. Type is optional, the rest is mandatory.
esClient: elasticsearch
: An elasticsearch client for the lock module to use. This can either be an elasticsearch or an enrise-esclient instance.index: String
: The elasticsearch index that will be used to store all lock-documents.owner: String
: The name of the process that is looking to place the lock.[type: String]
: The index-type that will be used to store all lock-documents. This will default to 'lockdocument'
.lock.acquire(resource: String, callback: function)
Set a lock for resource: resource
. Callback will be called with parameters [err, success: boolean]
. The success paramater will be false if a lock already exists.
lock.release(resource: String, callback: function)
Release a lock for resource: resource
. Callback will be called with parameter [err]
.
lock.isLocked(resource: String, callback: function)
Check if a resource is locked. Callback will be called with parameters [err, isLocked: boolean]
.
lock.list(callback: function)
Retrieve a list of all current locks. Callback will be called with parameters [err, locks: Object]
. Where the key in locks represents the resource and the value an object with the owner.
lock.delete(callback: function)
Delete the entire lock-index. Callback will be called with parameter [err]
.
const lock = new require('enrise-lock')({
esClient: new require('elasticsearch').Client(),
index: 'globallock',
type: 'lockdocument',
owner: 'api'
});
// Set lock
lock.acquire('my-resource', (err, success) => {
// Do some asynchronous operation
// ...
// Release lock
lock.release('my-resource', (err, success) => {
// ...
});
});
FAQs
Lock functionality used within Enrise projects and module's
The npm package enrise-lock receives a total of 1 weekly downloads. As such, enrise-lock popularity was classified as not popular.
We found that enrise-lock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.