diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 12cb276..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "jetpack/addon-sdk"] - path = jetpack/addon-sdk - url = git://github.com/mozilla/addon-sdk.git diff --git a/MANIFEST.in b/MANIFEST.in index 46d3958..8bed6c7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,2 @@ include validator/testcases/hashes.txt -include validator/app_versions.json -include validator/testcases/jetpack_data.txt include validator/testcases/whitelist_hashes.txt diff --git a/README.rst b/README.rst index 12445b8..2efcc7d 100644 --- a/README.rst +++ b/README.rst @@ -1,10 +1,9 @@ -============================== - addons.mozilla.org Validator -============================== +=================================== + marketplace.mozilla.org Validator +=================================== -The AMO Validator is a tool designed to scan Mozilla add-on packages for -problems such as security vulnerabilities, exploits, spamware and badware, -and lots of other gunk. By using a combination of various techniques and +The Apps Validator is a tool designed to scan open web apps for +problems and invalid code. By using a combination of various techniques and detection mechanisms, the validator is capable of being both efficient as well as thorough. @@ -19,7 +18,6 @@ Python Libraries: - argparse - cssutils -- rdflib - fastchardet Python Libraries for Testing: @@ -86,12 +84,10 @@ your environment. Run the validator as follows :: - python addon-validator [-t ] [-o ] [-v] [--boring] [--selfhosted] [--determined] + python app-validator [-o ] [-v] [--boring] [--selfhosted] [--determined] The path to the XPI should point to an XPI file. --t The type that you expect your add-on to be detected as. The - list of types is listed below. -o The type of output to generate. Types are listed below. -v Enable verbose mode. Extra information will be displayed in verbose mode, namely notices (informational messages), @@ -105,44 +101,6 @@ The path to the XPI should point to an XPI file. tier has failed. Certain high-tiered tests may inadvertently fail when this option is enabled for badly malformed add-ons. ---target-appversion Accepts a JSON string containing an object whose keys - are GUIDs and values are lists of version strings. In the - targetApplication and compatibility tests, the add-on's - predefined ```` values will be - overridden if its GUIDs match thoes from the JSON. E.g.: - ``{"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": "5.*"}`` ---for-appversions Accepts a JSON string containing an object whose keys are - GUIDs and values are lists of version strings. If this - list is specified, non-inlinecompatibility tests will only - be run if they specifically target the applications and - veresions in this parameter. E.g.: - ``{"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": ["6.*"]}`` - - -Expected Type: -============== - -The expected type should be one of the following values: - -any (default) - Accepts any extension -extension - Accepts only extensions -theme - Accepts only themes -dictionary - Accepts only dictionaries -languagepack - Accepts only language packs -search - Accepts only OpenSearch XML files (unpackaged) -multi - Accepts only multi-item XPI packages - -Specifying an expected type will throw an error if the validator -does not detect that particular type when scanning. All addon type -detection mechanisms are used to make this determination. - Output Type: ============ @@ -180,16 +138,11 @@ sample document below. :: { - "detected_type": "extension", + "detected_type": "packaged_app", "errors": 2, "warnings": 1, "notices": 1, "success": false, - "compatibility_summary": { - "errors": 1, - "warnings": 0, - "notices": 0 - }, "ending_tier": 4, "message_tree": { "module": { @@ -223,7 +176,7 @@ sample document below. "message": "This is the error message text.", "description": ["Description of the error message.", "Additional description text"], - "file": ["chrome/foo.jar", "bar/zap.js"], + "file": "chrome/foo.bar", "line": 12, "column": 50, "context: [ @@ -231,18 +184,9 @@ sample document below. " an_error_is_somewhere_on_this_line.prototy.eval("whatever");", null ], - "compatibility_type": "error", - "for_appversions": { - "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": ["5.0a2", "6.0a1"] - }, "tier": 2 } - ], - "metadata": { - "name": "Best Add-on Evar", - "version": "9000", - "guid": "foo@bar.com" - } + ] } @@ -371,23 +315,6 @@ or, after setting the proper python path: :: nosetests -However, to turn run unit tests with code coverage, the appropriate -command would be: :: - - nosetests --with-coverage --cover-package=validator --cover-skip=validator.outputhandlers.,validator.main,validator.constants,validator.constants_local --cover-inclusive --cover-tests - -Note that in order to use the --cover-skip nose parameter, you must -install the included patch for nose's coverage.py plugin: :: - - extras/cover.py - -This file should overwrite the standard nose coverage plugin at the -appropriate location: :: - - ~/.virtualenvs/[virtual environment]/lib/pythonX.X/site-packages/nose/plugins/cover.py - /usr/lib/pythonX.X/site-packages/nose/plugins/cover.py - - ---------- Updating ---------- @@ -395,16 +322,6 @@ appropriate location: :: Some regular maintenance needs to be performed on the validator in order to make sure that the results are accurate. -App Versions -============ - -A list of Mozilla ```` values is stored in the -``validator/app_versions.json`` file. This must be updated to include the latest -application versions. This information can be found on AMO: - -https://addons.mozilla.org/en-US/firefox/pages/appversions/ - - JS Libraries ============ @@ -422,41 +339,3 @@ regenerated with each new library version. To update: :: To add new libraries to the mix, edit ``extras/jslibfetcher.py`` and add the version number to the appropriate tuple. - -Jetpack -======= - -In order to maintain Jetpack compatibility, the whitelist hashes need to be -regenerated with each successive Jetpack version. To rebuild the hash library, -simply run: :: - - cd jetpack - ./generate_jp_whitelist.sh - -That's it! - - -Language Packs -============== - -With every version of every app that's released, the language pack references -need to be updated. - -We now have an automated tool to ease this tedious process. It is currently -designed to work on OS X with the OS X versions of Mozilla applications, though -it could conceivably run on any \*NIX platform against the OS X application -packages. - -To run the tool, first create a new directory: ``extras/language_controls/`` - -Put the ``.app`` packages for each updated product into this directory. Once -this is ready, simply run: :: - - cd extras - python update_langpacks.py - -That should be it. Note that this tool will fail horribly if any of the teams -change the locations that the various language files are stored in. - -Also note that this tool should only be run against the en-US versions of these -applications. diff --git a/addon-validator b/app-validator similarity index 100% rename from addon-validator rename to app-validator diff --git a/validator/__init__.py b/appvalidator/__init__.py similarity index 100% rename from validator/__init__.py rename to appvalidator/__init__.py diff --git a/validator/app_versions.json b/appvalidator/app_versions.json similarity index 100% rename from validator/app_versions.json rename to appvalidator/app_versions.json diff --git a/validator/chromemanifest.py b/appvalidator/chromemanifest.py similarity index 100% rename from validator/chromemanifest.py rename to appvalidator/chromemanifest.py diff --git a/validator/compat.py b/appvalidator/compat.py similarity index 100% rename from validator/compat.py rename to appvalidator/compat.py diff --git a/validator/constants.py b/appvalidator/constants.py similarity index 100% rename from validator/constants.py rename to appvalidator/constants.py diff --git a/validator/contextgenerator.py b/appvalidator/contextgenerator.py similarity index 100% rename from validator/contextgenerator.py rename to appvalidator/contextgenerator.py diff --git a/validator/decorator.py b/appvalidator/decorator.py similarity index 100% rename from validator/decorator.py rename to appvalidator/decorator.py diff --git a/validator/errorbundler.py b/appvalidator/errorbundler.py similarity index 100% rename from validator/errorbundler.py rename to appvalidator/errorbundler.py diff --git a/validator/loader.py b/appvalidator/loader.py similarity index 100% rename from validator/loader.py rename to appvalidator/loader.py diff --git a/validator/main.py b/appvalidator/main.py similarity index 100% rename from validator/main.py rename to appvalidator/main.py diff --git a/validator/opensearch.py b/appvalidator/opensearch.py similarity index 100% rename from validator/opensearch.py rename to appvalidator/opensearch.py diff --git a/validator/outputhandlers/__init__.py b/appvalidator/outputhandlers/__init__.py similarity index 100% rename from validator/outputhandlers/__init__.py rename to appvalidator/outputhandlers/__init__.py diff --git a/validator/outputhandlers/shellcolors.py b/appvalidator/outputhandlers/shellcolors.py similarity index 100% rename from validator/outputhandlers/shellcolors.py rename to appvalidator/outputhandlers/shellcolors.py diff --git a/validator/rdf.py b/appvalidator/rdf.py similarity index 100% rename from validator/rdf.py rename to appvalidator/rdf.py diff --git a/validator/specprocessor.py b/appvalidator/specprocessor.py similarity index 100% rename from validator/specprocessor.py rename to appvalidator/specprocessor.py diff --git a/validator/specs/__init__.py b/appvalidator/specs/__init__.py similarity index 100% rename from validator/specs/__init__.py rename to appvalidator/specs/__init__.py diff --git a/validator/specs/webapps.py b/appvalidator/specs/webapps.py similarity index 100% rename from validator/specs/webapps.py rename to appvalidator/specs/webapps.py diff --git a/validator/submain.py b/appvalidator/submain.py similarity index 100% rename from validator/submain.py rename to appvalidator/submain.py diff --git a/validator/testcases/__init__.py b/appvalidator/testcases/__init__.py similarity index 100% rename from validator/testcases/__init__.py rename to appvalidator/testcases/__init__.py diff --git a/validator/testcases/chromemanifest.py b/appvalidator/testcases/chromemanifest.py similarity index 100% rename from validator/testcases/chromemanifest.py rename to appvalidator/testcases/chromemanifest.py diff --git a/validator/testcases/conduit.py b/appvalidator/testcases/conduit.py similarity index 100% rename from validator/testcases/conduit.py rename to appvalidator/testcases/conduit.py diff --git a/validator/testcases/content.py b/appvalidator/testcases/content.py similarity index 100% rename from validator/testcases/content.py rename to appvalidator/testcases/content.py diff --git a/validator/testcases/hashes.txt b/appvalidator/testcases/hashes.txt similarity index 100% rename from validator/testcases/hashes.txt rename to appvalidator/testcases/hashes.txt diff --git a/validator/testcases/installrdf.py b/appvalidator/testcases/installrdf.py similarity index 100% rename from validator/testcases/installrdf.py rename to appvalidator/testcases/installrdf.py diff --git a/validator/testcases/javascript/__init__.py b/appvalidator/testcases/javascript/__init__.py similarity index 100% rename from validator/testcases/javascript/__init__.py rename to appvalidator/testcases/javascript/__init__.py diff --git a/validator/testcases/javascript/actions.py b/appvalidator/testcases/javascript/actions.py similarity index 100% rename from validator/testcases/javascript/actions.py rename to appvalidator/testcases/javascript/actions.py diff --git a/validator/testcases/javascript/call_definitions.py b/appvalidator/testcases/javascript/call_definitions.py similarity index 100% rename from validator/testcases/javascript/call_definitions.py rename to appvalidator/testcases/javascript/call_definitions.py diff --git a/validator/testcases/javascript/entity_values.py b/appvalidator/testcases/javascript/entity_values.py similarity index 100% rename from validator/testcases/javascript/entity_values.py rename to appvalidator/testcases/javascript/entity_values.py diff --git a/validator/testcases/javascript/instanceactions.py b/appvalidator/testcases/javascript/instanceactions.py similarity index 100% rename from validator/testcases/javascript/instanceactions.py rename to appvalidator/testcases/javascript/instanceactions.py diff --git a/validator/testcases/javascript/instanceproperties.py b/appvalidator/testcases/javascript/instanceproperties.py similarity index 100% rename from validator/testcases/javascript/instanceproperties.py rename to appvalidator/testcases/javascript/instanceproperties.py diff --git a/validator/testcases/javascript/jstypes.py b/appvalidator/testcases/javascript/jstypes.py similarity index 100% rename from validator/testcases/javascript/jstypes.py rename to appvalidator/testcases/javascript/jstypes.py diff --git a/validator/testcases/javascript/nodedefinitions.py b/appvalidator/testcases/javascript/nodedefinitions.py similarity index 100% rename from validator/testcases/javascript/nodedefinitions.py rename to appvalidator/testcases/javascript/nodedefinitions.py diff --git a/validator/testcases/javascript/predefinedentities.py b/appvalidator/testcases/javascript/predefinedentities.py similarity index 100% rename from validator/testcases/javascript/predefinedentities.py rename to appvalidator/testcases/javascript/predefinedentities.py diff --git a/validator/testcases/javascript/spidermonkey.py b/appvalidator/testcases/javascript/spidermonkey.py similarity index 100% rename from validator/testcases/javascript/spidermonkey.py rename to appvalidator/testcases/javascript/spidermonkey.py diff --git a/validator/testcases/javascript/traverser.py b/appvalidator/testcases/javascript/traverser.py similarity index 100% rename from validator/testcases/javascript/traverser.py rename to appvalidator/testcases/javascript/traverser.py diff --git a/validator/testcases/jetpack.py b/appvalidator/testcases/jetpack.py similarity index 100% rename from validator/testcases/jetpack.py rename to appvalidator/testcases/jetpack.py diff --git a/validator/testcases/jetpack_data.txt b/appvalidator/testcases/jetpack_data.txt similarity index 100% rename from validator/testcases/jetpack_data.txt rename to appvalidator/testcases/jetpack_data.txt diff --git a/validator/testcases/l10n/__init__.py b/appvalidator/testcases/l10n/__init__.py similarity index 100% rename from validator/testcases/l10n/__init__.py rename to appvalidator/testcases/l10n/__init__.py diff --git a/validator/testcases/l10n/dtd.py b/appvalidator/testcases/l10n/dtd.py similarity index 100% rename from validator/testcases/l10n/dtd.py rename to appvalidator/testcases/l10n/dtd.py diff --git a/validator/testcases/l10n/properties.py b/appvalidator/testcases/l10n/properties.py similarity index 100% rename from validator/testcases/l10n/properties.py rename to appvalidator/testcases/l10n/properties.py diff --git a/validator/testcases/l10ncompleteness.py b/appvalidator/testcases/l10ncompleteness.py similarity index 100% rename from validator/testcases/l10ncompleteness.py rename to appvalidator/testcases/l10ncompleteness.py diff --git a/validator/testcases/langpack.py b/appvalidator/testcases/langpack.py similarity index 100% rename from validator/testcases/langpack.py rename to appvalidator/testcases/langpack.py diff --git a/validator/testcases/langpacks/fennec.xpi b/appvalidator/testcases/langpacks/fennec.xpi similarity index 100% rename from validator/testcases/langpacks/fennec.xpi rename to appvalidator/testcases/langpacks/fennec.xpi diff --git a/validator/testcases/langpacks/firefox.xpi b/appvalidator/testcases/langpacks/firefox.xpi similarity index 100% rename from validator/testcases/langpacks/firefox.xpi rename to appvalidator/testcases/langpacks/firefox.xpi diff --git a/validator/testcases/langpacks/mozilla.xpi b/appvalidator/testcases/langpacks/mozilla.xpi similarity index 100% rename from validator/testcases/langpacks/mozilla.xpi rename to appvalidator/testcases/langpacks/mozilla.xpi diff --git a/validator/testcases/langpacks/seamonkey.xpi b/appvalidator/testcases/langpacks/seamonkey.xpi similarity index 100% rename from validator/testcases/langpacks/seamonkey.xpi rename to appvalidator/testcases/langpacks/seamonkey.xpi diff --git a/validator/testcases/langpacks/sunbird.xpi b/appvalidator/testcases/langpacks/sunbird.xpi similarity index 100% rename from validator/testcases/langpacks/sunbird.xpi rename to appvalidator/testcases/langpacks/sunbird.xpi diff --git a/validator/testcases/langpacks/thunderbird.xpi b/appvalidator/testcases/langpacks/thunderbird.xpi similarity index 100% rename from validator/testcases/langpacks/thunderbird.xpi rename to appvalidator/testcases/langpacks/thunderbird.xpi diff --git a/validator/testcases/markup/__init__.py b/appvalidator/testcases/markup/__init__.py similarity index 100% rename from validator/testcases/markup/__init__.py rename to appvalidator/testcases/markup/__init__.py diff --git a/validator/testcases/markup/csstester.py b/appvalidator/testcases/markup/csstester.py similarity index 100% rename from validator/testcases/markup/csstester.py rename to appvalidator/testcases/markup/csstester.py diff --git a/validator/testcases/markup/markuptester.py b/appvalidator/testcases/markup/markuptester.py similarity index 100% rename from validator/testcases/markup/markuptester.py rename to appvalidator/testcases/markup/markuptester.py diff --git a/validator/testcases/packagelayout.py b/appvalidator/testcases/packagelayout.py similarity index 100% rename from validator/testcases/packagelayout.py rename to appvalidator/testcases/packagelayout.py diff --git a/validator/testcases/regex.py b/appvalidator/testcases/regex.py similarity index 100% rename from validator/testcases/regex.py rename to appvalidator/testcases/regex.py diff --git a/validator/testcases/scripting.py b/appvalidator/testcases/scripting.py similarity index 100% rename from validator/testcases/scripting.py rename to appvalidator/testcases/scripting.py diff --git a/validator/testcases/targetapplication.py b/appvalidator/testcases/targetapplication.py similarity index 100% rename from validator/testcases/targetapplication.py rename to appvalidator/testcases/targetapplication.py diff --git a/validator/testcases/themes.py b/appvalidator/testcases/themes.py similarity index 100% rename from validator/testcases/themes.py rename to appvalidator/testcases/themes.py diff --git a/validator/testcases/whitelist_hashes.txt b/appvalidator/testcases/whitelist_hashes.txt similarity index 100% rename from validator/testcases/whitelist_hashes.txt rename to appvalidator/testcases/whitelist_hashes.txt diff --git a/validator/textfilter.py b/appvalidator/textfilter.py similarity index 100% rename from validator/textfilter.py rename to appvalidator/textfilter.py diff --git a/validator/typedetection.py b/appvalidator/typedetection.py similarity index 100% rename from validator/typedetection.py rename to appvalidator/typedetection.py diff --git a/validator/unicodehelper.py b/appvalidator/unicodehelper.py similarity index 100% rename from validator/unicodehelper.py rename to appvalidator/unicodehelper.py diff --git a/validator/validate.py b/appvalidator/validate.py similarity index 100% rename from validator/validate.py rename to appvalidator/validate.py diff --git a/validator/version.py b/appvalidator/version.py similarity index 100% rename from validator/version.py rename to appvalidator/version.py diff --git a/validator/webapp.py b/appvalidator/webapp.py similarity index 100% rename from validator/webapp.py rename to appvalidator/webapp.py diff --git a/validator/xpi.py b/appvalidator/xpi.py similarity index 100% rename from validator/xpi.py rename to appvalidator/xpi.py diff --git a/extras/build_whitelist.py b/extras/build_whitelist.py deleted file mode 100644 index d93d8d9..0000000 --- a/extras/build_whitelist.py +++ /dev/null @@ -1,17 +0,0 @@ -import sys -import os -import os.path as pth -import hashlib - -output = open("whitelist_hashes.txt", mode="w") - -for root, dirs, files in os.walk(sys.argv[1]): - for filename in files: - path = pth.join(pth.dirname(pth.abspath(sys.argv[0])), - root, filename) - hash = hashlib.sha1(open(path).read()).hexdigest() - print path, hash - output.write(hash + "\n") - -output.close() - diff --git a/extras/bundle.py b/extras/bundle.py deleted file mode 100644 index e744db3..0000000 --- a/extras/bundle.py +++ /dev/null @@ -1,42 +0,0 @@ -import sys -import os - -import zipfile -from zipfile import ZipFile -from StringIO import StringIO - -source = sys.argv[1] -target = sys.argv[2] -zf = ZipFile(target, 'w') - -def _build_directory(source, zip, root): - for item in os.listdir(source): - - if item in ("__MACOSX", - ".DS_Store"): - continue - - if item.startswith("__"): - continue - - item = "%s/%s" % (source, item) - print item - - if os.path.isdir(item): - if item.startswith("_") and item.endswith(".jar"): - zipbuffer = StringIO() - subzip = ZipFile(zipbuffer, "w") - _build_directory(item, subzip, item) - subzip.close() - - zip.writestr(item[len(root) + 2:], zipbuffer.getvalue()) - else: - _build_directory(item, zip, root) - else: - print item[len(root) + 1:] - zip.write(item, item[len(root) + 1:]) - - - -_build_directory(source, zf, source) -zf.close() diff --git a/extras/cover.py b/extras/cover.py deleted file mode 100644 index 416a650..0000000 --- a/extras/cover.py +++ /dev/null @@ -1,305 +0,0 @@ -"""If you have Ned Batchelder's coverage_ module installed, you may activate a -coverage report with the ``--with-coverage`` switch or NOSE_WITH_COVERAGE -environment variable. The coverage report will cover any python source module -imported after the start of the test run, excluding modules that match -testMatch. If you want to include those modules too, use the ``--cover-tests`` -switch, or set the NOSE_COVER_TESTS environment variable to a true value. To -restrict the coverage report to modules from a particular package or packages, -use the ``--cover-packages`` switch or the NOSE_COVER_PACKAGES environment -variable. - -.. _coverage: http://www.nedbatchelder.com/code/modules/coverage.html -""" -import logging -import os -import sys -from nose.plugins.base import Plugin -from nose.util import src, tolist - -log = logging.getLogger(__name__) - -COVERAGE_TEMPLATE = ''' - -%(title)s - - -%(header)s - -
-%(stats)s -
-
-%(body)s -
- - -''' - -COVERAGE_STATS_TEMPLATE = '''Covered: %(covered)s lines
-Missed: %(missed)s lines
-Skipped %(skipped)s lines
-Percent: %(percent)s %%
-''' - - -class Coverage(Plugin): - """ - Activate a coverage report using Ned Batchelder's coverage module. - """ - coverTests = False - coverPackages = None - score = 200 - status = {} - - def options(self, parser, env): - """ - Add options to command line. - """ - Plugin.options(self, parser, env) - parser.add_option("--cover-package", action="append", - default=env.get('NOSE_COVER_PACKAGE'), - metavar="PACKAGE", - dest="cover_packages", - help="Restrict coverage output to selected packages " - "[NOSE_COVER_PACKAGE]") - parser.add_option("--cover-skip", action="store", - dest="cover_skip", - help="Skip packages " - "[NOSE_COVER_SKIP]") - parser.add_option("--cover-erase", action="store_true", - default=env.get('NOSE_COVER_ERASE'), - dest="cover_erase", - help="Erase previously collected coverage " - "statistics before run") - parser.add_option("--cover-tests", action="store_true", - dest="cover_tests", - default=env.get('NOSE_COVER_TESTS'), - help="Include test modules in coverage report " - "[NOSE_COVER_TESTS]") - parser.add_option("--cover-inclusive", action="store_true", - dest="cover_inclusive", - default=env.get('NOSE_COVER_INCLUSIVE'), - help="Include all python files under working " - "directory in coverage report. Useful for " - "discovering holes in test coverage if not all " - "files are imported by the test suite. " - "[NOSE_COVER_INCLUSIVE]") - parser.add_option("--cover-html", action="store_true", - default=env.get('NOSE_COVER_HTML'), - dest='cover_html', - help="Produce HTML coverage information") - parser.add_option('--cover-html-dir', action='store', - default=env.get('NOSE_COVER_HTML_DIR', 'cover'), - dest='cover_html_dir', - metavar='DIR', - help='Produce HTML coverage information in dir') - - def configure(self, options, config): - """ - Configure plugin. - """ - try: - self.status.pop('active') - except KeyError: - pass - Plugin.configure(self, options, config) - if config.worker: - return - if self.enabled: - try: - import coverage - except ImportError: - log.error("Coverage not available: " - "unable to import coverage module") - self.enabled = False - return - self.conf = config - cskip = options.cover_skip - if cskip: - self.coverSkip = cskip.split(",") - else: - self.coverSkip = [] - self.coverErase = options.cover_erase - self.coverTests = options.cover_tests - self.coverPackages = [] - if options.cover_packages: - for pkgs in [tolist(x) for x in options.cover_packages]: - self.coverPackages.extend(pkgs) - self.coverInclusive = options.cover_inclusive - if self.coverPackages: - log.info("Coverage report will include only packages: %s", - self.coverPackages) - self.coverHtmlDir = None - if options.cover_html: - self.coverHtmlDir = options.cover_html_dir - log.debug('Will put HTML coverage report in %s', self.coverHtmlDir) - if self.enabled: - self.status['active'] = True - - def begin(self): - """ - Begin recording coverage information. - """ - log.debug("Coverage begin") - import coverage - self.skipModules = sys.modules.keys()[:] - if self.coverErase: - log.debug("Clearing previously collected coverage statistics") - coverage.erase() - coverage.exclude('#pragma[: ]+[nN][oO] [cC][oO][vV][eE][rR]') - coverage.start() - - def report(self, stream): - """ - Output code coverage report. - """ - log.debug("Coverage report") - import coverage - coverage.stop() - modules = [ module - for name, module in sys.modules.items() - if self.wantModuleCoverage(name, module, stream) ] - log.debug("Coverage report will cover modules: %s", modules) - coverage.report(modules, file=stream) - if self.coverHtmlDir: - if not os.path.exists(self.coverHtmlDir): - os.makedirs(self.coverHtmlDir) - log.debug("Generating HTML coverage report") - files = {} - for m in modules: - if hasattr(m, '__name__') and hasattr(m, '__file__'): - files[m.__name__] = m.__file__ - coverage.annotate(files.values()) - global_stats = {'covered': 0, 'missed': 0, 'skipped': 0} - file_list = [] - for m, f in files.iteritems(): - if f.endswith('pyc'): - f = f[:-1] - coverfile = f+',cover' - outfile, stats = self.htmlAnnotate(m, f, coverfile, - self.coverHtmlDir) - for field in ('covered', 'missed', 'skipped'): - global_stats[field] += stats[field] - file_list.append((stats['percent'], m, outfile, stats)) - os.unlink(coverfile) - file_list.sort() - global_stats['percent'] = self.computePercent( - global_stats['covered'], global_stats['missed']) - # Now write out an index file for the coverage HTML - index = open(os.path.join(self.coverHtmlDir, 'index.html'), 'w') - index.write('Coverage Index' - '

') - index.write(COVERAGE_STATS_TEMPLATE % global_stats) - index.write('') - for junk, name, outfile, stats in file_list: - stats['a'] = '%s' % (outfile, name) - index.write('' % stats) - index.write('
FileCoveredMissed' - 'SkippedPercent
%(a)s%(covered)s' - '%(missed)s%(skipped)s' - '%(percent)s %%

', '>'), - ('"', '"'), ): - line = line.replace(old, new) - if status == '!': - rows.append('
'
-                            '%s
%s
' % (lineno, - line)) - stats['missed'] += 1 - elif status == '>': - rows.append('
%s
' - '
%s
' % (lineno, line)) - stats['covered'] += 1 - else: - rows.append('' % (lineno, line)) - stats['skipped'] += 1 - stats['percent'] = self.computePercent(stats['covered'], - stats['missed']) - html = COVERAGE_TEMPLATE % {'title': '%s' % name, - 'header': name, - 'body': '\n'.join(rows), - 'stats': COVERAGE_STATS_TEMPLATE % stats, - } - outfilename = name + '.html' - outfile = open(os.path.join(outputDir, outfilename), 'w') - outfile.write(html) - outfile.close() - return outfilename, stats - - def computePercent(self, covered, missed): - if covered + missed == 0: - percent = 1 - else: - percent = covered/(covered+missed+0.0) - return int(percent * 100) - - def wantModuleCoverage(self, name, module, stream=None): - if not hasattr(module, '__file__'): - log.debug("no coverage of %s: no __file__", name) - return False - module_file = src(module.__file__) - if not module_file or not module_file.endswith('.py'): - log.debug("no coverage of %s: not a python file", name) - return False - if self.coverSkip: - for package in self.coverSkip: - if name.startswith(package): - return False - if self.coverPackages: - for package in self.coverPackages: - if (name.startswith(package) - and (self.coverTests - or not self.conf.testMatch.search(name))): - log.debug("coverage for %s", name) - return True - - if name in self.skipModules: - log.debug("no coverage for %s: loaded before coverage start", - name) - return False - if self.conf.testMatch.search(name) and not self.coverTests: - log.debug("no coverage for %s: is a test", name) - return False - # accept any package that passed the previous tests, unless - # coverPackages is on -- in that case, if we wanted this - # module, we would have already returned True - return not self.coverPackages - - def wantFile(self, file, package=None): - """If inclusive coverage enabled, return true for all source files - in wanted packages. - """ - if self.coverInclusive: - if file.endswith(".py"): - if package and self.coverPackages: - for want in self.coverPackages: - if package.startswith(want): - return True - else: - return True - return None diff --git a/extras/unbundle.py b/extras/unbundle.py deleted file mode 100644 index d26a6be..0000000 --- a/extras/unbundle.py +++ /dev/null @@ -1,47 +0,0 @@ -import sys -import os - -import zipfile -from zipfile import ZipFile -from StringIO import StringIO - -source = sys.argv[1] -target = sys.argv[2] - -if not target.endswith("/"): - target = "%s/" % target - -def _unbundle(path, target): - zf = ZipFile(path, 'r') - contents = zf.namelist() - for item in contents: - sp = item.split("/") - if not sp[-1]: - continue - - if "__MACOSX" in item: - continue - - print item, ">", target + item - - cpath = target + "/".join(sp[:-1]) - if not os.path.exists(cpath): - os.makedirs(cpath) - if item.endswith((".jar", ".xpi", ".zip")): - now = target + item - path_item = item.split("/") - path_item[-1] = "_" + path_item[-1] - path = target + "/".join(path_item) - - buff = StringIO(zf.read(item)) - _unbundle(buff, path + "/") - else: - f = open(target + item, 'w') - f.write(zf.read(item)) - f.close() - zf.close() - -if not os.path.exists(target): - os.mkdir(target) - -_unbundle(source, target) diff --git a/extras/update_langpacks.py b/extras/update_langpacks.py deleted file mode 100644 index efa191c..0000000 --- a/extras/update_langpacks.py +++ /dev/null @@ -1,72 +0,0 @@ -import os -from fnmatch import fnmatch -from tempfile import NamedTemporaryFile -from zipfile import ZipFile - - -PACKAGE_MAPPINGS = {"Fennec.app": "fennec", - "Firefox.app": "firefox", - "SeaMonkey.app": "seamonkey", - "Thunderbird.app": "thunderbird",} - - -def copy_to_zip(read_zip, write_zip, pattern, prefix=""): - for member in read_zip.namelist(): - if fnmatch(member, pattern): - filename = member.split("/")[-1] - write_zip.writestr("%s%s" % (prefix, filename), - read_zip.read(member)) - - -def copy_to_new_zip(callback, read_zip, pattern, prefix=""): - with NamedTemporaryFile("w") as temp: - with ZipFile(temp.name, "w") as write_zip: - copy_to_zip(read_zip, write_zip, pattern, prefix) - - callback(temp.name) - - -def main(): - for package in os.listdir("language_controls/"): - if package.startswith(".") or package not in PACKAGE_MAPPINGS: - continue - - platform = PACKAGE_MAPPINGS[package] - path = "language_controls/%s" % package - jar = ZipFile("../validator/testcases/langpacks/%s.xpi" % platform, "w") - - if platform == "firefox": - # Firefox puts this stuff in omni.ja. - with ZipFile("%s/Contents/MacOS/omni.ja" % path, "r") as omni_ja: - #print list(x for x in omni_ja.namelist() if x.startswith("chrome/")) - jar.writestr("chrome.manifest", - omni_ja.read("chrome/localized.manifest")) - - # Copy the chrome/en-US/ directory to /en-US.jar in the new zip. - def callback(name): - jar.write(name, "en-US.jar") - copy_to_new_zip(callback, omni_ja, "chrome/en-US/*") - - elif platform in ("thunderbird", "seamonkey", ): - # Thunderbird puts stuff in omni.ja, too, - with ZipFile("%s/Contents/MacOS/omni.ja" % path, "r") as omni_ja: - jar.writestr("chrome.manifest", - omni_ja.read("chrome/localized.manifest")) - - # Copy the chrome/en-US/ directory to /en-US.jar in the new zip. - def callback(name): - jar.write(name, "en-US.jar") - copy_to_new_zip(callback, omni_ja, "chrome/en-US/*") - - else: - jar.write("%s/Contents/MacOS/chrome/localized.manifest" % path, - "chrome.manifest") - jar.write("%s/Contents/MacOS/chrome/en-US.jar" % path, - "en-US.jar") - - jar.close() - - -if __name__ == "__main__": - main() - diff --git a/jetpack/addon-sdk b/jetpack/addon-sdk deleted file mode 160000 index e2b154a..0000000 --- a/jetpack/addon-sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e2b154aff5c452d3b4f25bd67513122bd6172319 diff --git a/jetpack/generate_jp_whitelist.sh b/jetpack/generate_jp_whitelist.sh deleted file mode 100755 index 743f954..0000000 --- a/jetpack/generate_jp_whitelist.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -rm ../validator/testcases/jetpack_data.txt - -cd addon-sdk -git pull origin --tags -for tagname in `git tag`; -do - # Check out the tag. - git checkout $tagname - - # Hash all of the JS files. - for f in `find . -type f -name "*.js"`; - do - python ../make_hash.py $f $tagname >> ../../validator/testcases/jetpack_data.txt - done - - # Run again for HTML, because it gets bundled, too. - for f in `find . -type f -name "*.html"`; - do - python ../make_hash.py $f $tagname >> ../../validator/testcases/jetpack_data.txt - done -done - -sort ../../validator/testcases/jetpack_data.txt -d -o ../../validator/testcases/jetpack_data.txt diff --git a/jetpack/make_hash.py b/jetpack/make_hash.py deleted file mode 100644 index 65041f5..0000000 --- a/jetpack/make_hash.py +++ /dev/null @@ -1,6 +0,0 @@ -import hashlib -import os -import sys - -hash = hashlib.sha256(open(sys.argv[1]).read()).hexdigest() -print sys.argv[1], sys.argv[2], hash diff --git a/requirements.txt b/requirements.txt index 9b63eaf..eee4109 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,6 @@ -coverage==3.3.1 cssutils==0.9.7 Fabric==0.9.0 nose==0.11.4 -rdflib==3.2.1 simplejson==2.3.0 argparse==1.1 -e git://github.com/mattbasta/fastchardet#egg=fastchardet diff --git a/setup.py b/setup.py index 2eae362..6d2ae4c 100644 --- a/setup.py +++ b/setup.py @@ -2,13 +2,13 @@ setup( - name='amo-validator', + name='app-validator', version='1.0', - description='Validates addons for Mozilla products.', + description='Validates open web apps.', long_description=open('README.rst').read(), author='Matt Basta', author_email='me@mattbasta.com', - url='http://github.com/mattbasta/amo-validator', + url='http://github.com/mattbasta/app-validator', license='BSD', packages=find_packages(exclude=['tests', 'tests/*', @@ -19,7 +19,7 @@ install_requires=[p.strip() for p in open('./requirements.txt') if not p.startswith(('#', '-e'))], - scripts=["addon-validator"], + scripts=["app-validator"], classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Web Environment',