const print = (toPrint) => {
const line = document.createElement('pre');
line.textContent = JSON.stringify(toPrint,null, 2);
document.getElementById('results').appendChild(line);
}
console.log = print;
// RESEARCH ON THIS TYPE OF DATA
// What is IOC? Indicator of compromise or IOC is a forensic term that refers to the evidence on a device that points out to a security breach
// example json object
const intelligence = [
{
ioc: "1.2.3.4",
threat: "low",
countryCode: "us",
seenBy: ["usSS", "whiteHatsAnon"],
lastSeen: 1650309845083
},{
ioc: "1.2.3.5",
threat: "high",
countryCode: "us",
seenBy: ["usSS"],
lastSeen: 1650307825088
},{
ioc: "gougle.com",
threat: "high",
regionName: "utah",
countryCode: "ca",
seenBy: ["usSS", "whiteHatsAnon", "ruWatch", "privateInc", "angiesList"],
lastSeen: 1650609845087
},{
ioc: "goople.com",
threat: "high",
countryCode: "ru",
seenBy: ["usSS", "whiteHatsAnon", "angiesList"],
lastSeen: 1650109815283
},
];
// intialize data
const data = {};
// get the elements in the json
elements = Object.keys(intelligence[0])
// adds the keys to the object
elements.forEach((i) => {
data[i] = {};
});
// counts all the types of variables for each key
intelligence.forEach((el) => {
elements.forEach((key) => {
if (key == 'lastSeen') {
var date = new Date(el[key] * 1000);
el[key] = date.toUTCString();
}
//if the object is not a object type
if (typeof el[key] != "object") {
// if the element hasn't shown up before
if(data[key][el[key]] == "undefined"){
data[key][el[key]] = 1;
}
// adds to existing element
else {
data[key][el[key]] = data[key][el[key]] ? (data[key][el[key]] += 1) : 1
}
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.