
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
json-images-saver
Advanced tools
Save to files all base64 images contained in the json
It can be easily integrated with the output of static site creator
"use strict";
var elixir = require('laravel-elixir');
require('laravel-elixir-pug');
var gulp = require('gulp');
elixir(function (mix) {
mix.jsonImagesSaver('data/**/*.json',()=>gulp.dest('out'),'json',{images_path:__dirname+'/public/img/data/', delete_files:true});
});
"use strict";
var elixir = require('laravel-elixir');
require('laravel-elixir-pug');
require('json-images-saver/elixir');
var fs = require('fs');
var gulp = require('gulp');
var through = require('through2');
var args = require('yargs').argv;
class JsonCollection{
constructor() {
this._list = [];
this.data = {};
}
set(name, json){
if(!(name in this._list))
this.add(name);
try {
this._list[name] = JSON.parse(json.toString('utf-8'));
}catch(e){
this._list[name] = json.toString('utf-8');
}
}
add(name){
var _this = this;
Object.defineProperty(this.data, name, { get: function() { return _this._list[name]} , set: function(value){}, enumerable: true, configurable: true});
}
}
function jsonPipe() {
return function () {
// Creating a stream through which each file will pass
var stream = through.obj(function (file, enc, cb) {
if (file.isNull()) {
// return empty file
return cb(null, file);
}
if (file.isBuffer()) {
let name = file.path.split('/'); //TODO checks
name = name[name.length - 1];
jsonCollection.set(name.substr(0, name.length - ('json'.length + 1)), file.contents);
return cb(null, file);
}
if (file.isStream()) {
return cb(new PluginError(PLUGIN_NAME, 'Not yet supported'));
}
});
stream.on('end', function () {
pugVars.locked = false;
gulp.start('pug');
});
return stream;
}
}
var jsonCollection = new JsonCollection();
var pugVars = {locked:true};
elixir(function (mix) {
mix.jsonImagesSaver('data/**/*.json',jsonPipe(),'json',{images_path:__dirname+'/public/img/data/', delete_files:true})
.pug({
locals: {
data: jsonCollection,
pugVars: pugVars
},
});
if(args._.indexOf('watch') != -1) {
setTimeout(()=> {
fs.writeFile(__dirname + '/data/test.json', '{"time":"' + new Date().toTimeString() + '"}', function () {
});
}, 1000);
}
});
FAQs
Save to files all base64 images contained in the json
The npm package json-images-saver receives a total of 29 weekly downloads. As such, json-images-saver popularity was classified as not popular.
We found that json-images-saver 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
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.