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

spofcheck

v0.1.7

Published

A CLI tool for detecting frontend SPOF

Downloads

30

Readme

NPM

Build Status ##SPOFCheck - Fighting Frontend SPOF at its root

With the increase in 3rd party widgets and modernization of web applications, Frontend Single Point Of Failure (SPOF) has become a critical focus point. Thanks to Steve Souders for his initial research on this topic, we now have a list of common patterns which cause SPOF. The awareness of Frontend SPOF has also increased tremendously among engineers, thanks to some of the recent blogs and articles emphasizing the importance of it.

There are already a bunch of utilities and plugins out there which can detect possible SPOF vulnerabilities in a web application. The most notable ones being webpagetest.org, SPOF-O-Matic chrome plugin and YSlow 3PO extension. At eBay we wanted to detect SPOF at a very early stage, during the development cycle itself. This means an additional hook in our automated testing pipeline. The solution resulted in creating a simple tool which works on our test URLs and produces SPOF alerts. The tool is SPOFCheck.

SPOFCheck is a Command Line Interface (CLI) built in Node.js to detect possible Frontend SPOF for web pages. The output is generated in an XML format that can be consumed and reported by CI jobs. The tool is integrated with our secondary jobs, which run daily automation on a testing server where a development branch is deployed. In case of a SPOF alert, engineers are notified and they act on it accordingly. This process ensures that SPOFs are contained within the development cycle and do not sneak into staging or production.

Thanks to github projects spof-o-matic and 3po, a lot of the code logic has been re-used here. The design and packaging of the tool is based on csslint, thanks to Nicholas Zakas and Nicole Sullivan.

##The command line interface SPOFCheck provides a simple command line interface and runs on Node.js

To install SPOFCheck run the following

$ npm install -g spofcheck

To run SPOFCheck, use the following format

spofcheck [options]* [urls]*

Options
--help | -h                       		     Displays this information.
--format=<format> | -f <format>   		     Indicate which format [junit-xml | spof-xml | text] to use for output.
--outputdir=<dir> | -o <dir>      		     Outputs the spof results to this directory.
--rules=<rule[,rule]+> | -r <rule[,rule]+>   Indicate which rules to include.
--print | -p                      		     Outputs the results in console, instead of saving to a file.
--quiet | -q                      		     Keeps the console clear from logging.

Example

$ spofcheck -f junit-xml -o /tests www.ebay.com www.amazon.com

##Rules SPOFCheck by default runs with 5 rules (checks). The rules are maintained in the rules.js file. New rules can be easily added by pushing entries to the rules array or calling the spof api registerRules. The default rules come from Souders's original list outlined below

  1. 3rdparty-scripts - Always load 3rd party external scripts asyncronously in a non-blocking pattern
  2. application-js - Load application JS in a non-blocking pattern or towards the end of page
  3. fontface-stylesheet - Try to inline @font-face style. Also make the font files compressed and cacheable
  4. fontface-inline - Make sure the fonts files are compressed, cached and small in size
  5. fontface-inline-precede-script-IE - Make sure inlined @font-face is not preceded by a SCRIPT tag, causes SPOF in IE

##Output SPOFCheck creates a file and writes results in one of the below formats

  • junit-xml - a format most CI servers can parse, the default format
  • spof-xml - an XML format that can be consumed by other utilities
  • text - a textual representation of the results

The format can be specified using the --format or -f option. For just printing results i.e. no file creation, use the --print or -p option

##Programmable API SPOFCheck also provides a programmable API to be used along with build scripts like grunt. The API is called run which takes in a lits of URLs along with options (same options mentioned above) and returns a promise. The promise is either fulfilled with the SPOF analysis results or rejected with an error message.

var spofcheck = require('spofcheck');
spofcheck.run(['www.google.com', 'www.bing.com']).then(function(results){	
	console.log(JSON.stringify(results));
},function(errorObject) {
	console.log(errorObject.message);
});

The format of the results object is shown below

[  
   {  
      "messages":[  
         {  
            "type":"warning",
            "message":"WARNING: Possible SPOF attack in IE due to inline @font-face preceded by a SCRIPT tag",
            "entity":"NA",
            "score":"NA",
            "rule":{  
               "id":"fontface-inline-precede-script-IE",
               "name":"Inline @font-face precede Script tag IE issue",
               "desc":"Make sure inlined @font-face is not preceded by a SCRIPT tag, causes SPOF in IE"
            }
         }
      ],
      "url":"http://www.bing.com"
   },
   {  
      "messages":[  
         {  
            "type":"warning",
            "message":"WARNING: Possible SPOF attack in IE due to inline @font-face preceded by a SCRIPT tag",
            "entity":"NA",
            "score":"NA",
            "rule":{  
               "id":"fontface-inline-precede-script-IE",
               "name":"Inline @font-face precede Script tag IE issue",
               "desc":"Make sure inlined @font-face is not preceded by a SCRIPT tag, causes SPOF in IE"
            }
         }
      ],
      "url":"http://www.google.com"
   }
]

##Testing The entire test suite for both, the Command Line Interface and programmable API is available in the main test file spofcheck.js. For assertion the default Node.js assert module is used. To run the tests - clone the repo, install the package $ npm install and run

$ npm test

##Issues Have a bug or a feature request? Please open a new issue

##Authors Senthil Padmanabhan - github | twitter

##License Copyright (c) 2012 eBay Inc.

Released under the MIT License http://www.opensource.org/licenses/MIT