From 6d01461e53cf17483ed6ee6399517a7d56dff076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sun, 14 Feb 2021 18:32:05 +0000 Subject: [PATCH 01/19] Improve JSON detection when the mime-type is not application/json --- lib/tools/redownload/contentTypeChecker.js | 18 ++++++++++++++++-- package.json | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/tools/redownload/contentTypeChecker.js b/lib/tools/redownload/contentTypeChecker.js index 58fb3df..ea06d88 100644 --- a/lib/tools/redownload/contentTypeChecker.js +++ b/lib/tools/redownload/contentTypeChecker.js @@ -10,6 +10,7 @@ var isWoff2 = require('is-woff2'); var isOtf = require('is-otf'); var isTtf = require('is-ttf'); var isEot = require('is-eot'); +var isJson = require('is-json'); var ContentTypeChecker = function() { @@ -57,7 +58,7 @@ var ContentTypeChecker = function() { foundType = findContentType(entry.weightCheck.bodyBuffer); // If it's an image or a font, then rewrite. - if (foundType !== null && (foundType.type === 'image' || foundType.type === 'webfont')) { + if (foundType !== null && (foundType.type === 'image' || foundType.type === 'webfont' || foundType.type === 'json')) { if (foundType.type !== entry.type) { debug('Content type %s is wrong for %s. It should be %s.', entry.type, entry.ulr, foundType.type); } @@ -119,6 +120,10 @@ var ContentTypeChecker = function() { return contentTypes.eot; } + if (isJson(bodyStr)) { + return contentTypes.json; + } + return null; } @@ -224,7 +229,16 @@ var ContentTypeChecker = function() { entry.type = 'webfont'; entry.isWebFont = true; } - } + }, + json: { + type: 'json', + mimes: ['application/json'], + updateFn: function(entry) { + entry.type = 'json'; + entry.isJSON = true; + } + }, + }; return { diff --git a/package.json b/package.json index ed35943..2d76827 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yellowlabtools", - "version": "2.0.0-beta", + "version": "2.0.0", "description": "Online tool to audit a webpage for performance and front-end quality issues", "license": "GPL-2.0", "author": { @@ -50,6 +50,7 @@ "is-eot": "1.0.0", "is-gif": "3.0.0", "is-jpg": "2.0.0", + "is-json": "2.0.1", "is-otf": "0.1.2", "is-png": "1.1.0", "is-svg": "3.0.0", From 38b362e5febdeb865a95540f6fa954a35f3a42b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Mon, 15 Feb 2021 22:46:42 +0000 Subject: [PATCH 02/19] Comment typo --- lib/tools/redownload/fileMinifier.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tools/redownload/fileMinifier.js b/lib/tools/redownload/fileMinifier.js index 5e4f97e..4387e75 100644 --- a/lib/tools/redownload/fileMinifier.js +++ b/lib/tools/redownload/fileMinifier.js @@ -224,7 +224,7 @@ var FileMinifier = function() { return result; } - // Avoid losing some trying to compress JS files if they already look minified + // Avoid losing time trying to compress JS files if they already look minified // by counting the number of lines compared to the total size. // Less than 2KB per line is suspicious function looksAlreadyMinified(code) { From e46d4cff27c621948237fe4d0747c5de352d1b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Fri, 19 Feb 2021 20:03:02 +0000 Subject: [PATCH 03/19] Fix offenders not being displayed for globalVariables and synchronousXHR --- front/src/views/rule.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/front/src/views/rule.html b/front/src/views/rule.html index 1161dd7..2c8a2a0 100644 --- a/front/src/views/rule.html +++ b/front/src/views/rule.html @@ -179,10 +179,18 @@ () -
+
+ {{offender}} +
+ +
{{offender.version}}
+
+ {{offender.url}} +
+
({{offender.size | bytes}}) From 9be862e37bb0b036d42ab06bc15ff24f2de061dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Fri, 19 Feb 2021 20:08:13 +0000 Subject: [PATCH 04/19] Remove is-json package --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 2d76827..8c5fa85 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "is-eot": "1.0.0", "is-gif": "3.0.0", "is-jpg": "2.0.0", - "is-json": "2.0.1", "is-otf": "0.1.2", "is-png": "1.1.0", "is-svg": "3.0.0", From cc74359e8323f359b735bc59b0d26f41ea9bedc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sat, 20 Feb 2021 13:02:14 +0000 Subject: [PATCH 05/19] Fix SSL errors not being correctly ignored --- lib/tools/phantomas/phantomasWrapper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tools/phantomas/phantomasWrapper.js b/lib/tools/phantomas/phantomasWrapper.js index a4aa347..e74e85a 100644 --- a/lib/tools/phantomas/phantomasWrapper.js +++ b/lib/tools/phantomas/phantomasWrapper.js @@ -47,7 +47,7 @@ var PhantomasWrapper = function() { // Mandatory 'analyze-css': true, - 'ignore-ssl-errors': true + 'ignoreSslErrors': true }; From e9ab1fd16e347a1981cb3a8318bb2e62b6940b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Thu, 25 Feb 2021 15:21:45 +0000 Subject: [PATCH 06/19] Sorry, I should have kept is-json package --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8c5fa85..2d76827 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "is-eot": "1.0.0", "is-gif": "3.0.0", "is-jpg": "2.0.0", + "is-json": "2.0.1", "is-otf": "0.1.2", "is-png": "1.1.0", "is-svg": "3.0.0", From 707048a1dfa9a72bc588ac11012ffeb272778df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Fri, 26 Feb 2021 16:22:29 +0000 Subject: [PATCH 07/19] Change Brotli wording --- lib/metadata/policies.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/metadata/policies.js b/lib/metadata/policies.js index 953aa51..1d9a606 100644 --- a/lib/metadata/policies.js +++ b/lib/metadata/policies.js @@ -757,7 +757,7 @@ var policies = { }, "compression": { "tool": "redownload", - "label": "Brotli compression", + "label": "Gzip/Brotli compression", "message": "

Measures the number of bytes that could be saved by compressing textual files. Some files listed below might not be compressed at all, some might be already compressed with Gzip but would become even lighter with Brotli.

All major server systems are now compatible with Brotli.

Note that compressing small files (< 1 KB) is arguable, and that some assets such as images should not be compressed as it is already included in their format. Here is a list of Content-Types that should be compressed.

", "isOkThreshold": 20480, "isBadThreshold": 204800, From 418426419db11ad720245e7f3283a70f55e2c250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sun, 28 Feb 2021 13:59:16 +0000 Subject: [PATCH 08/19] Improve compression detection --- lib/metadata/policies.js | 2 +- lib/tools/redownload/redownload.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/metadata/policies.js b/lib/metadata/policies.js index 1d9a606..f76c01f 100644 --- a/lib/metadata/policies.js +++ b/lib/metadata/policies.js @@ -758,7 +758,7 @@ var policies = { "compression": { "tool": "redownload", "label": "Gzip/Brotli compression", - "message": "

Measures the number of bytes that could be saved by compressing textual files. Some files listed below might not be compressed at all, some might be already compressed with Gzip but would become even lighter with Brotli.

All major server systems are now compatible with Brotli.

Note that compressing small files (< 1 KB) is arguable, and that some assets such as images should not be compressed as it is already included in their format. Here is a list of Content-Types that should be compressed.

", + "message": "

Measures the number of bytes that could be saved by compressing textual files. Some files listed below might not be compressed at all, some might be already compressed with Gzip but would become even lighter with Brotli.

All major server systems are now compatible with Brotli.

Note that compressing small files (< 1 KB) is arguable, and that some assets such as images should not be compressed as it is already included in their format. Here is a list of MIME types that should be compressed.

", "isOkThreshold": 20480, "isBadThreshold": 204800, "isAbnormalThreshold": 409600, diff --git a/lib/tools/redownload/redownload.js b/lib/tools/redownload/redownload.js index 3b544f8..82793ad 100644 --- a/lib/tools/redownload/redownload.js +++ b/lib/tools/redownload/redownload.js @@ -823,6 +823,7 @@ var Redownload = function() { reqHeaders['Accept'] = '*/*,image/webp'; reqHeaders['Accept-Encoding'] = 'gzip, deflate, br'; reqHeaders['Connection'] = 'keep-alive'; + reqHeaders['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36'; var requestOptions = { method: entry.method, From e3d41000555cba480f3e8f64fa27194a76bc0df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Mon, 1 Mar 2021 01:18:48 +0000 Subject: [PATCH 09/19] Update ttf2woff2 library --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2d76827..a357ab5 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "request": "2.88.0", "rimraf": "2.6.3", "temporary": "0.0.8", - "ttf2woff2": "3.0.0", + "ttf2woff2": "4.0.1", "uglify-js": "3.4.9", "woff-tools": "0.1.0" }, From 1213854644699c166bc4f88b1b38416c5cecdc1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Mon, 1 Mar 2021 01:31:35 +0000 Subject: [PATCH 10/19] Update Imagemin and dependencies --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a357ab5..d0e6ea1 100644 --- a/package.json +++ b/package.json @@ -42,11 +42,11 @@ "fontkit": "1.7.8", "html-minifier": "4.0.0", "image-size": "0.7.1", - "imagemin": "6.1.0", - "imagemin-jpegoptim": "6.0.0", - "imagemin-jpegtran": "6.0.0", - "imagemin-optipng": "6.0.0", - "imagemin-svgo": "7.0.0", + "imagemin": "7.0.1", + "imagemin-jpegoptim": "7.0.0", + "imagemin-jpegtran": "7.0.0", + "imagemin-optipng": "8.0.0", + "imagemin-svgo": "8.0.0", "is-eot": "1.0.0", "is-gif": "3.0.0", "is-jpg": "2.0.0", From bb9429e907836204c49a25bb06591a185d754e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Mon, 1 Mar 2021 02:50:23 +0000 Subject: [PATCH 11/19] Update Imagemin and dependencies --- lib/tools/redownload/imageOptimizer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tools/redownload/imageOptimizer.js b/lib/tools/redownload/imageOptimizer.js index 042502a..0490025 100644 --- a/lib/tools/redownload/imageOptimizer.js +++ b/lib/tools/redownload/imageOptimizer.js @@ -210,7 +210,7 @@ var ImageOptimizer = function() { } - imagemin.buffer(imageBody, {use: engine}) + imagemin.buffer(imageBody, {plugins: [engine]}) .then(function(file) { var endTime = Date.now(); From 0a1b9ce27abf5aedcd026676420a7db619ff669e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Tue, 2 Mar 2021 00:19:56 +0000 Subject: [PATCH 12/19] Fix JS error offenders --- lib/offendersHelpers.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/lib/offendersHelpers.js b/lib/offendersHelpers.js index f2e9143..702243d 100644 --- a/lib/offendersHelpers.js +++ b/lib/offendersHelpers.js @@ -117,7 +117,7 @@ var OffendersHelpers = function() { for (var i=0 ; i Date: Sun, 7 Mar 2021 09:45:56 +0000 Subject: [PATCH 13/19] Working on implementing unicode ranges again --- lib/metadata/policies.js | 4 ++-- lib/metadata/scoreProfileGeneric.json | 3 ++- lib/tools/redownload/redownload.js | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/metadata/policies.js b/lib/metadata/policies.js index f76c01f..8a10eca 100644 --- a/lib/metadata/policies.js +++ b/lib/metadata/policies.js @@ -875,7 +875,7 @@ var policies = { return offenders; } }, - /*"unusedUnicodeRanges": { + "unusedUnicodeRanges": { "tool": "redownload", "label": "Unused Unicode ranges", "message": "

This metric counts the number of unused Unicode ranges inside each font. For example, one font could include Cyrillic glyphs but none of them are used on the page.

It also reveals the number of ligatures (letters that are represented differently when close to each other) and hidden chars (glyphs not linked to the unicode system that can't be displayed on the web).

Because of technical limitations, Yellow Lab Tools checks each font against the glyphs of the entire page. As a result, estimated use is >= to reality. For example, if you read that 10 glyphs are \"possibly used\", it means that these 10 glyphs are used on the page but nothing guaranties that they are displayed using this font.

Tools such as Font Squirrel can remove some unicode ranges from a font.

In the case of an icon font, make sure you only keep the icons that are used on the website and to remove the others. Several tools are able to extract SVG images from a font, then some other tools can generate a font from the SVGs you want to keep.

", @@ -886,7 +886,7 @@ var policies = { "offendersTransformFn": function(offenders) { return offenders; } - },*/ + }, "nonWoff2Fonts": { "tool": "redownload", "label": "WOFF 2", diff --git a/lib/metadata/scoreProfileGeneric.json b/lib/metadata/scoreProfileGeneric.json index 14dfd0f..cc82643 100644 --- a/lib/metadata/scoreProfileGeneric.json +++ b/lib/metadata/scoreProfileGeneric.json @@ -86,7 +86,8 @@ "policies": { "fontsCount": 1, "heavyFonts": 0.5, - "nonWoff2Fonts": 0.5 + "nonWoff2Fonts": 0.5, + "unusedUnicodeRanges": 0.1 } }, "serverConfig": { diff --git a/lib/tools/redownload/redownload.js b/lib/tools/redownload/redownload.js index 82793ad..bab99ae 100644 --- a/lib/tools/redownload/redownload.js +++ b/lib/tools/redownload/redownload.js @@ -65,8 +65,8 @@ var Redownload = function() { // Prevent a bug with the font analyzer on empty pages var differentCharacters = ''; - if (data.toolsResults.phantomas.offenders.differentCharacters && data.toolsResults.phantomas.offenders.differentCharacters.length > 0) { - differentCharacters = data.toolsResults.phantomas.offenders.differentCharacters[0]; + if (data.toolsResults.phantomas.offenders.charactersCount && data.toolsResults.phantomas.offenders.charactersCount.length > 0) { + differentCharacters = data.toolsResults.phantomas.offenders.charactersCount[0]; } // Transform every request into a download function with a callback when done From 52a781dee8fd45b82d569284294c901166adb354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sun, 7 Mar 2021 09:48:29 +0000 Subject: [PATCH 14/19] Start working on CDN detection --- lib/tools/redownload/redownload.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/tools/redownload/redownload.js b/lib/tools/redownload/redownload.js index bab99ae..e14d5de 100644 --- a/lib/tools/redownload/redownload.js +++ b/lib/tools/redownload/redownload.js @@ -21,6 +21,7 @@ var brotliCompressor = require('./brotliCompressor'); var contentTypeChecker = require('./contentTypeChecker'); var fontAnalyzer = require('./fontAnalyzer'); var imageDimensions = require('./imageDimensions'); +var cdnDetector = require('./cdnDetector/cdnDetector'); var Redownload = function() { @@ -75,6 +76,8 @@ var Redownload = function() { redownloadEntry(entry, httpAuth, proxy) + .then(cdnDetector.detectCDN) + .then(contentTypeChecker.checkContentType) .then(imageOptimizer.optimizeImage) @@ -900,6 +903,7 @@ var Redownload = function() { var result = { bodyBuffer: body, headersSize: Buffer.byteLength(rawHeaders, 'utf8'), + headers: res.headers, bodySize: bodySize, isCompressed: isCompressed, compressionTool: compressionTool, From 36fc0f0e10697918f003eaa55fdcfed18787b8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sun, 7 Mar 2021 11:41:00 +0000 Subject: [PATCH 15/19] Working on implementing unicode ranges again --- lib/metadata/scoreProfileGeneric.json | 4 ++-- lib/runner.js | 6 ++++++ lib/tools/redownload/redownload.js | 3 --- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/metadata/scoreProfileGeneric.json b/lib/metadata/scoreProfileGeneric.json index cc82643..8bff9e4 100644 --- a/lib/metadata/scoreProfileGeneric.json +++ b/lib/metadata/scoreProfileGeneric.json @@ -86,8 +86,8 @@ "policies": { "fontsCount": 1, "heavyFonts": 0.5, - "nonWoff2Fonts": 0.5, - "unusedUnicodeRanges": 0.1 + "unusedUnicodeRanges": 0.5, + "nonWoff2Fonts": 0.5 } }, "serverConfig": { diff --git a/lib/runner.js b/lib/runner.js index 33389e5..bbf3138 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -78,6 +78,12 @@ var Runner = function(params) { milestone: 'redownload' }); + // Fix: don't display Unicode ranges if the module is not present in Phantomas + if (!data.toolsResults.phantomas.metrics.charactersCount) { + delete data.toolsResults.redownload.metrics.unusedUnicodeRanges; + delete data.toolsResults.redownload.offenders.unusedUnicodeRanges; + } + // Rules checker var policies = require('./metadata/policies'); data.rules = rulesChecker.check(data, policies); diff --git a/lib/tools/redownload/redownload.js b/lib/tools/redownload/redownload.js index e14d5de..42b4de3 100644 --- a/lib/tools/redownload/redownload.js +++ b/lib/tools/redownload/redownload.js @@ -21,7 +21,6 @@ var brotliCompressor = require('./brotliCompressor'); var contentTypeChecker = require('./contentTypeChecker'); var fontAnalyzer = require('./fontAnalyzer'); var imageDimensions = require('./imageDimensions'); -var cdnDetector = require('./cdnDetector/cdnDetector'); var Redownload = function() { @@ -76,8 +75,6 @@ var Redownload = function() { redownloadEntry(entry, httpAuth, proxy) - .then(cdnDetector.detectCDN) - .then(contentTypeChecker.checkContentType) .then(imageOptimizer.optimizeImage) From dc5bd2e71e808621ccaf1964cb00c618f31822da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Wed, 10 Mar 2021 00:54:50 +0000 Subject: [PATCH 16/19] Add last test launch time in the new /api/runs route --- lib/server/controllers/apiController.js | 5 ++++- lib/server/datastores/runsQueue.js | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/server/controllers/apiController.js b/lib/server/controllers/apiController.js index a464cc6..090e6ec 100644 --- a/lib/server/controllers/apiController.js +++ b/lib/server/controllers/apiController.js @@ -227,7 +227,10 @@ var ApiController = function(app) { // Counts all pending runs app.get('/api/runs', function(req, res) { res.setHeader('Content-Type', 'application/json'); - res.send(JSON.stringify({pendingRuns: queue.length()}, null, 2)); + res.send(JSON.stringify({ + pendingRuns: queue.length(), + timeSinceLastTestStarted: queue.timeSinceLastTestStarted() + }, null, 2)); }); // Delete one run by id diff --git a/lib/server/datastores/runsQueue.js b/lib/server/datastores/runsQueue.js index e99f1fb..5164d67 100644 --- a/lib/server/datastores/runsQueue.js +++ b/lib/server/datastores/runsQueue.js @@ -6,7 +6,7 @@ function RunsQueue() { 'use strict'; var queue = []; - + var lastTestTimestamp = 0; this.push = function(runId) { var deferred = Q.defer(); @@ -21,6 +21,7 @@ function RunsQueue() { runId: runId }); + lastTestTimestamp = Date.now(); deferred.resolve(); } else { @@ -31,6 +32,7 @@ function RunsQueue() { deferred.notify(position); }, itIsTimeCallback: function() { + lastTestTimestamp = Date.now(); deferred.resolve(); } }); @@ -78,6 +80,11 @@ function RunsQueue() { this.length = function() { return queue.length; }; + + // Returns the number of seconds since the last test was launched + this.timeSinceLastTestStarted = function() { + return Math.round((Date.now() - lastTestTimestamp) / 1000); + }; } module.exports = RunsQueue; \ No newline at end of file From 92d92b8021b678936825c6a8bf1f8b4189d3379c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Wed, 10 Mar 2021 07:11:13 +0000 Subject: [PATCH 17/19] Remove API limits for /api/runs in GET mode --- lib/server/middlewares/apiLimitsMiddleware.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/middlewares/apiLimitsMiddleware.js b/lib/server/middlewares/apiLimitsMiddleware.js index 0ebe205..9c92f61 100644 --- a/lib/server/middlewares/apiLimitsMiddleware.js +++ b/lib/server/middlewares/apiLimitsMiddleware.js @@ -13,7 +13,7 @@ var apiLimitsMiddleware = function(req, res, next) { if (req.path.indexOf('/api/') === 0 && !res.locals.hasApiKey) { - if (req.path === '/api/runs') { + if (req.path === '/api/runs' && req.method === 'POST') { if (!runsTable.accepts(ipAddress)) { // Sorry :/ From fcdf3c924011fcc8fdc880d2c37c38088fe6efd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Thu, 11 Mar 2021 09:56:41 +0000 Subject: [PATCH 18/19] Fix monitoring being blocked --- lib/metadata/policies.js | 2 +- lib/server/middlewares/apiLimitsMiddleware.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/metadata/policies.js b/lib/metadata/policies.js index 8a10eca..3157fb1 100644 --- a/lib/metadata/policies.js +++ b/lib/metadata/policies.js @@ -538,7 +538,7 @@ var policies = { "message": "

It can be useful, but only as a last resort. It is a bad practice because it overrides the normal cascading logic. The more you use !important, the more you need it again to over-override. This conducts to a poor maintainability.

", "isOkThreshold": 0, "isBadThreshold": 200, - "isAbnormalThreshold": 500, + "isAbnormalThreshold": 1000, "hasOffenders": true, "offendersTransformFn": function(offenders) { var parsedOffenders = offenders.map(function(offender) { diff --git a/lib/server/middlewares/apiLimitsMiddleware.js b/lib/server/middlewares/apiLimitsMiddleware.js index 9c92f61..bd85e9b 100644 --- a/lib/server/middlewares/apiLimitsMiddleware.js +++ b/lib/server/middlewares/apiLimitsMiddleware.js @@ -13,6 +13,13 @@ var apiLimitsMiddleware = function(req, res, next) { if (req.path.indexOf('/api/') === 0 && !res.locals.hasApiKey) { + // Monitoring requests + if (req.path === '/api/runs' && req.method === 'GET') { + next(); + return; + } + + // New tests if (req.path === '/api/runs' && req.method === 'POST') { if (!runsTable.accepts(ipAddress)) { @@ -24,6 +31,7 @@ var apiLimitsMiddleware = function(req, res, next) { } + // Every other calls if (!callsTable.accepts(ipAddress)) { // Sorry :/ debug('Too many API requests from IP address %s', ipAddress); From 91e1724540fe7d0997e199e016f43bb1eada2e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Sat, 13 Mar 2021 11:17:58 +0000 Subject: [PATCH 19/19] Get ready for Phantomas 2.2 --- lib/tools/phantomas/phantomasWrapper.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tools/phantomas/phantomasWrapper.js b/lib/tools/phantomas/phantomasWrapper.js index e74e85a..c7b9bc6 100644 --- a/lib/tools/phantomas/phantomasWrapper.js +++ b/lib/tools/phantomas/phantomasWrapper.js @@ -47,7 +47,8 @@ var PhantomasWrapper = function() { // Mandatory 'analyze-css': true, - 'ignoreSslErrors': true + 'ignoreSslErrors': true, // until Phantomas 2.1 + 'ignore-ssl-errors': true // for Phantomas >= 2.2 };