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.
Javascript easy string manipulation, file access, ascii conversions, statistics, json, and more ..
by @sha0coder
require('protos.js');
var users = [];
users.load('users.txt'); // arrays can load data
if (!users.has('Peter')) { // arrays can check content
users.push('Peter')
users.save('users.txt') // arrays can save data
}
if ('Peter'.in(users)) { // strings can also check if exists in arrays
'Peter is here'.log(); // strings can console.log
'some error'.err(); // same as console.error()
'John'.appendFile('users.txt') // strings can append to file
}
var str = 'test';
str.log(); // same as console.log(str);
str.save('file.txt');
str.save('file.txt', function() {
'async saved!'.log();
});
var str = ''.load('data.txt');
['a','b','c','d'].cut(1,3);
['a','b','c','d'].cut(1,-1); // -1 means last item (like python)
// STRING MANIPULATION MADE EASY (python style)
var el = 'hello'.cut(1,3);
var lo = 'hello'.cut(3,-1);
> 'hello'.cut(0,4).log();
'hell'
> '3'.toInt();
3
> 'a'.toInt().isNum();
false
// JSON FILES
var struct = {}.load('file.json'); // load json files into js object
struct.save('file.json'); // save js object into json file
struct.save('file.json', function() { // save async
'saved'.log();
});
struct.dir() // same as console.dir(struct);
// FUZZY HASHING thanks to ctph.js
'hello'.compare('hell') // 50%
'hello'.compare('hello') // 100%
'hello'.compare('abcd') // 0%
var hash = 'hello'.fuzzyHash();
// calling a function on all items
objects.call('method',[params]);
// ARRAY USEFUL METHODS
> ['cats','dogs','birds'].choice()
'dogs'
> [3, 1, 2, 3].unique()
[ 3, 1, 2 ]
// SHELL EXECUTION
'ls'.exec(function(stdout,stderr) {
stdout.log();
stderr.err();
});
// STATISTICS
> [1,3,2].max()
3
> [1,3,2].min()
1
> [1,3,2].average()
2
> var n = [];
> n.fillNums(1,10);
> n.cut(0,1)
[ 1 ]
> n.cut(-3,-1) // -1 means last item
[ 9, 10 ]
> var n = 0/0;
> n.isNum();
false
// INTROSPECT
> var a = {b:1};
> a.dir();
{ b: 1 }
> var a = [1,2,3];
> a.dir();
[ 1, 2, 3 ]
// ASCII chr()
> (0x41).chr();
'A'
> 'HELLO'.chr();
[ 72, 69, 76, 76, 79 ]
> [72,69,76,76,79].chr()
'HELLO'
// ITERATION knowing the index
['dog','cat','bird'].each(function(i,pet) {
pet.log();
});
// BOOLEANS callback based conditions
(cmd == 'install').call(doInstall); // boleans can call if true
(1 == 2).call(ghostbusters);
true.call(function() {
'always here'.log();
});
false.call(ghostbusters)
'help'.in(process.args).call(doHelp);
FAQs
Tons of prototypes for an easier life
We found that protos.js 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.