Skip to content

Instantly share code, notes, and snippets.

@hitGovernor
Last active December 21, 2019 16:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitGovernor/e467e906c705edcd9544577a3806b52a to your computer and use it in GitHub Desktop.
Save hitGovernor/e467e906c705edcd9544577a3806b52a to your computer and use it in GitHub Desktop.
Consoles out a table of all resources blocked by Ensighten's Privacy Gateway
if (typeof (gateway) != "undefined") {
/**
* consoles out the provided array using the provided status as a header
* @param status {string}
* @param output {array}
*/
function gwLogger(status, output) {
if (output.length > 0) {
console.log(status + " REQUESTS:");
console.table(output);
} else {
console.log(status + " REQUESTS:\n-- none");
};
};
var blocked = [],
notBlocked = [];
// loop through history object, separating out blocked and non-blocked resources
for (var id in gateway.history.complete) {
var item = {
// id: id,
destination: gateway.history.complete[id].request.destination,
type: gateway.history.complete[id].request.type,
source: gateway.history.complete[id].request.source,
status: gateway.history.complete[id].request.status,
reasons: JSON.stringify(gateway.history.complete[id].request.reasons, null, 0),
list: JSON.stringify(gateway.history.complete[id].request.list, null, 0)
}
if (item.status === "blocked") {
blocked.push(item);
} else {
notBlocked.push(item);
}
}
// display findings in console
gwLogger("BLOCKED", blocked);
gwLogger("OTHER (ALLOWED)", notBlocked);
} else {
console.log("Ensighten's Privacy gateway object was not detected.");
}
@hitGovernor
Copy link
Author

Updated gist to reference gateway.history.complete object, reducing code by half. Output now includes significantly more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment