Skip to content

Commit

Permalink
make xsslint handle import statements
Browse files Browse the repository at this point in the history
do our own babylon parse and pass the ast into xsslint

test plan:
* use `import` in your jsx
* :cat_dance:

Change-Id: I6ea240e82143f44ea360240ada492e6cbbdaa853
Reviewed-on: https://gerrit.instructure.com/104107
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <[email protected]>
Product-Review: Landon Wilkins <[email protected]>
QA-Review: Landon Wilkins <[email protected]>
  • Loading branch information
jenseng committed Mar 6, 2017
1 parent 6deef12 commit 0634e4d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions script/xsslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const globby = require("gglobby");
const fs = require("fs");
const CoffeeScript = require("coffee-script");
const glob = require("glob");
const babylon = require("babylon");

XSSLint.configure({
"xssable.receiver.whitelist": ["formData"],
Expand Down Expand Up @@ -97,10 +98,11 @@ allPaths.forEach(function({paths, glob, defaultIgnores = [], transform}) {
console.log(`Checking ${path} (${files.length} files) for potential XSS vulnerabilities...`);

files.forEach(function(file) {
let pathOrOptions = file;
if (transform) pathOrOptions = {source: transform(fs.readFileSync(file).toString())};
let source = fs.readFileSync(file).toString();
if (transform) source = transform(source);
source = babylon.parse(source, { plugins: ["jsx", "classProperties", "objectRestSpread"], sourceType: "module" });

const warnings = XSSLint.run(pathOrOptions);
const warnings = XSSLint.run({source});
warningCount += warnings.length;
warnings.forEach(({line, method}) => {
console.error(`${path}/${file}:${line}: possibly XSS-able ${methodDescription(method)}`);
Expand Down

0 comments on commit 0634e4d

Please sign in to comment.