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;
}
import * as color from 'color'
import _ from 'lodash'
import * as thirdPartyWeb from 'third-party-web'
import * as d3plus from 'd3plus/build/d3plus.js'
const categories = _.uniq(thirdPartyWeb.entities.map(e => e.categories[0])).map((category, idx) => {
return {
id: category,
displayName: _.startCase(category),
color: color(`hsl(175, 75%, ${15 + idx * 5}%)`)
.rgb()
.string(),
}
})
const data = thirdPartyWeb.entities
.filter(entity => entity.totalOccurrences)
.sort((a, b) => b.totalExecutionTime - a.totalExecutionTime)
.slice(0, 100)
.sort((a, b) => a.name.localeCompare(b.name))
.map(entity => {
const category = categories.find(c => c.id === entity.categories[0])
return {
...entity,
id: entity.name,
category: category.displayName,
color: category.color,
}
})
const tooltipConfig = {
import React, {useEffect, useState, useRef} from 'react'
import PropTypes from 'prop-types'
import * as color from 'color'
import _ from 'lodash'
import * as thirdPartyWeb from 'third-party-web'
import * as d3plus from 'd3plus/build/d3plus.js'
const categories = _.uniq(thirdPartyWeb.entities.map(e => e.categories[0])).map((category, idx) => {
return {
id: category,
displayName: _.startCase(category),
color: color(`hsl(175, 75%, ${15 + idx * 5}%)`)
.rgb()
.string(),
}
})
const data = thirdPartyWeb.entities
.filter(entity => entity.totalOccurrences)
.sort((a, b) => b.totalExecutionTime - a.totalExecutionTime)
.slice(0, 100)
.sort((a, b) => a.name.localeCompare(b.name))
.map(entity => {
const category = categories.find(c => c.id === entity.categories[0])
static getEntitySafe(url) {
try {
return thirdPartyWeb.getEntity(url);
} catch (_) {
return undefined;
}
}