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.
Simple tool for HTTP response simulation, automated and load testing.
When started, server parses query string of incoming requests and responds with simulated latency, status code, JSON payload or any combination of the mentioned above.
npm install simdummy
To simulate HTTP response with latency, start listener at custom port:
const run = require('simdummy').run
run((port, stats, server) => {
console.log(`Simulation server started at ${port}`)
}, 9999)
Then make HTTP call and specify required latency (eg: 200ms) in query string:
time curl http://localhost:9999/?l=200\&eh=1
To start HTTP listener to test asynchronous code with promises and async/await:
const test = require('simdummy').test
it('test async promise', async () => {
await test(async (port, stats, server) => {
const res = await yourHttpClient.get(`http://localhost:${port}`)
expect(res.status).to.equal(200)
expect(stats.calls).to.equal(1)
})
})
Sim server collects basic statistics about number of requests received, responses sent and calls droped. The stats are exposed on sim sever instance as property and passed to run and test callbacks as argument:
To start HTTP listener to test asynchronous code with callbacks, pass done to test call:
it('test async callback', done => {
test((port, stats, server, done) => {
yourHttpClient.get(`http://localhost:${port}`, res => {
expect(res.status).to.equal(200)
expect(stats.calls).to.equal(1)
done()
})
}, done)
})
Simulation settings are passed as query string parameters:
Here is an example of how the simulation server can be started and which events are exposed.
const SimServer = require('simdummy').SimServer
// set latency and response body size limits
const limits = { maxLatency: 500, maxBodySize: 16 * 1024 }
const server = new SimServer(limits)
server.start(s =>
// execute code on start
console.log(`Simulation server started at ${s.address().port}`),
// set custom port
9999
)
// request event is emitted after settings parsed and limits applied
server.on('request', (req, res, settings) => {
console.log('Accepted request')
// override response latency
setting.latency.actual = 1000
// override response body
settings.response.body = 'Hello, world!'
// or end response right here
res.end()
})
// response event is emitted before sending response
server.on('response', (req, res, settings) => {
console.log('Sending response')
// pipe request to response
settings.response.echoBody = true
// or override the whole body
settings.response.body = 'Hello, world!'
// set different status code
res.statusCode = 201
})
// stop the server
server.close(err => {
// execute code on stop
console.log('Simulation server stopped')
})
To start simdummy in Docker container:
docker run --name sd -p 9999:9999 -d alexpereverzyev/simdummy
FAQs
Simple tool for HTTP response simulation, automated and load testing
The npm package simdummy receives a total of 0 weekly downloads. As such, simdummy popularity was classified as not popular.
We found that simdummy 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.