Public
Edited
Aug 10, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = (() => {
const data1 = rawData.slice(1).filter(x => x).map((row, rowIdx) => {
const rowData = row.reduce((all, cell, cellIdx) => {
const newAll = { ...all }
const key = rawData[0][cellIdx];
let value = cell;
if (key === 'data') {
value = eval(value)
value
.map((x) => Object.entries(x)[0] )
.forEach((entry) => {
let val = entry[1];
try {
val = JSON.parse(val);
} catch (e) {
try {
val = eval(val);
} catch (e) {}
}
let pKey = dataParts[entry[0]]
if (pKey === 'maliciousPackages' || pKey === 'userLocation') {
Object.entries(val).forEach(entry => {
if (entry[0] === 'll') {
newAll['userLocation_latitude'] = entry[1][0];
newAll['userLocation_longitude'] = entry[1][1];
} else {
newAll[`${pKey}_${entry[0]}`] = entry[1];
}
})
} else {
newAll[pKey] = val;
}
});
value = null;
} else if (key === 'applicationName') {
try {
value = JSON.parse(value);
} catch (e) {
try {
value = JSON.parse(value.replace(/'/gi, '"'))
} catch (e) {
try {
value = eval(value)
} catch (e) {}
}
}
if (typeof value !== 'string') {
newAll.applicationName = value.Application;
newAll.applicationStatus = value.Status;
value = null;
}
} else {
value = cell.replace(/^"(.*)"$/, '$1');
if (!isNaN(value)) {
value = +value;
}
}
if (value == null) return newAll;
newAll[key] = value;
return newAll;
}, {})
return rowData;
});

const data2 = data1.map(x => ({
timestamp: x.timestamp,
// location: {
country: x.userLocation_country,
region: x.userLocation_region,
city: x.userLocation_city,
timezone: x.userLocation_timezone,
lat: x.userLocation_latitude,
lon: x.userLocation_longitude,
// },
// app: {
appId: x.token,
appArxanId: x.uniqueAppInstance,
appName: x.applicationName,
appStatus: x.applicationStatus,
osName: x.osName,
osVersion: x.osVersion,
// },
// tamper: {
guardId: x.guardId,
guardType: x.guardType,
guardTypeName: x.guardTypeName,
tamper: x.activity,
tamperName: x.activityName,
tamperIP: x.IP,
maliciousPackagesName: x.maliciousPackages_packageName,
maliciousPackagesThreatLevel: x.maliciousPackages_threatLevel,
// }
}) );

return data2;
})()
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more