Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
mongo-assert
Advanced tools
Mongo assertion library.
This library is created to assert made changes in mongodb. Useful when you want to be sure that method added, updated or deleted only one document, and other were unchanged.
$ npm i -D mongo-assert
const nassert = require('n-assert')
const mongoassert = require('mongo-assert')
const initialUsers = [
{
_id: nassert.getObjectId(),
email: 'pen@mail.com',
firstName: 'Piter',
lastName: 'Pen'
},
{
_id: nassert.getObjectId(),
email: 'smith@mail.com',
firstName: 'John',
lastName: 'Smith'
}
]
it('should update user', async () => {
let filter = { _id: initialUsers[0]._id }
let userData = {
email: 'smith-another-email@mail.com'
}
let updatedUser = {
_id: initialUsers[0]._id,
email: 'smith-another-email@mail.com'
}
await User.create(initialUsers)
await usersSrvc.updateUser({ filter, userData })
await mongoassert.assertCollection({
model: User,
initialDocs: initialUsers,
changedDoc: updatedUser,
typeOfChange: updatedUser ? 'updated' : null,
sortField: '_id'
})
})
assertCollection({ model, initialDocs, changedDoc, typeOfChange, sortField })
Asserts mongodb collection. Loads all documents in the collection, merges initial collection with changed document and asserts.
model
- mongoose model.initialDocs
- initial documents collection.changedDoc
- changed document, must be omitted or undefined if collection is unchanged.typeOfChange
- the type of the change (created, updated, deleted), must be omitted if collection is unchanged.sortField
- the field which should be used for sorting actual and expected collections before asseting.Licensed under the MIT license.
Alexander Mac
FAQs
Mongo assertion library
The npm package mongo-assert receives a total of 1 weekly downloads. As such, mongo-assert popularity was classified as not popular.
We found that mongo-assert 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.