
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A simple CLI used to produce a JSON stream with fake data using JSON schema.
This is basically a CLI upon json-schema-faker project.
npm install -g genjson
The JSON generation is based on a JSON-Schema (draft-04).
You can add an x-faker attribute to choose the data to be generated.
Example:
{
"id": "Sample",
"type": "object",
"properties": {
"uuid": {"type": "string", "x-faker": "random.uuid"},
"timestamp": {"type": "integer", "x-faker": "timestamp.now"},
"email": {"type": "string", "x-faker": "internet.email"}
}
}
This will generate this kind of result:
{
"uuid": "632ff1b6-4d5e-435d-a664-5d4185a6c78e",
"timestamp": 1537174965817,
"email": "Julianne61@yahoo.com"}
}
Please refer to faker.js documentation to see available methods.
There is also some builtin generators:
"x-faker": {"custom.val": "hello world"}: A parameterized faker used to set
a constant value."x-faker": "timestamp.now": Set current time using timestamp format."x-faker": "timestamp.iso": Set current time using ISO format."x-faker": "timestamp.recent": Set a timestamp from the recent past."x-faker": "timestamp.future": Set a timestamp form the future.You can add you own generators (see extensions section).
Type genjson to see usage.
$ genjson -c 10 -i 100 -o file://test.log -s ./schemas/sample.json
-c 10-i 100test.log file: -o file://test.logsample schema: -s ./schema/sample.jsonYou can use
jqto properly display the JSON event.
$ genjson -s ./schemas/sample.json | jq .
sample schema: -s ./schema/sample.json$ genjson -c 100 -i 1000 -o https://requestb.in/13s7hxv1 -s ./schemas/sample.json
-c 100-i 1000-o https://requestb.in/13s7hxv1sample schema: -s ./schema/sample.json$ genjson -c 5 -i 1000 -s schemas/sample.json | xargs -l1 sh -c 'echo "$@" | http POST requestb.in/13s7hxv1'
-c 5-i 1000sample schema: -s ./schema/sample.json| xargs -l1 sh -c 'echo "$@" | http POST requestb.in/13s7hxv1'You can extend the generation of fake data by adding your own custom generator.
Example:
Create a new file (suffixed by .fake.js) into the custom-faker directory:
vi custom-faker/foo.fake.js
Export a function having a faker instance as parameter:
'use strict'
function Foo (faker) {
this.bar = function (val) {
return `FOO - {val}`
}
}
module['exports'] = Foo
Note: this example of a faker function called bar having a parameter.
Now you can use this new faker into you JSON schema:
{
"id": "Sample",
"type": "object",
"properties": {
"id": {"type": "string", "x-faker": "random.uuid"},
"sample": {
"type": "string",
"x-faker": {"foo.bar": "hello"}
}
}
}
You will get the following result:
{
"id": "e6e53833-57e1-4a5b-aa04-7883bd29c57c",
"sample": "FOO - hello"
}
FAQs
CLI to generate fake JSON as a stream
We found that genjson 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.