Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
uk.dioxic.mgenerate:mgenerate-parent
mgenerate4j is a tool for generating rich JSON documents from a template.
It can be used as a standalone application or as a library and is also extendable if you need to do something that isn't covered by the out-of-the-box functions.
The core syntax is largely the same as mgeneratejs by Thomas Rueckstiess.
To find out more, please check out the mgenerate4j wiki.
Here we have a template that defines 3 fields; a random name, a random age and an array with 2 random email address.
{ "name": "$name", "age": "$age", "emails": { "$array": { "of": "$email", "number": 2} } }
{"name": "Jeffery Dooley", "age": 71, "emails": ["daisy.monahan@hotmail.com", "jacey.bauch@hotmail.com"]}
{"name": "Durward Morar", "age": 3, "emails": ["osborne.kassulke@hotmail.com", "amparo.stokes@gmail.com"]}
{"name": "Reyes Cartwright", "age": 42, "emails": ["candida.macejkovic@hotmail.com", "kasey.vandervort@yahoo.com"]}
{"name": "Naomi Nicolas", "age": 117, "emails": ["ottilie.murazik@gmail.com", "dillon.marvin@hotmail.com"]}
{"name": "Athena Buckridge", "age": 36, "emails": ["aryanna.tromp@gmail.com", "celestino.buckridge@gmail.com"]}
Assuming git and Maven installed:
$ git clone https://github.com/dioxic/mgenerate4j.git
$ mvn clean package
$ java -jar mgenerate-core/target/mgenerate.jar example-template.json
To import as a maven dependency:
<dependency>
<groupId>uk.dioxic.mgenerate</groupId>
<artifactId>mgenerate-core</artifactId>
<version>0.0.5</version>
</dependency>
To import as a gradle dependency:
dependencies {
compile 'uk.dioxic.mgenerate:mgenerate-core:0.0.5'
}
Note: precompiled executable jars are also available in releases.
Usage: mgenerate [-h] [--debug] [-n=<number>] [-o=<output>] TEMPLATE
TEMPLATE template file path
--debug debug logging
-h, --help display a help message
-n, --number=<number> number of documents to generate (default: 10)
-o, --out=<output> output file path
$ java -jar mgenerate.jar template.json
MongoClientSettings mcs = MongoClientSettings.builder()
.codecRegistry(TemplateCodec.getCodecRegistry())
.build();
Template template = Template.from("c:\\tmp\\mongo.json");
MongoCollection<Template> collection = MongoClients.create(mcs)
.getDatabase("test")
.getCollection("mgen", Template.class);
collection.insertOne(template);
collection.insertOne(template);
collection.insertOne(template);
This will result in 3 different documents being inserted since the template is hydrated during encoding.
Apache 2.0
FAQs
Parent project for mgenerate4j
We found that uk.dioxic.mgenerate:mgenerate-parent demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.