
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
Factory/Loader of mongoose
mongo query via mongoose apirpc query via rpc methodsAFAIK, we can use hooks or so called middlewares to modify the mongoose model object before save and remove functions, but it does not works on update function. There was even leaded to an argument on github, but the maintainers still don't pay their attension on this issue.
So I decide to use some tricks to overwrite the mongoose model methods, and make the hooks work. For example, we have an update function in model, we need update the updatedAt key when we save data by update function, we can overwrite this function.
_update = UserModel.update
UserModel.update = (conditions, update) ->
update.updatedAt or= new Date
_update.apply this, arguments
In limbo, we supply an overwrite function to help you overwrite the same name function of each model.
limbo = require 'limbo'
db = limbo.use 'test',
conn: mongoose.createConnection 'mongodb://localhost/test'
# Overwrite the update function
db.loadOverwrite 'update', (_update) ->
(conditions, update) ->
update or= new Date
_update.apply this, arguments
# Load schemas
db.loadSchema 'User', UserSchema
# Then each update function will auto update the updateAt key when executed
db.user.update()
We use a currying way to ensure your function recieve the exactly arguments by the user given. So the origin function of model will give you in the wrapper function (in this example, it is _update).
As the same as loadStatics and loadMethods in limbo, the loadOverwrite function also have a plural version: loadOverwrites, you can pass a group of overwrite function to it.
Some methods in rpc provider is not enabled, here is some examples:
db.user.find({}).limit(1).exec(callback) => db.user.find({}, {limit: 1}, callback)
db.user.find({email: /gmail.com/}, {limit: 1}, callback) => db.user.aggregate([{$match: {'email': {$regex: 'gmail.com'}}}, {$limit: 1}])
aggregate function in mongoose do not auto cast variables to ObjectId or anything else, so you should take case of these variables and do not use them in the rpc provider. (for the reason JSON only accept data)bind event when methods are loaded from rpc serverbind and enableRpc to one method: enableRpcloadStatics, loadMethods and loadOverwrites in mongo providerload prefix on all loading methodsbind method to mongo provider_methods in exposed methodsMIT
FAQs
Factory/Loader of mongoose
The npm package limbo receives a total of 30 weekly downloads. As such, limbo popularity was classified as not popular.
We found that limbo 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.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.