Created
April 11, 2014 02:35
-
-
Save pdehaan/10438005 to your computer and use it in GitHub Desktop.
Scan your Firefox bookmarks exported JSON for HTTPS bookmarks succeptable to heartbleed exploit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"); | |
var url = require("url"); | |
var heartbleed = require("heartbleed"); | |
var jsonselect = require("jsonselect"); | |
var Promise = require("promise"); | |
var readFile = Promise.denodeify(fs.readFile); | |
readFile("bookmarks.json", "utf8").then(JSON.parse).then(function (data) { | |
var httpsUris = uniqueUris(data).map(heartbleed); | |
Promise.all(httpsUris).then(function (results) { | |
results.filter(filterNoSafe).forEach(function (warning) { | |
console.log("[%s] %s -- %s", warning.status, warning.host, warning.error); | |
}); | |
}).then(null, console.error); | |
}, console.error); | |
function uniqueUris(data) { | |
var httpsUris = {}; | |
jsonselect.forEach(".uri", data, function (uri) { | |
uri = url.parse(uri); | |
if ((uri.protocol === "https:") && !httpsUris.hasOwnProperty(uri.hostname)) { | |
httpsUris[uri.hostname] = true; | |
} | |
}); | |
return Object.keys(httpsUris).sort(); | |
} | |
function filterNoSafe(result) { | |
return (result.code !== 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment