Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (count <= 5) {
cooked.push({
name: vuln,
pluginId: raw[vuln]['id'],
count: raw[vuln]['data'][0],
severity: raw[vuln]['severity']
});
}
}
web.vulnCache(cooked);
console.log('PVS: Updated Top Vulnerabilities Cache');
web.io.emit('topVulns', cooked);
// Initiate a logout from the API. We need to make sure to do
// this so that we don't keep sessions running to time out
httpreq.post(host + '/logout', {parameters: {json: 1, token: token}})
}
})
}
rawgithub(url, function(err, data){
// => returns the file contents as a string
if(err){console.log(err);console.log(url);process.exit(0);}
console.log("Github ver:"+JSON.parse(data).app);
console.log("Local ver:"+currentver.app);
rimraf.sync(path.resolve(tmp_path,"./"+reponame));
if(fs.existsSync(path.resolve(__dirname,"./update.zip"))) fs.unlinkSync(path.resolve(__dirname, "./update.zip"));
if(parseFloat(JSON.parse(data).app)==parseFloat(currentver.app)) {
fs.writeFileSync(path.resolve(__dirname,"./update.track"),"updated");
process.exit(0);
}
else
{
fs.writeFileSync(path.resolve(__dirname,"./update.track"),"downloading");
httpreq.download(
urlzip,
path.resolve(__dirname,"./update.zip")
, function (err, progress){
if (err) return console.log(err);
console.log(progress);
}, function (err, res){
if (err) return console.log(err);
console.log(res);
fs.createReadStream(path.resolve(__dirname + "/update.zip")).pipe(unzip.Extract({ path:tmp_path }))
.on('finish', function () {
console.log('chmoding...');
try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_macx32'));}catch(err){;};
try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_x32'));}catch(err){;};
try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_x32.exe'));}catch(err){;};
try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_x64'));}catch(err){;};
function pvsData() {
var token = null;
// Initiate the login to the PVS API.
httpreq.post(host + '/login', {
parameters: {
login: config.Monitoring.PVS.username,
password: config.Monitoring.PVS.password,
json: 1
}
}, function(err, res) {
if (err) {
console.log('PVS: ' + err);
} else {
// As it appears that we were able to login, lets to ahead
// and set the token variable.
var data = JSON.parse(res.body);
token = data['reply']['contents']['token'];
// Here what we'll be interfacing to is the top hosts
// dashboard item. Since the New PVS WebUI has formatted
db.Image.findOne({where: {url: url_nq}}).then(function(image){
if (image) {
updateImage(image, url_nq);
} else {
// As we havent seen the image in the database, we will
// then download the file, compute the MD5 hash, then
// store the file with the MD5 hash as the filename.
httpreq.get(url, {binary: true}, function(err, res){
if (err) {
console.log('NGrep: download error - ' + err);
} else {
var hash = md5(res.body);
var filename = hash + '.' + ext;
// Attempt to write the file...
fs.writeFile(config.AppServer.images + '/' + filename, res.body, function(err) {
if (err) {
console.log('NGrep: file save error - ' + err);
} else {
// Creating a new image object and inserting it into the database...
db.Image.findOrCreate({where: {hash: hash},
defaults: {
hash: hash,
filename: filename,
url: url_nq,
update(callback) {
httpreq.get(this.url, {binary: true}, (err, res) => {
if (err) {
Homey.log(err);
return;
}
// Ignore first 4 bits
const buffer = res.body.slice(4);
const buffers = [];
// Split buffers on 9x 00 followed by 04
// Not the nicest way to do this probably, ideas welcome
let lastEnd = 0;
for (let i = 10; i < buffer.length; i++) {
let split = true;
for (let x = i - 10; x < i - 1; x++) {
}).spread(function(image, created) {
if (created && config.Monitoring.Driftnet.nsfw_filter) {
httpreq.post(config.NSFW.address + '/score', {
parameters: {
path: 'file:///images/' + image.filename
}
}, function(err, res) {
if (err) {
console.log('Driftnet: ' + err);
} else {
if (res.statusCode == 200){
data = JSON.parse(res.body)
if (!data['error']){
image.updateAttributes({
nsfw: data['score']
}).then(function(result) {
console.log('Driftnet: ' + image.filename + ' created from ' + image.url + ' with nsfw score of ' + image.nsfw)
io.emit('images', image)
})
}).spread(function(image, created){
if (created && config.Monitoring.NGrep.nsfw_filter) {
httpreq.post(config.NSFW.address + '/score', {
parameters: {
path: 'file:///images/' + filename
}
}, function(err, res) {
if (err) {
console.log('NGrep: ' + err);
} else {
if (res.statusCode == 200){
data = JSON.parse(res.body)
if (!data['error']){
image.updateAttributes({
nsfw: data['score']
}).then(function(result) {
console.log('NGrep: ' + image.filename + ' created from ' + image.url + ' with nsfw score of ' + image.nsfw)
io.emit('images', image)
})
fontReferences.forEach(function (fontReference) {
var reference = fontReference.substring(4, fontReference.length - 1);
var fontName = reference.substring(fontReference.lastIndexOf("/"));
cssString = cssString.replace(reference, fontName);
httpreq.get(reference, {binary: true}, function (err, response) {
if (err) {
console.log(err);
} else {
files.push({
name:fontName,
file:response.body
});
}
if(files.length === fontReferences.length){
completion();
}
});
});
}
function(req, res) {
var errors = [];
var params, rep;
var requestUrl = 'http://fonts.googleapis.com' + '/css'+req.originalUrl.substring(req.originalUrl.indexOf('?'));
var indexOfFamilySeperator = req.originalUrl.indexOf(":");
if(indexOfFamilySeperator<0){
indexOfFamilySeperator = req.originalUrl.length;
}
var requestedFontName = req.originalUrl.substring(req.originalUrl.indexOf('=')+1, indexOfFamilySeperator);
requestedFontName = requestedFontName.replace(/\+/g, "");
requestedFontName = requestedFontName.charAt(0).toLocaleLowerCase()+requestedFontName.substr(1);
var requestedPackageName = req.originalUrl.substring(req.originalUrl.lastIndexOf("/")+1, req.originalUrl.indexOf('?'));
httpreq.get(requestUrl, function (err, response){
if (err){
console.log(err);
res.send(500, {error:err});
}else {
if (response.statusCode !== 200) {
res.status(response.statusCode).send(response.body);
return
}
var cssString = response.body;
var files = [];
var completion = function(){
res.setHeader('Content-Type', 'application/octet-stream');
res.setHeader('Content-disposition', 'attachment; filename='+requestedFontName+'.zip');
return new Promise((resolve) => {
http.get(this.getUpdatesJsonUrl(), (err, res) => {
if (err) {
console.warn(
`Could not get updates.json. ${IGNORE_WARNING} `
+ `An error occurred ${err.message}`
);
resolve(empty);
return;
}
if (res.statusCode !== 200) {
console.warn(
`Could not get updates.json. ${IGNORE_WARNING} A hosting `
+ `response is:\n${res.statusCode} ${res.body}`
);
resolve(empty);
return;