Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
processMessage(message, queue) {
const make = this.make;
const thirdPartyAssetsByCategory = {};
const toolsByCategory = {};
const possibileMissedThirdPartyDomains = [];
if (message.type === 'pagexray.run') {
const firstPartyRegEx = message.data.firstPartyRegEx;
for (let d of Object.keys(message.data.domains)) {
const entity = d.indexOf('localhost') > -1 ? undefined : getEntity(d);
if (entity !== undefined) {
// Here is a match
} else {
if (!d.match(firstPartyRegEx)) {
possibileMissedThirdPartyDomains.push(d);
}
}
}
const byCategory = {};
this.groups[message.url] = message.group;
const company =
message.url.indexOf('localhost') > -1
? undefined
: getEntity(message.url);
let totalThirdPartyRequests = 0;
for (let asset of message.data.assets) {
possibileMissedThirdPartyDomains.push(d);
}
}
}
const byCategory = {};
this.groups[message.url] = message.group;
const company =
message.url.indexOf('localhost') > -1
? undefined
: getEntity(message.url);
let totalThirdPartyRequests = 0;
for (let asset of message.data.assets) {
const entity =
asset.url.indexOf('localhost') > -1
? undefined
: getEntity(asset.url);
if (entity !== undefined) {
if (company && company.name === entity.name) {
// Testing comnpanies that themselves are a third party gives a high third party score
// so we should remove the ones.
continue;
}
totalThirdPartyRequests++;
if (
entity.name.indexOf('Google') > -1 ||
entity.name.indexOf('Facebook') > -1 ||
entity.name.indexOf('AMP') > -1 ||
entity.name.indexOf('YouTube') > -1
) {
if (!entity.categories.includes('survelliance')) {
entity.categories.push('survelliance');
}
for (let d of Object.keys(message.data.domains)) {
const entity = d.indexOf('localhost') > -1 ? undefined : getEntity(d);
if (entity !== undefined) {
// Here is a match
} else {
if (!d.match(firstPartyRegEx)) {
possibileMissedThirdPartyDomains.push(d);
}
}
}
const byCategory = {};
this.groups[message.url] = message.group;
const company =
message.url.indexOf('localhost') > -1
? undefined
: getEntity(message.url);
let totalThirdPartyRequests = 0;
for (let asset of message.data.assets) {
const entity =
asset.url.indexOf('localhost') > -1
? undefined
: getEntity(asset.url);
if (entity !== undefined) {
if (company && company.name === entity.name) {
// Testing comnpanies that themselves are a third party gives a high third party score
// so we should remove the ones.
continue;
}
totalThirdPartyRequests++;
if (
entity.name.indexOf('Google') > -1 ||
entity.name.indexOf('Facebook') > -1 ||
module.exports.getThirdParty = function(page) {
const toolsByCategory = {};
const offending = [];
const byCategory = {};
let thirdPartyTransferSizeBytes = 0;
const thirdPartyAssetsByCategory = {};
const company =
page && page.url.indexOf('localhost') > -1
? undefined
: getEntity(page.url);
let totalThirdPartyRequests = 0;
for (let asset of page.assets) {
const entity =
asset && asset.url.indexOf('localhost') > -1
? undefined
: getEntity(asset.url);
if (entity !== undefined) {
if (company && company.name === entity.name) {
// Testing comnpanies that themselves are a third party gives a high third party score
// so we should remove the ones.
continue;
}
totalThirdPartyRequests++;
if (asset.transferSize) {
thirdPartyTransferSizeBytes += asset.transferSize;
}
if (
entity.name.indexOf('Google') > -1 ||
entity.name.indexOf('Facebook') > -1 ||
entity.name.indexOf('AMP') > -1 ||
entity.name.indexOf('YouTube') > -1
) {
if (!asset.url.match(firstPartyRegEx)) {
if (byCategory['unknown']) {
byCategory['unknown'] = byCategory['unknown'] + 1;
} else {
byCategory['unknown'] = 1;
}
}
}
}
const cpuPerTool = {};
if (message.data.cpu && message.data.cpu.urls) {
for (let ent of message.data.cpu.urls) {
// Seen errors like "Unable to find domain in "about:blank"
if (ent.url && ent.url.startsWith('http')) {
let entity = getEntity(ent.url);
// fallback to domain
if (!entity) {
const hostname = ent.url.startsWith('http')
? urlParser.parse(ent.url).hostname
: ent.url;
entity = {
name: hostname
};
}
if (cpuPerTool[entity.name]) {
cpuPerTool[entity.name] += ent.value;
} else {
cpuPerTool[entity.name] = ent.value;
}
}
}
module.exports.getThirdParty = function(page) {
const toolsByCategory = {};
const offending = [];
const byCategory = {};
let thirdPartyTransferSizeBytes = 0;
const thirdPartyAssetsByCategory = {};
const company =
page && page.url.indexOf('localhost') > -1
? undefined
: getEntity(page.url);
let totalThirdPartyRequests = 0;
for (let asset of page.assets) {
const entity =
asset && asset.url.indexOf('localhost') > -1
? undefined
: getEntity(asset.url);
if (entity !== undefined) {
if (company && company.name === entity.name) {
// Testing comnpanies that themselves are a third party gives a high third party score
// so we should remove the ones.
continue;
}
totalThirdPartyRequests++;
if (asset.transferSize) {
thirdPartyTransferSizeBytes += asset.transferSize;
}