
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@newmo/graphql-fake-server
Advanced tools
GraphQL Fake Server.
See https://github.com/newmo-oss/graphql-fake-server
/fake
API/fake/called
API/graphql
APIUsage: npx @newmo/graphql-fake-server --schema <path> [options]
Options:
--config <path> Path to a config file
--schema <path> Path to a schema file
--logLevel <logLevel> log level: debug, info, warn, error
--cwd <path> Current working directory
--help Show help
Examples:
# Provide a schema file - use default config
npx @newmo/graphql-fake-server --schema api.graphql
# Use a config file
npx @newmo/graphql-fake-server --config graphql-fake-server.config.js
/graphql
and /query
GraphQL Endpoint.
You need to set sequence-id
header to identify the sequence with the request.
await fetch(`${urls.fakeServer}/graphql`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"sequence-id": sequenceId,
},
body: JSON.stringify({
query: `
query GetBooks {
books {
id
title
}
}
`,
}),
});
/fake
Register fake response for GraphQL operation.
await fetch(`${urls.fakeServer}/fake`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"sequence-id": sequenceId,
},
body: JSON.stringify({
type: "operation",
operationName: "CreateBook",
data: {
createBook: {
id: "new-id",
title: "new BOOK",
},
},
}),
});
/fake/called
Return request and response for the request with sequence-id
and operationName
.
const calledResponse = await fetch(`${urls.fakeServer}/fake/called`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"sequence-id": sequenceId,
},
body: JSON.stringify({
operationName: "CreateBook",
}),
});
You can register fake responses with conditions that determine when they should be returned. This allows for different responses based on request characteristics.
Variables-based condition:
// Register a fake that only returns when variables match exactly
await fetch(`${urls.fakeServer}/fake`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"sequence-id": sequenceId,
},
body: JSON.stringify({
type: "operation",
operationName: "GetUser",
requestCondition: {
type: "variables",
value: { id: "admin", role: "admin" },
},
data: {
user: {
id: "admin",
name: "Admin User",
},
},
}),
});
When no condition matches, the server falls back to the declarative fake data defined in the GraphQL schema.
To ensure predictable behavior, variables-based conditions and default (no condition) responses can coexist for the same operation within a sequence.
✅ Allowed combinations:
You can customize the configuration by --config
option.
npx @newmo/graphql-fake-server --config graphql-fake-server.config.mjs
Example of the config file: graphql-fake-server.config.mjs
export default {
schemaFilePath: "./api/api.graphql",
ports: {
fakeServer: 4000,
apolloServer: 4002,
},
maxRegisteredSequences: 1000,
maxQueryDepth: 10,
maxFieldRecursionDepth: 9,
logLevel: "info",
/**
* @type {string[] | undefined}
* Allowed CORS origins for the fake server
* If undefined, it allows localhost and internal network connections only
* @example ["https://example.com", "https://app.example.com"]
*/
allowedCORSOrigins: undefined,
/**
* @type {string[] | "auto" | undefined}
* Allowed Host headers for the fake server to prevent DNS rebinding attacks
* - "auto" (default): Automatically generates allowed hosts from CORS origins and localhost addresses
* - string[]: Explicit list of allowed Host headers
* - undefined: Same as "auto"
* @example ["localhost:4000", "myapp.local:4000"]
*/
allowedHosts: undefined,
};
RequiredFakeServerConfig
schema:
type RequiredFakeServerConfig = {
schemaFilePath: string;
ports: {
fakeServer: number;
apolloServer: number;
};
maxRegisteredSequences: number;
maxQueryDepth: number;
maxFieldRecursionDepth: number;
logLevel?: LogLevel;
/**
* Allowed CORS origins for the fake server
* If undefined, it allows localhost and internal network connections only
* @example ["https://example.com", "https://app.example.com"]
*/
allowedCORSOrigins?: string[] | undefined;
/**
* Allowed Host headers for the fake server to prevent DNS rebinding attacks
* - "auto" (default): Automatically generates allowed hosts from CORS origins and localhost addresses
* - string[]: Explicit list of allowed Host headers
* @example ["localhost:4000", "myapp.local:4000"]
*/
allowedHosts?: string[] | "auto" | undefined;
};
GraphQL Fake Server implements security features to prevent DNS rebinding and cross-origin attacks:
"auto"
- automatically generates allowed hosts from CORS origins and localhost addressesallowedHosts
option accepts "auto"
, string[]
, or undefined
allowedCORSOrigins
option accepts string[]
or undefined
When allowedHosts
is "auto"
(default), the server automatically:
This integration ensures consistent security policies and reduces configuration errors.
npm test
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT
FAQs
GraphQL fake server for testing
The npm package @newmo/graphql-fake-server receives a total of 2,249 weekly downloads. As such, @newmo/graphql-fake-server popularity was classified as popular.
We found that @newmo/graphql-fake-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.