Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
http-deceiver
Advanced tools
The http-deceiver npm package is designed to manipulate HTTP requests and responses. It allows developers to intercept, modify, and create custom behaviors for HTTP traffic, which is particularly useful in testing and development environments where simulating various network conditions and responses is necessary.
Intercept and modify HTTP requests
This feature allows you to intercept HTTP requests and modify properties such as the URL before the server processes them. In the provided code, the request URL is changed to '/modified-path', and a custom response is sent back.
const httpDeceiver = require('http-deceiver');
const http = require('http');
const server = http.createServer((req, res) => {
httpDeceiver.deceive(req, res, (req, res) => {
req.url = '/modified-path';
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Request was modified');
});
});
server.listen(3000);
Simulate server responses
This feature is useful for simulating different server responses under various conditions. In this example, a 503 Service Unavailable response is simulated regardless of the actual server state or the incoming request.
const httpDeceiver = require('http-deceiver');
const http = require('http');
const server = http.createServer((req, res) => {
httpDeceiver.deceive(req, res, (req, res) => {
res.writeHead(503, {'Content-Type': 'text/plain'});
res.end('Service Unavailable');
});
});
server.listen(3000);
Nock is a powerful HTTP server mocking and expectations library for Node.js. It allows you to control HTTP requests and responses with a high level of granularity. Compared to http-deceiver, nock provides a more comprehensive API for defining precise request and response behaviors, making it ideal for complex testing scenarios.
Sinon provides standalone test spies, stubs, and mocks for JavaScript. While it is not limited to HTTP, it can be used in conjunction with other libraries to mock HTTP interactions. Sinon is generally more flexible than http-deceiver as it can handle a wider range of testing needs beyond just HTTP.
Deceive!
This software is licensed under the MIT License.
Copyright Fedor Indutny, 2015.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Deceive HTTP parser
The npm package http-deceiver receives a total of 8,282,299 weekly downloads. As such, http-deceiver popularity was classified as popular.
We found that http-deceiver 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.