Giter Site home page Giter Site logo

addons-linter's People

Contributors

ag12r avatar andy-moz avatar dependabot[bot] avatar diox avatar entequak avatar fjoerfoks avatar greenkeeper[bot] avatar greenkeeperio-bot avatar itielman avatar jasnapaka avatar jimsp472000 avatar karm46 avatar marceloghelman avatar meskobalazs avatar milupo avatar mozilla-pontoon avatar mstriemer avatar muffinresearch avatar nolski avatar petercpg avatar ravneette avatar renovate-bot avatar renovate[bot] avatar rpl avatar selimsum avatar theochevalier avatar tofumatt avatar ujdhesa avatar wagnerand avatar willdurand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

addons-linter's Issues

Try htmlparser2 in RDF

htmlparser2 has better test coverage and seems more robust, so let's try to use it for RDF parsing instead of XMLDom.

Get ESLint to ignore /*eslint*/ comments

We need a way to either configure ESLint not to respect comments inside the code (usually in /* eslint nocheckforbadthing */-type comments).

If that's not possible, we'll need to strip out all comments when we parse code or something so the code can't tell the validator to back off ๐Ÿ˜„

Add text output processing.

We've got a start on outputting JSON - we need to add something to output the rules in a nice way as just text with nice colours assuming boring is false.

Deal with known JS libs

  • Check against known library hashes #383
  • Build our own hash list #384
  • Hook up Dispensary inside the linter

We need a way to skip over validation of known safe libs.

Move RDF rules into their own files

Related to #78, we should keep our rules in single files (similarly to what we do with ESLint rules) so they are easy to find and we don't have massive validator classes full of methods.

I'll move the RDF ones that exist already.

Define list of layout tests

The list of rules covers a bunch of tests that relate to files and how they're laid-out in the zip (xpi). We should write a list of those and start implementing them.

Defend against zip-bombs

For use via amo it's important we can blow-up gracefully if a zip bomb is submitted for validation.

Port tests

This will need breaking down further.

Detect addon-type

We need to know what addon-type we are dealing with as some validation tests are type-specific.

Decide on CSS parser for CSS processing rules.

Let's investigate what's state of the art in CSS parsing for Node. Then the next step will be to prototype out something simple and double check the chosen solutions looks fit for purpose.

Plan error handling

  • How should errors be handled?
  • How does the current validator expose various classes of error.

Put scanners/validators in their own directory

Just a minor thought, but as we add separate scanners (CSS, JS, RDF), the root of src/ is getting crowded. It would be easier to see what files did what if they were grouped (ie put all scanners in a scanners/ folder.

So instead of:

- src/
  - messages/
  - rules/
  - cli.js
  - css.js
  - javascript.js
  - rdf.js
  [etc.]

we can do:

- src/
  - messages/
  - scanners/
    - css.js
    - javascript.js
    - rdf.js
  - rules/
  - cli.js
  [etc.]

Add binary file tests

There are a set of tests that read the first few bytes of a file to identify them.

Make tests less noisy

Output from the tests is a bit noisy because we have console.log calls inside the code path that aren't silenced for tests.

screenshot 2015-10-09 21 00 55

Realistically, we probably want an validator.config.output option that is nothing or null.

Not sure when the CLI would ever want it, but it's what we want for the tests and we should already have the infra for it via that config.output option.

Other console.log should be silenced by this option. We probably just want to use our own log method everywhere.

Quick review of existing structure before we move onto adding more rules.

Before we go too far and add lots of rules I think it might be worth taking a step back briefly to look at what we have in terms of parsers and how they are integrated and make sure we are being as consistent in our approach as possible for each parser so far.

Kind of questions I have in mind are:

  • Use of rule functions vs class methods.
  • How are the message objects setup and passed back to the collector.

We can then file issues for any things that need to be changed if necessary.

Add message collector

This classes job is to collect up warnings, errors and notice objects and provide an API for doing so.

Plan architecture for processing files.

Starting with the xpi:

  • How with the various parsers and processors be glued together.
  • We should look to ensure the integrity of the scans (making sure all files are processed).

Add JSCS to tests

I've already made a few silly style nitpicks/raised some style questions in #20.

Shall we add some JS Style checks to the tests so we don't quibble over how we do long strings, line lengths, etc.?

It's worked well for localForage. Keeps styles in-line on the more fluid things eslint won't check.

Test to make sure number of rules match rules that are run in scan()

Write a test that checks the number of rule files in rules/$VALIDATOR_TYPE (eg: all files sans index.js) and checks how many rules are run in $VALIDATOR_TYPE.scan(). We can test this for at least the HTML and RDF checkers now, and could check the length of the ESLint rule list as well.

This makes sure of two things:

  1. All rule files contain exactly one rule.
  2. All rules are being exported/imported and run properly.

Test for obsfucation/identify obsfucation attempts

Currently we test for identifiers (#44), as the previous validator does. This leaves us open to obsfucation of restricted identifiers, eg:

var m = "m";
var o = "o";
var z = "z";
var idb = "IndexedDB";
var tricksterVariable = m + o + z + idb;
// Bad!
var myDatabase = window[tricksterVariable];

We need to statically analyse variable paths and find out their eventual values if they're used to dynamically call a function.

Failing this: we need to identify heuristics that we can use to say that obfuscation appears likely and alert the reviewer for closer manual inspection.

Allow CLI parser to be run from a (Celery) queue

@andymckay, @mstriemer, and I talked about #49. What we actually need is to use the existing https://github.com/mozilla/olympia Django app as our API server (having multiple front ends is needless) to handle the Validator's API (eg: upload a file for validation -> get an ID -> query said ID for its validation status).

Do need to get the validator to run as a Celery task that can get data from the Django API (put into celery) and then send data back.

The API would return a status of the validation (processing/complete) with a series of messages/warnings/errors (as JSON, which the validator can already easily produce being a JS app).

Refactor HTML/RDF scanner classes

Looking at the HTML and RDF scanner classes, they're nearly the same now that I've started on #79. Might be nice to define a "markup" scanner class and have them simply extend it (essentially the only difference is the parser used and the rules they're using).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.