npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

insecurity

v3.1.0

Published

Test HTML, CSS, JS, etc. files for insecure URLs.

Downloads

7

Readme

Insecurity

Build Status

Analyze HTML, CSS, JS, etc. files for insecure URLs (http://) that might cause Mixed Content problems when serving a site over SSL.

Installation

npm install insecurity

Usage

All methods return an array of insecure urls found (or an empty array, if none are found).

insecurity.html(content[, options])

Checks the src and href attributes of <script>, <link>, and <iframe> tags.

content is the text content of an HTML document.

If the passive option is set to true, it will also check the src attributes of <img>, <audio>, and <video> tags.

If the styles option is set to true, it will also check the properties in the inline contents of <style> tags for insecure url() values.

If the scripts option is set to true, it will also check the inline contents of any JS <script> tags for string literals that include insecure URLs.

You can also supply an array of strings and or regular expressions as a whitelist option. URLs that contain those strings or matches those expressions will be skipped.

Returns an array of insecure urls with a url and a tag name.

URLs found in the inline content of a <script> tag will also have inline set to true.

URLs found in the inline content of a <script> tag will also have inline set to true and a property name.

var fs = require("fs"),
    insecurity = require("insecurity");

fs.readFile("something.html", "utf8", function(err, content){

  var problems = insecurity.html(content);

  /*
    [
      { tag: "link", url: "http://somethinginsecure.com/style.css" },
      { tag: "script", url: "http://somethinginsecure.com/script.js" }
    ]
  */

  problems = insecurity.html(content, { passive: true });

  /*
    [
      { tag: "link", url: "http://somethinginsecure.com/style.css" },
      { tag: "script", url: "http://somethinginsecure.com/script.js" },
      { tag: "img", url: "http://somethinginsecure.com/image.png" }
    ]
  */

  problems = insecurity.html(content, { passive: true, scripts: true, styles: true });

  /*
    [
      { tag: "link", url: "http://somethinginsecure.com/style.css" },
      { tag: "script", url: "http://somethinginsecure.com/script.js" },
      { tag: "img", url: "http://somethinginsecure.com/image.png" },
      { tag: "script", url: "http://somethinginsecure.com/inascript.html", inline: true },
      { tag: "style", url: "http://somethinginsecure.com/background-image.jpg", inline: true, property: "background" },
      { tag: "style", url: "http://somethinginsecure.com/Garamond.ttf", inline: true, property: "font-face" }
    ]
  */


});

insecurity.css(content[, options])

Checks all url() values of CSS properties for insecure URLs.

content is the text content of a CSS stylesheet.

Returns an array of insecure urls with a property, a url, and a line number. If the lineNumbers option is set to false, it will omit the line in the result.

You can also supply an array of strings and or regular expressions as a whitelist option. URLs that contain those strings or matches those expressions will be skipped.

If the quiet option is set to true, it will not throw parsing errors.

var fs = require("fs"),
    insecurity = require("insecurity");

fs.readFile("something.css", "utf8", function(err, content){

  var problems = insecurity.css(content);

  /*
    [
      { url: "http://somethinginsecure.com/img/background-image.png", property: "background-image", line: 10 },
      { url: "http://somethinginsecure.com/img/font.ttf", property: "src", line: 25 }
    ]
  */

});

insecurity.js(content, options)

Checks all strings in a piece of JavaScript for any insecure URL string literals.

content is the text content of a JS file.

Returns an array of insecure urls with a a url and a line number. If the lineNumbers option is set to false, it will omit the line in the result.

You can also supply an array of strings and or regular expressions as a whitelist option. URLs that contain those strings or matches those expressions will be skipped.

If the quiet option is set to true, it will not throw parsing errors.

var fs = require("fs"),
    insecurity = require("insecurity");

fs.readFile("something.js", "utf8", function(err, content){

  var problems = insecurity.js(content);

  /*
    [
      { url: "http://somethinginsecure.com/", line: 10 },
      { url: "http://somethingelseinsecure.com/", line: 25 }
    ]
  */

});

insecurity.text(content, options)

Check any text for insecure URL substrings.

content is the text content.

Returns an array of insecure urls with a a url and a line number. If the lineNumbers option is set to false, it will omit the line in the result.

You can also supply an array of strings and or regular expressions as a whitelist option. URLs that contain those strings or matches those expressions will be skipped.

var fs = require("fs"),
    insecurity = require("insecurity");

fs.readFile("something.csv", "utf8", function(err, content){

  var problems = insecurity.text(content);

  /*
    [
      { url: "http://somethinginsecure.com/", line: 10 },
      { url: "http://somethingelseinsecure.com/whatever.html", line: 25 }
    ]
  */

});