Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Not very random temporary name generator
NVRNG
generates array of random readable names, like 'Silver Raccoon' or 'Purple Snake'.
NVRNG
can create sets for different genders (like 'Lemon Stallion' or 'Marble Actress').
NVRNG
uses vocabulary in json
format.
npm install nvrng --save
Example
const { NVRNG } = require('nvrng');
let gen = new NVRNG();
gen.upload('./file.json');
let [err, nameset] = gen.getSet(5);
Here nameset
is of type Set
Some predefined vocabularies can be found in vocabularies
folder in repository
Please, make pull request if found any errors or if you have any other vocabulary to suggest.
constructor({ limit = 100000 })
limit
- max number of attempts to create set
upload(filename, { shuffle = true }) => err
Setup vocabulary. Returns error. If everything is ok, then returns null
;
filename
- path to json
vocabulary
shuffle
- to shuffle vocabulary after upload
getSet(size, { gender = Genders.Any, output = OutputFormat.Set, include, exclude, delimiter = ' ', format = StringFormat.NoFormat }) => [err, set]
Generate set of random names. Returns array. First element is error (null
if ok), second is a set of names;
gender
- gender, possible values are 'n', 'f', 'm', or 'a'. You can also use Enum Genders
with values
Genders.Any
Genders.Female
Genders.Male
Genders.Nuetral
if bad value is used then getSet will return error and null;
Note that possible variants depend on your vocabulary file. Hence, if there is only 'n' gender, then you can not use 'f' or 'm' gender. 'a' value will return list with random genders.
output
- output format. Possible formats are 'set', 'array', 'object', or
OutputFormat.Set
OutputFormat.Array
OutputFormat.Object
format
- string output format. Possible values are 'lowercase', 'uppercase', 'capitalize', 'noformat', or
StringFormat.Lowercase
StringFormat.Uppercase
StringFormat.Capitalize
StringFormat.NoFormat
Note, don't forget to export enums with NVRNG:
let { NVRNG, OutputFormat, Genders, StringFormat } = require('nvrng');
if bad value is used, then getSet
will return error and set.
include
- array or set of values that would be injected to output set, default is empty set. For example, if include
is 3 unique strings long and
you generate 5 new strings, then output would be 5 + 3 = 8 strings long
exclude
- array or set of values that must be ommitted in output set, default is empty set
delimiter
- char to join random words, default is ' '
getOne({ gender = Genders.Any, exclude, delimiter = ' ', format = StringFormat.NoFormat }) => [err, string]
Returns one string. Same options as in getSet
(except include
and output
).
Returns array of keys available for uploaded vocabulary
const filename = __dirname + '/../examples/gender.json';
err = gen.upload(filename);
console.log(gen.getKeys()); //[ 'f', 'm', 'n' ]
Vocabulary is a json object which contains one or more objects ("spaces") with 1 to 3 different arrays. For example
{
"adjectives": {
"n": ["red", "orange", "yellow", "green", "blue", "dark blue", "purple"]
},
"nouns": {
"n": ["cat", "dog", "cow", "horse", "mouse", "duck", "elephant"]
}
}
or
{
"adjectives": {
"n": ["red", "orange", "yellow", "green", "blue", "dark blue", "purple"],
"f": ["red", "orange", "yellow", "green", "blue", "dark blue", "purple"],
"m": ["red", "orange", "yellow", "green", "blue", "dark blue", "purple"]
},
"nouns": {
"n": ["artist", "heir", "server", "chicken", "spouse", "horse", "person"],
"f": ["actress", "princess", "waitress", "hen", "wife", "mare", "woman"],
"m": ["actor", "prince", "waiter", "rooster", "husband", "stallion", "man"]
}
}
let { NVRNG, OutputFormat, Genders, StringFormat } = require('../index.js');
let gen = new NVRNG();
gen.upload(__dirname + '/../examples/simplest4.json');
let [err, set] = gen.getSet(3, { delimiter: '-', format: StringFormat.Capitalize });
console.log(err);
set.forEach(item => console.log(item));
let newname;
[err, newname] = gen.getOne({ delimiter: '-', format: StringFormat.Capitalize, exclude: set });
console.log(newname);
Output is
null
Dark-blue-Mouse-With-Notebook
Purple-Dog-With-Gun
Green-Elephant-With-Gun
Purple-Dog-With-Car
Clone repository and run
npm run test
npm run cover
FAQs
Not very random temporary name generator
The npm package nvrng receives a total of 2 weekly downloads. As such, nvrng popularity was classified as not popular.
We found that nvrng 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.