
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@stuntman/server
Advanced tools
Stuntman is a proxy/mock server that can be deployed remotely together with your application under test, working as either pass-through proxy allowing you to inspect traffic or proxy/mock which can intercept requests/responses and modify them or stub with predefined ones.
It offers API and client library that can be used for example within E2E functional test scripts to dynamically alter it's behaviour for specific traffic matching set of rules of your definition.
In order to get more familiar with the concept and how to use it please refer to example app
NOTE: This project is at a very early stage of developement and as such may often contain breaking changes in upcoming releases before reaching stable version 1.0.0
nvm use
pnpm install --frozen-lockfile
pnpm build
pnpm stuntman
Stuntman uses config
You can create config/default.json
with settings of your liking matching Stuntman.Config
type
npm install @stuntman/server
yarn add @stuntman/server
pnpm add @stuntman/server
stuntman
yarn stuntman
node ./node_modules/.bin/stuntman
import { Mock } from '../mock';
import { stuntmanConfig } from '@stuntman/shared';
const mock = new Mock(stuntmanConfig);
mock.start();
Add some domains with .stuntman
suffix (or .stuntmanhttp
/ .stuntmanhttps
depending where you want to direct the traffic in proxy mode) to your /etc/hosts
for example
127.0.0.1 www.example.com.stuntman
go to your browser and visit http://www.example.com.stuntman:2015/
to see the proxied page
for local playground you can also use http://www.example.com.localhost:2015
Mind the scope of Stuntman.RemotableFunction
like matches
, modifyRequest
, modifyResponse
.
Stuntman.RemotableFunction.localFn
contains the function, but since it'll be executed on a remote mock server it cannot access any variables outside it's body. In order to pass variable values into the function use Stuntman.RemotableFunction.variables
for example:
matches: {
localFn: (req) => {
// you might need to ignore typescript errors about undefined variables in this scope
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return /http:\/\/[^/]+\/somepath$/.test(req.url) && req.url.includes(`?someparam=${myVar}`);
},
localVariables: { myVar: 'myValue' },
}
You can build the rules using fluentish ruleBuilder
import { Client } from './apiClient';
import { ruleBuilder } from './ruleBuilder';
const client = new Client();
const uniqueQaUserEmail = 'unique_qa_email@example.com';
const rule = ruleBuilder()
.limitedUse(2)
.onRequestToHostname('example.com')
.withSearchParam('user', uniqueQaUserEmail)
.mockResponse({
localFn: (req) => {
if (JSON.parse(req.body).email !== uniqueQaUserEmail) {
return {
status: 500,
};
}
return { status: 201 };
},
localVariables: { uniqueQaUserEmail },
});
client.addRule(rule).then((x) => console.log(x));
....just don't look to closely, it's very much incomplete and hacky
FAQs
Stuntman - HTTP proxy / mock server with API
The npm package @stuntman/server receives a total of 1,937 weekly downloads. As such, @stuntman/server popularity was classified as popular.
We found that @stuntman/server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.