From 3b21571e4cb03591666286183e11e4a31086acf1 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 10:53:15 -0400 Subject: [PATCH 01/66] relevatehealthBidAdapter.js: bugfix for storage used without consent --- modules/relevatehealthBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/relevatehealthBidAdapter.js b/modules/relevatehealthBidAdapter.js index 1d60e7f67cc..6e50a0c526a 100644 --- a/modules/relevatehealthBidAdapter.js +++ b/modules/relevatehealthBidAdapter.js @@ -142,7 +142,7 @@ function buildUser(bid) { if (bid && bid.params) { return { id: bid.params.user_id && typeof bid.params.user_id == 'string' ? bid.params.user_id : '', - buyeruid: localStorage.getItem('adx_profile_guid') ? localStorage.getItem('adx_profile_guid') : '', + buyeruid: '', keywords: bid.params.keywords && typeof bid.params.keywords == 'string' ? bid.params.keywords : '', customdata: bid.params.customdata && typeof bid.params.customdata == 'string' ? bid.params.customdata : '' }; From 0491a7e94a33bef0c8f73b9d86081d4fb4968430 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:01:40 -0400 Subject: [PATCH 02/66] Update index.js --- plugins/eslint/index.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 5041675f6ad..bfd8b21503c 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -71,6 +71,43 @@ module.exports = { } } } + }, + 'no-cookie-or-localstorage': { + meta: { + docs: { + description: 'Disallow use of document.cookie or localStorage in files matching *BidAdapter.js' + }, + messages: { + noCookie: 'Usage of document.cookie is not allowed in *BidAdapter.js files.', + noLocalStorage: 'Usage of localStorage is not allowed in *BidAdapter.js files.', + } + }, + create: function(context) { + const filename = context.getFilename(); + const isBidAdapterFile = /.*BidAdapter\.js$/.test(filename); + + if (!isBidAdapterFile) { + return {}; + } + + return { + MemberExpression(node) { + if ( + (node.object.name === 'document' && node.property.name === 'cookie') || + (node.object.name === 'localStorage' && + (node.property.name === 'getItem' || + node.property.name === 'setItem' || + node.property.name === 'removeItem' || + node.property.name === 'clear')) + ) { + context.report({ + node, + messageId: node.object.name === 'document' ? 'noCookie' : 'noLocalStorage', + }); + } + } + } + } } } }; From c624d7472b276b2ff2d7200915d03b4b6d25c94f Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:04:41 -0400 Subject: [PATCH 03/66] Update index.js --- plugins/eslint/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index bfd8b21503c..5133c2e2bd4 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -94,10 +94,10 @@ module.exports = { MemberExpression(node) { if ( (node.object.name === 'document' && node.property.name === 'cookie') || - (node.object.name === 'localStorage' && - (node.property.name === 'getItem' || - node.property.name === 'setItem' || - node.property.name === 'removeItem' || + (node.object.name === 'localStorage' && + (node.property.name === 'getItem' || + node.property.name === 'setItem' || + node.property.name === 'removeItem' || node.property.name === 'clear')) ) { context.report({ From b81d4dc167c65dbd9bfc69bd682311ec1e3e905a Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:11:23 -0400 Subject: [PATCH 04/66] Update index.js --- plugins/eslint/index.js | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 5133c2e2bd4..34dd6420a5c 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -108,6 +108,51 @@ module.exports = { } } } + }, + 'no-dom-manipulation': { + meta: { + docs: { + description: 'Disallow use of methods to insert elements into the document in files matching *BidAdapter.js' + }, + messages: { + noInsertElement: 'Usage of insertElement is not allowed in *BidAdapter.js files.', + noAppendChild: 'Usage of appendChild is not allowed in *BidAdapter.js files.', + noDomManipulation: 'Direct DOM manipulation is not allowed in *BidAdapter.js files.' + } + }, + create: function(context) { + const filename = context.getFilename(); + const isBidAdapterFile = /.*BidAdapter\.js$/.test(filename); + + if (!isBidAdapterFile) { + return {}; + } + + return { + CallExpression(node) { + const calleeName = node.callee.name; + if (calleeName === 'insertElement' || calleeName === 'appendChild' || + calleeName === 'insertBefore' || calleeName === 'replaceChild' || + calleeName === 'createElement' || calleeName === 'createElementNS' || + calleeName === 'createDocumentFragment' || + calleeName === 'innerHTML') { + context.report({ + node, + messageId: calleeName === 'insertElement' ? 'noInsertElement' : + calleeName === 'appendChild' ? 'noAppendChild' : 'noDomManipulation' + }); + } + }, + MemberExpression(node) { + if (node.property && node.property.name === 'innerHTML') { + context.report({ + node: node.property, + messageId: 'noDomManipulation', + }); + } + } + } + } } } }; From 5971e5a63ddd185c0b1ab939f85754c5d1091e87 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:29:36 -0400 Subject: [PATCH 05/66] Update index.js --- plugins/eslint/index.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 34dd6420a5c..a33c3f8a228 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -78,8 +78,8 @@ module.exports = { description: 'Disallow use of document.cookie or localStorage in files matching *BidAdapter.js' }, messages: { - noCookie: 'Usage of document.cookie is not allowed in *BidAdapter.js files.', - noLocalStorage: 'Usage of localStorage is not allowed in *BidAdapter.js files.', + noCookie: 'Usage of document.cookie is not allowed in *BidAdapter.js files. Use storageManager instead.', + noLocalStorage: 'Usage of localStorage is not allowed in *BidAdapter.js files. Use storageManager instead.', } }, create: function(context) { @@ -115,9 +115,9 @@ module.exports = { description: 'Disallow use of methods to insert elements into the document in files matching *BidAdapter.js' }, messages: { - noInsertElement: 'Usage of insertElement is not allowed in *BidAdapter.js files.', - noAppendChild: 'Usage of appendChild is not allowed in *BidAdapter.js files.', - noDomManipulation: 'Direct DOM manipulation is not allowed in *BidAdapter.js files.' + noInsertElement: 'Usage of insertElement is not allowed in *BidAdapter.js files. Import our methods instead.', + noAppendChild: 'Usage of appendChild is not allowed in *BidAdapter.js files. Import our methods instead.', + noDomManipulation: 'Direct DOM manipulation is not allowed in *BidAdapter.js files. Import our methods instead.' } }, create: function(context) { @@ -138,8 +138,12 @@ module.exports = { calleeName === 'innerHTML') { context.report({ node, - messageId: calleeName === 'insertElement' ? 'noInsertElement' : - calleeName === 'appendChild' ? 'noAppendChild' : 'noDomManipulation' + messageId: + calleeName === 'insertElement' + ? 'noInsertElement' + : calleeName === 'appendChild' + ? 'noAppendChild' + : 'noDomManipulation' }); } }, From a2cdfa0a6fdca30b1f770a1d775a2369f6e8883a Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:33:39 -0400 Subject: [PATCH 06/66] Update index.js --- plugins/eslint/index.js | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index a33c3f8a228..db8e62fd36b 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -157,6 +157,55 @@ module.exports = { } } } + }, + 'no-direct-network-requests': { + meta: { + docs: { + description: 'Disallow direct use of network requests methods (navigator.sendBeacon, XMLHttpRequest, fetch) in files matching *BidAdapter.js' + }, + messages: { + noSendBeacon: 'Usage of navigator.sendBeacon is not allowed in *BidAdapter.js files.', + noXMLHttpRequest: 'Usage of XMLHttpRequest is not allowed in *BidAdapter.js files.', + noFetch: 'Usage of fetch is not allowed in *BidAdapter.js files.', + } + }, + create: function(context) { + const filename = context.getFilename(); + const isBidAdapterFile = /.*BidAdapter\.js$/.test(filename); + + if (!isBidAdapterFile) { + return {}; + } + + return { + MemberExpression(node) { + if (node.object.name === 'navigator' && node.property.name === 'sendBeacon') { + context.report({ + node, + messageId: 'noSendBeacon', + }); + } + }, + NewExpression(node) { + if (node.callee.name === 'XMLHttpRequest') { + context.report({ + node, + messageId: 'noXMLHttpRequest', + }); + } + }, + CallExpression(node) { + const calleeName = node.callee.name; + if (calleeName === 'fetch') { + context.report({ + node, + messageId: 'noFetch', + }); + } + } + } + } } } }; + From 847c994defb0df411fa24bf526b1d8da2d1dc534 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:34:24 -0400 Subject: [PATCH 07/66] Update index.js --- plugins/eslint/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index db8e62fd36b..f2a1b787404 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -164,14 +164,14 @@ module.exports = { description: 'Disallow direct use of network requests methods (navigator.sendBeacon, XMLHttpRequest, fetch) in files matching *BidAdapter.js' }, messages: { - noSendBeacon: 'Usage of navigator.sendBeacon is not allowed in *BidAdapter.js files.', - noXMLHttpRequest: 'Usage of XMLHttpRequest is not allowed in *BidAdapter.js files.', - noFetch: 'Usage of fetch is not allowed in *BidAdapter.js files.', + noSendBeacon: 'Usage of navigator.sendBeacon is not allowed in *Adapter.js files.', + noXMLHttpRequest: 'Usage of XMLHttpRequest is not allowed in *Adapter.js files.', + noFetch: 'Usage of fetch is not allowed in *Adapter.js files.', } }, create: function(context) { const filename = context.getFilename(); - const isBidAdapterFile = /.*BidAdapter\.js$/.test(filename); + const isBidAdapterFile = /.*Adapter\.js$/.test(filename); if (!isBidAdapterFile) { return {}; @@ -208,4 +208,3 @@ module.exports = { } } }; - From 9f494c9ab6c9b16e3d071b7d91ed0c1e65be40c3 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:35:04 -0400 Subject: [PATCH 08/66] Update index.js --- plugins/eslint/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index f2a1b787404..126f8db844a 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -75,11 +75,11 @@ module.exports = { 'no-cookie-or-localstorage': { meta: { docs: { - description: 'Disallow use of document.cookie or localStorage in files matching *BidAdapter.js' + description: 'Disallow use of document.cookie or localStorage in files matching *Adapter.js' }, messages: { - noCookie: 'Usage of document.cookie is not allowed in *BidAdapter.js files. Use storageManager instead.', - noLocalStorage: 'Usage of localStorage is not allowed in *BidAdapter.js files. Use storageManager instead.', + noCookie: 'Usage of document.cookie is not allowed in *Adapter.js files. Use storageManager instead.', + noLocalStorage: 'Usage of localStorage is not allowed in *Adapter.js files. Use storageManager instead.', } }, create: function(context) { @@ -161,7 +161,7 @@ module.exports = { 'no-direct-network-requests': { meta: { docs: { - description: 'Disallow direct use of network requests methods (navigator.sendBeacon, XMLHttpRequest, fetch) in files matching *BidAdapter.js' + description: 'Disallow direct use of network requests methods (navigator.sendBeacon, XMLHttpRequest, fetch) in files matching *Adapter.js' }, messages: { noSendBeacon: 'Usage of navigator.sendBeacon is not allowed in *Adapter.js files.', From 4967683676500af0625332aa7b7b0f6eca68e3f5 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:39:49 -0400 Subject: [PATCH 09/66] Update index.js --- plugins/eslint/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 126f8db844a..fac8c453a94 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -142,8 +142,8 @@ module.exports = { calleeName === 'insertElement' ? 'noInsertElement' : calleeName === 'appendChild' - ? 'noAppendChild' - : 'noDomManipulation' + ? 'noAppendChild' + : 'noDomManipulation' }); } }, From 054fbca1f32e052fa2a2f0ca4ea231f8b2b5619f Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:43:47 -0400 Subject: [PATCH 10/66] Update relevatehealthBidAdapter.js --- modules/relevatehealthBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/relevatehealthBidAdapter.js b/modules/relevatehealthBidAdapter.js index 6e50a0c526a..54609daa65d 100644 --- a/modules/relevatehealthBidAdapter.js +++ b/modules/relevatehealthBidAdapter.js @@ -142,7 +142,7 @@ function buildUser(bid) { if (bid && bid.params) { return { id: bid.params.user_id && typeof bid.params.user_id == 'string' ? bid.params.user_id : '', - buyeruid: '', + buyeruid: localStorage.getItem('adx_profile_guid') ? localStorage.getItem('adx_profile_guid') : 'testing the linter', keywords: bid.params.keywords && typeof bid.params.keywords == 'string' ? bid.params.keywords : '', customdata: bid.params.customdata && typeof bid.params.customdata == 'string' ? bid.params.customdata : '' }; From 78a76238bbd025d5de2da3e7ec215db95c52075c Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 11:53:58 -0400 Subject: [PATCH 11/66] Update index.js --- plugins/eslint/index.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index fac8c453a94..d14ca0a3b48 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -75,11 +75,11 @@ module.exports = { 'no-cookie-or-localstorage': { meta: { docs: { - description: 'Disallow use of document.cookie or localStorage in files matching *Adapter.js' + description: 'Disallow use of document.cookie or localStorage in files matching *BidAdapter.js' }, messages: { - noCookie: 'Usage of document.cookie is not allowed in *Adapter.js files. Use storageManager instead.', - noLocalStorage: 'Usage of localStorage is not allowed in *Adapter.js files. Use storageManager instead.', + noCookie: 'Usage of document.cookie is not allowed in *BidAdapter.js files.', + noLocalStorage: 'Usage of localStorage is not allowed in *BidAdapter.js files.', } }, create: function(context) { @@ -92,17 +92,16 @@ module.exports = { return { MemberExpression(node) { - if ( - (node.object.name === 'document' && node.property.name === 'cookie') || - (node.object.name === 'localStorage' && - (node.property.name === 'getItem' || - node.property.name === 'setItem' || - node.property.name === 'removeItem' || - node.property.name === 'clear')) - ) { + if (node.object.name === 'document' && node.property.name === 'cookie') { context.report({ node, - messageId: node.object.name === 'document' ? 'noCookie' : 'noLocalStorage', + messageId: 'noCookie', + }); + } + if (node.object.name === 'localStorage') { + context.report({ + node, + messageId: 'noLocalStorage', }); } } From 68b864e7f8df3614b0ebc0f884db04936184fc80 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 12:00:27 -0400 Subject: [PATCH 12/66] Update index.js --- plugins/eslint/index.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index d14ca0a3b48..86981bfffa7 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -83,13 +83,6 @@ module.exports = { } }, create: function(context) { - const filename = context.getFilename(); - const isBidAdapterFile = /.*BidAdapter\.js$/.test(filename); - - if (!isBidAdapterFile) { - return {}; - } - return { MemberExpression(node) { if (node.object.name === 'document' && node.property.name === 'cookie') { From 886ebc121fb1fade40edb509654ca75391a55c13 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 12:11:33 -0400 Subject: [PATCH 13/66] Update index.js --- plugins/eslint/index.js | 49 ++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 86981bfffa7..4ce214bff6d 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -9,7 +9,7 @@ module.exports = { description: '.outerText property on DOM elements should not be used due to performance issues' }, messages: { - noInnerText: 'Use of `.outerText` is not allowed. Use `.textContent` instead.', + noOuterText: 'Use of `.outerText` is not allowed. Use `.textContent` instead.', } }, create: function(context) { @@ -22,7 +22,7 @@ module.exports = { }); } } - } + }; } }, 'no-innerText': { @@ -44,7 +44,7 @@ module.exports = { }); } } - } + }; } }, 'validate-imports': { @@ -69,7 +69,7 @@ module.exports = { let importPath = node.source.value.trim(); flagErrors(context, node, importPath); } - } + }; } }, 'no-cookie-or-localstorage': { @@ -83,22 +83,30 @@ module.exports = { } }, create: function(context) { + const filename = context.getFilename(); + const isBidAdapterFile = /.*BidAdapter\.js$/.test(filename); + + if (!isBidAdapterFile) { + return {}; + } + return { MemberExpression(node) { - if (node.object.name === 'document' && node.property.name === 'cookie') { - context.report({ - node, - messageId: 'noCookie', - }); - } - if (node.object.name === 'localStorage') { + if ( + (node.object.name === 'document' && node.property.name === 'cookie') || + (node.object.name === 'localStorage' && + (node.property.name === 'getItem' || + node.property.name === 'setItem' || + node.property.name === 'removeItem' || + node.property.name === 'clear')) + ) { context.report({ node, - messageId: 'noLocalStorage', + messageId: node.object.name === 'document' ? 'noCookie' : 'noLocalStorage', }); } } - } + }; } }, 'no-dom-manipulation': { @@ -123,11 +131,12 @@ module.exports = { return { CallExpression(node) { const calleeName = node.callee.name; - if (calleeName === 'insertElement' || calleeName === 'appendChild' || - calleeName === 'insertBefore' || calleeName === 'replaceChild' || - calleeName === 'createElement' || calleeName === 'createElementNS' || - calleeName === 'createDocumentFragment' || - calleeName === 'innerHTML') { + if ( + calleeName === 'insertElement' || calleeName === 'appendChild' || + calleeName === 'insertBefore' || calleeName === 'replaceChild' || + calleeName === 'createElement' || calleeName === 'createElementNS' || + calleeName === 'createDocumentFragment' || calleeName === 'innerHTML' + ) { context.report({ node, messageId: @@ -147,7 +156,7 @@ module.exports = { }); } } - } + }; } }, 'no-direct-network-requests': { @@ -195,7 +204,7 @@ module.exports = { }); } } - } + }; } } } From ff8a0be5f2644d47c168528ad0d9cadec10afb2d Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 12:20:39 -0400 Subject: [PATCH 14/66] Update index.js --- plugins/eslint/index.js | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 4ce214bff6d..4b36e022edc 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -75,21 +75,14 @@ module.exports = { 'no-cookie-or-localstorage': { meta: { docs: { - description: 'Disallow use of document.cookie or localStorage in files matching *BidAdapter.js' + description: 'Disallow use of document.cookie or localStorage' }, messages: { - noCookie: 'Usage of document.cookie is not allowed in *BidAdapter.js files.', - noLocalStorage: 'Usage of localStorage is not allowed in *BidAdapter.js files.', + noCookie: 'Usage of document.cookie is not allowed', + noLocalStorage: 'Usage of localStorage is not allowed', } }, create: function(context) { - const filename = context.getFilename(); - const isBidAdapterFile = /.*BidAdapter\.js$/.test(filename); - - if (!isBidAdapterFile) { - return {}; - } - return { MemberExpression(node) { if ( @@ -115,19 +108,12 @@ module.exports = { description: 'Disallow use of methods to insert elements into the document in files matching *BidAdapter.js' }, messages: { - noInsertElement: 'Usage of insertElement is not allowed in *BidAdapter.js files. Import our methods instead.', - noAppendChild: 'Usage of appendChild is not allowed in *BidAdapter.js files. Import our methods instead.', - noDomManipulation: 'Direct DOM manipulation is not allowed in *BidAdapter.js files. Import our methods instead.' + noInsertElement: 'Usage of insertElement is not allowed. Import our methods instead.', + noAppendChild: 'Usage of appendChild is not allowed. Import our methods instead.', + noDomManipulation: 'Direct DOM manipulation is not allowed. Import our methods instead.' } }, create: function(context) { - const filename = context.getFilename(); - const isBidAdapterFile = /.*BidAdapter\.js$/.test(filename); - - if (!isBidAdapterFile) { - return {}; - } - return { CallExpression(node) { const calleeName = node.callee.name; @@ -162,22 +148,15 @@ module.exports = { 'no-direct-network-requests': { meta: { docs: { - description: 'Disallow direct use of network requests methods (navigator.sendBeacon, XMLHttpRequest, fetch) in files matching *Adapter.js' + description: 'Disallow direct use of network requests methods (navigator.sendBeacon, XMLHttpRequest, fetch)' }, messages: { - noSendBeacon: 'Usage of navigator.sendBeacon is not allowed in *Adapter.js files.', - noXMLHttpRequest: 'Usage of XMLHttpRequest is not allowed in *Adapter.js files.', - noFetch: 'Usage of fetch is not allowed in *Adapter.js files.', + noSendBeacon: 'Usage of navigator.sendBeacon is not allowed', + noXMLHttpRequest: 'Usage of XMLHttpRequest is not allowed', + noFetch: 'Usage of fetch is not allowed', } }, create: function(context) { - const filename = context.getFilename(); - const isBidAdapterFile = /.*Adapter\.js$/.test(filename); - - if (!isBidAdapterFile) { - return {}; - } - return { MemberExpression(node) { if (node.object.name === 'navigator' && node.property.name === 'sendBeacon') { From dbc3aa2933729ede7ce426d7293126edd8216fa5 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 12:21:05 -0400 Subject: [PATCH 15/66] Update index.js --- plugins/eslint/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 4b36e022edc..83dd62c50b6 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -105,7 +105,7 @@ module.exports = { 'no-dom-manipulation': { meta: { docs: { - description: 'Disallow use of methods to insert elements into the document in files matching *BidAdapter.js' + description: 'Disallow use of methods to insert elements into the document' }, messages: { noInsertElement: 'Usage of insertElement is not allowed. Import our methods instead.', From 7294b36fee4acc7cce1d6916da9651a3ba4ee5bf Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 12:35:15 -0400 Subject: [PATCH 16/66] Update .eslintrc.js --- .eslintrc.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 184b042813d..3a9761cc373 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -83,7 +83,11 @@ module.exports = { files: key + '/**/*.js', rules: { 'prebid/validate-imports': ['error', allowedModules[key]], - 'prebid/no-innerText': ['error', allowedModules[key]], + 'prebid/no-innerText': 'error', + 'prebid/no-outerText': 'error', + 'prebid/no-cookie-or-localstorage': 'error', + 'prebid/no-dom-manipulation': 'error', + 'prebid/no-direct-network-requests': 'error', 'no-restricted-globals': [ 'error', { From 7e66b620447315d112882db3ec21b6af058e2189 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 13:28:10 -0400 Subject: [PATCH 17/66] Update index.js --- plugins/eslint/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 83dd62c50b6..4634bab4476 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -83,6 +83,12 @@ module.exports = { } }, create: function(context) { + const filename = context.getFilename(); + const isAdapterFile = /.*Adapter\.js$/.test(filename); + + if (!isAdapterFile) { + return {}; + } return { MemberExpression(node) { if ( @@ -114,6 +120,12 @@ module.exports = { } }, create: function(context) { + const filename = context.getFilename(); + const isAdapterFile = /.*Adapter\.js$/.test(filename); + + if (!isAdapterFile) { + return {}; + } return { CallExpression(node) { const calleeName = node.callee.name; @@ -157,6 +169,12 @@ module.exports = { } }, create: function(context) { + const filename = context.getFilename(); + const isAdapterFile = /.*Adapter\.js$/.test(filename); + + if (!isAdapterFile) { + return {}; + } return { MemberExpression(node) { if (node.object.name === 'navigator' && node.property.name === 'sendBeacon') { From 5fa5a52674c696c6949b04e6d6d4869b5d6d5d97 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 13:29:46 -0400 Subject: [PATCH 18/66] Update relevatehealthBidAdapter.js --- modules/relevatehealthBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/relevatehealthBidAdapter.js b/modules/relevatehealthBidAdapter.js index 54609daa65d..6e50a0c526a 100644 --- a/modules/relevatehealthBidAdapter.js +++ b/modules/relevatehealthBidAdapter.js @@ -142,7 +142,7 @@ function buildUser(bid) { if (bid && bid.params) { return { id: bid.params.user_id && typeof bid.params.user_id == 'string' ? bid.params.user_id : '', - buyeruid: localStorage.getItem('adx_profile_guid') ? localStorage.getItem('adx_profile_guid') : 'testing the linter', + buyeruid: '', keywords: bid.params.keywords && typeof bid.params.keywords == 'string' ? bid.params.keywords : '', customdata: bid.params.customdata && typeof bid.params.customdata == 'string' ? bid.params.customdata : '' }; From f885004e2a2ab33edb20373b27c865aed912b7f6 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 13:32:35 -0400 Subject: [PATCH 19/66] Update 33acrossAnalyticsAdapter.js --- modules/33acrossAnalyticsAdapter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/33acrossAnalyticsAdapter.js b/modules/33acrossAnalyticsAdapter.js index 890c963fa71..ddc2d07b97d 100644 --- a/modules/33acrossAnalyticsAdapter.js +++ b/modules/33acrossAnalyticsAdapter.js @@ -629,6 +629,8 @@ function setCachedBidStatus(auctionId, bidId, status) { * @param {string} endpoint URL */ function sendReport(report, endpoint) { + //TODO FIX THIS RULES VIOLATION + // eslint-disable-next-line no-direct-network-requests if (navigator.sendBeacon(endpoint, JSON.stringify(report))) { log.info(`Analytics report sent to ${endpoint}`, report); From 6c9691283720c05de6978d496648872f54769dd2 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:01:06 -0400 Subject: [PATCH 20/66] Update index.js --- plugins/eslint/index.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 4634bab4476..0973e0acc9c 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -163,9 +163,8 @@ module.exports = { description: 'Disallow direct use of network requests methods (navigator.sendBeacon, XMLHttpRequest, fetch)' }, messages: { - noSendBeacon: 'Usage of navigator.sendBeacon is not allowed', - noXMLHttpRequest: 'Usage of XMLHttpRequest is not allowed', - noFetch: 'Usage of fetch is not allowed', + noSendBeacon: 'Usage of navigator.sendBeacon and window.fetch are not allowed', + noXMLHttpRequest: 'Usage of XMLHttpRequest is not allowed' } }, create: function(context) { @@ -177,10 +176,11 @@ module.exports = { } return { MemberExpression(node) { - if (node.object.name === 'navigator' && node.property.name === 'sendBeacon') { + if (node.object.name === 'navigator' && node.property.name === 'sendBeacon') || + (node.object.name === 'window' && node.property.name === 'fetch') { context.report({ node, - messageId: 'noSendBeacon', + messageId: 'noSendBeacon or window.fetch', }); } }, @@ -191,15 +191,6 @@ module.exports = { messageId: 'noXMLHttpRequest', }); } - }, - CallExpression(node) { - const calleeName = node.callee.name; - if (calleeName === 'fetch') { - context.report({ - node, - messageId: 'noFetch', - }); - } } }; } From fcdce604877ae574747686883cda0eb41d4e0ee3 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:11:23 -0400 Subject: [PATCH 21/66] Update index.js --- plugins/eslint/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 0973e0acc9c..8ea85add3bf 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -176,8 +176,10 @@ module.exports = { } return { MemberExpression(node) { - if (node.object.name === 'navigator' && node.property.name === 'sendBeacon') || - (node.object.name === 'window' && node.property.name === 'fetch') { + if ( + (node.object.name === 'navigator' && node.property.name === 'sendBeacon') || + (node.object.name === 'window' && node.property.name === 'fetch') + ) { context.report({ node, messageId: 'noSendBeacon or window.fetch', From f3d5b01efbeb2764ada343089641319274ed9f9e Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:17:35 -0400 Subject: [PATCH 22/66] Update 33acrossAnalyticsAdapter.js --- modules/33acrossAnalyticsAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/33acrossAnalyticsAdapter.js b/modules/33acrossAnalyticsAdapter.js index ddc2d07b97d..1de986cd28e 100644 --- a/modules/33acrossAnalyticsAdapter.js +++ b/modules/33acrossAnalyticsAdapter.js @@ -629,8 +629,8 @@ function setCachedBidStatus(auctionId, bidId, status) { * @param {string} endpoint URL */ function sendReport(report, endpoint) { - //TODO FIX THIS RULES VIOLATION - // eslint-disable-next-line no-direct-network-requests + // TODO FIX THIS RULES VIOLATION + // eslint-disable-next-line if (navigator.sendBeacon(endpoint, JSON.stringify(report))) { log.info(`Analytics report sent to ${endpoint}`, report); From 43c76c00bed19f0b3ec5ad3c2ffa2ba56210be0e Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:33:12 -0400 Subject: [PATCH 23/66] Update index.js --- plugins/eslint/index.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 8ea85add3bf..c5872d9e827 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -83,12 +83,6 @@ module.exports = { } }, create: function(context) { - const filename = context.getFilename(); - const isAdapterFile = /.*Adapter\.js$/.test(filename); - - if (!isAdapterFile) { - return {}; - } return { MemberExpression(node) { if ( @@ -120,12 +114,6 @@ module.exports = { } }, create: function(context) { - const filename = context.getFilename(); - const isAdapterFile = /.*Adapter\.js$/.test(filename); - - if (!isAdapterFile) { - return {}; - } return { CallExpression(node) { const calleeName = node.callee.name; @@ -168,21 +156,15 @@ module.exports = { } }, create: function(context) { - const filename = context.getFilename(); - const isAdapterFile = /.*Adapter\.js$/.test(filename); - - if (!isAdapterFile) { - return {}; - } return { MemberExpression(node) { if ( (node.object.name === 'navigator' && node.property.name === 'sendBeacon') || (node.object.name === 'window' && node.property.name === 'fetch') - ) { + ) { context.report({ node, - messageId: 'noSendBeacon or window.fetch', + messageId: 'noSendBeacon', }); } }, From 75a3ab48e53b107fea50b99dbb7e5957bcb7084a Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:38:50 -0400 Subject: [PATCH 24/66] Update ampliffyBidAdapter.js --- modules/ampliffyBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ampliffyBidAdapter.js b/modules/ampliffyBidAdapter.js index e79b04ab4c4..7b32816afeb 100644 --- a/modules/ampliffyBidAdapter.js +++ b/modules/ampliffyBidAdapter.js @@ -292,6 +292,7 @@ export function parseXML(xml, bid) { if (ct) { const companion = xml.getElementsByTagName('Companion')[0]; const htmlResource = companion.getElementsByTagName('HTMLResource')[0]; + // eslint-disable-next-line no-dom-manipulation const htmlContent = document.createElement('html'); htmlContent.innerHTML = htmlResource.textContent; From 383df3030f24394f029ddba748c1e8faf8a45257 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:40:48 -0400 Subject: [PATCH 25/66] Update index.js --- plugins/eslint/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index c5872d9e827..af03d51856b 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -83,6 +83,12 @@ module.exports = { } }, create: function(context) { + const filename = context.getFilename(); + const isAdapterFile = /.*Adapter\.js$/.test(filename); + + if (!isAdapterFile) { + return {}; + } return { MemberExpression(node) { if ( @@ -114,6 +120,12 @@ module.exports = { } }, create: function(context) { + const filename = context.getFilename(); + const isAdapterFile = /.*Adapter\.js$/.test(filename); + + if (!isAdapterFile) { + return {}; + } return { CallExpression(node) { const calleeName = node.callee.name; @@ -156,6 +168,12 @@ module.exports = { } }, create: function(context) { + const filename = context.getFilename(); + const isAdapterFile = /.*Adapter\.js$/.test(filename); + + if (!isAdapterFile) { + return {}; + } return { MemberExpression(node) { if ( From ce78bf0b07758b2d1202cd954b7c9c5c7101085c Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:47:31 -0400 Subject: [PATCH 26/66] Update invibesBidAdapter.js --- modules/invibesBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/invibesBidAdapter.js b/modules/invibesBidAdapter.js index a69311834b2..2b5f86640bb 100644 --- a/modules/invibesBidAdapter.js +++ b/modules/invibesBidAdapter.js @@ -792,6 +792,7 @@ let keywords = (function () { prefix = prefix || ''; let title = document.title || headTag ? headTag.getElementsByTagName('title')[0] + // eslint-disable-next-line no-dom-manipulation ? headTag.getElementsByTagName('title')[0].innerHTML : '' : ''; From 1e70fa51d9282ffa24b545be2a79b45dd810e007 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:51:10 -0400 Subject: [PATCH 27/66] Update growthCodeAnalyticsAdapter.js --- modules/growthCodeAnalyticsAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/growthCodeAnalyticsAdapter.js b/modules/growthCodeAnalyticsAdapter.js index 1bd7a80afa7..7696cd14610 100644 --- a/modules/growthCodeAnalyticsAdapter.js +++ b/modules/growthCodeAnalyticsAdapter.js @@ -140,7 +140,7 @@ function logToServer() { if (pid === DEFAULT_PID) return; if (eventQueue.length >= 1) { // Get the correct GCID - let gcid = localStorage.getItem('gcid') + let gcid = storage.getDataFromLocalStorage('gcid')) let data = { session: sessionId, From 93ae8a14babb504687a0bc98d5b2d7160e487d7f Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:55:51 -0400 Subject: [PATCH 28/66] Update fintezaAnalyticsAdapter.js --- modules/fintezaAnalyticsAdapter.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/modules/fintezaAnalyticsAdapter.js b/modules/fintezaAnalyticsAdapter.js index ab41272c85f..62a7dfc957e 100644 --- a/modules/fintezaAnalyticsAdapter.js +++ b/modules/fintezaAnalyticsAdapter.js @@ -68,12 +68,7 @@ function initFirstVisit() { let now; let visitDate; let cookies; - - try { - cookies = parseCookies(document.cookie); - } catch (a) { - cookies = {}; - } + cookies = {}; visitDate = cookies[ FIRST_VISIT_DATE ]; @@ -171,11 +166,7 @@ function initSession() { let sessionDuration; let isNew = false; - try { - cookies = parseCookies(document.cookie); - } catch (a) { - cookies = {}; - } + cookies = {}; sessionId = cookies[ SESSION_ID ]; @@ -263,7 +254,7 @@ function getTrackRequestLastTime() { ); } - cookie = parseCookies(document.cookie); + cookie = {}; cookie = cookie[ TRACK_TIME_KEY ]; if (cookie) { return parseInt(cookie, 10); From 28f335efda84c544b2bd44672dcaf41c71a8e64b Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:56:54 -0400 Subject: [PATCH 29/66] Update growthCodeAnalyticsAdapter.js --- modules/growthCodeAnalyticsAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/growthCodeAnalyticsAdapter.js b/modules/growthCodeAnalyticsAdapter.js index 7696cd14610..0b1f343e4dc 100644 --- a/modules/growthCodeAnalyticsAdapter.js +++ b/modules/growthCodeAnalyticsAdapter.js @@ -140,7 +140,7 @@ function logToServer() { if (pid === DEFAULT_PID) return; if (eventQueue.length >= 1) { // Get the correct GCID - let gcid = storage.getDataFromLocalStorage('gcid')) + let gcid = storage.getDataFromLocalStorage('gcid'); let data = { session: sessionId, From 66ec05cb80a04f36c4a364c69c837ebd3ecc2122 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:58:28 -0400 Subject: [PATCH 30/66] Update etargetBidAdapter.js --- modules/etargetBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/etargetBidAdapter.js b/modules/etargetBidAdapter.js index 1653d849297..5d144297ad4 100644 --- a/modules/etargetBidAdapter.js +++ b/modules/etargetBidAdapter.js @@ -89,6 +89,7 @@ export const spec = { } } } + // eslint-disable-next-line no-dom-manipulation mts['title'] = [(document.getElementsByTagName('title')[0] || []).innerHTML]; mts['base'] = [(document.getElementsByTagName('base')[0] || {}).href]; mts['referer'] = [document.location.href]; From 768f252a53d81a252683a6c22badb5f2a99ab28a Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 15:59:46 -0400 Subject: [PATCH 31/66] Update dspxBidAdapter.js --- modules/dspxBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/dspxBidAdapter.js b/modules/dspxBidAdapter.js index 2b819789ec1..28e627b0b1c 100644 --- a/modules/dspxBidAdapter.js +++ b/modules/dspxBidAdapter.js @@ -1,3 +1,4 @@ +// eslint-disable no-dom-manipulation import {deepAccess, getBidIdParameter, isFn, logError, logMessage, logWarn} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; From 88ad00710da0e756c4e0dc92f19ca021c420b42c Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:02:51 -0400 Subject: [PATCH 32/66] Update cwireBidAdapter.js --- modules/cwireBidAdapter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/cwireBidAdapter.js b/modules/cwireBidAdapter.js index f878be5f66a..1b2f6cb1e0f 100644 --- a/modules/cwireBidAdapter.js +++ b/modules/cwireBidAdapter.js @@ -224,6 +224,8 @@ export const spec = { bid: bid } } + // TODO FIX THIS RULES VIOLATION + // eslint-disable-next-line no-direct-network-requests navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, @@ -236,6 +238,8 @@ export const spec = { bidderRequest: bidderRequest } } + // TODO FIX THIS RULES VIOLATION + // eslint-disable-next-line no-direct-network-requests navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, From 5ad7fe93fc93d2e98f40e4071e3c166dcd0506f4 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:04:35 -0400 Subject: [PATCH 33/66] Update cwireBidAdapter.js --- modules/cwireBidAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/cwireBidAdapter.js b/modules/cwireBidAdapter.js index 1b2f6cb1e0f..87fdd305a01 100644 --- a/modules/cwireBidAdapter.js +++ b/modules/cwireBidAdapter.js @@ -225,7 +225,7 @@ export const spec = { } } // TODO FIX THIS RULES VIOLATION - // eslint-disable-next-line no-direct-network-requests + // eslint-disable-next-line prebid/no-direct-network-requests navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, @@ -239,7 +239,7 @@ export const spec = { } } // TODO FIX THIS RULES VIOLATION - // eslint-disable-next-line no-direct-network-requests + // eslint-disable-next-line prebid/no-direct-network-requests navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, From bbd9533361621ebbef9dd55fceefe0faa9829065 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:05:09 -0400 Subject: [PATCH 34/66] Update ampliffyBidAdapter.js --- modules/ampliffyBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ampliffyBidAdapter.js b/modules/ampliffyBidAdapter.js index 7b32816afeb..9e379ec17d5 100644 --- a/modules/ampliffyBidAdapter.js +++ b/modules/ampliffyBidAdapter.js @@ -292,7 +292,7 @@ export function parseXML(xml, bid) { if (ct) { const companion = xml.getElementsByTagName('Companion')[0]; const htmlResource = companion.getElementsByTagName('HTMLResource')[0]; - // eslint-disable-next-line no-dom-manipulation + // eslint-disable-next-line prebid/no-dom-manipulation const htmlContent = document.createElement('html'); htmlContent.innerHTML = htmlResource.textContent; From 193c91fca8328e3f8ec8cca0e2c7f7595aa6ea39 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:06:01 -0400 Subject: [PATCH 35/66] Update etargetBidAdapter.js --- modules/etargetBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/etargetBidAdapter.js b/modules/etargetBidAdapter.js index 5d144297ad4..f05e2c1f9d7 100644 --- a/modules/etargetBidAdapter.js +++ b/modules/etargetBidAdapter.js @@ -89,7 +89,7 @@ export const spec = { } } } - // eslint-disable-next-line no-dom-manipulation + // eslint-disable-next-line prebid/no-dom-manipulation mts['title'] = [(document.getElementsByTagName('title')[0] || []).innerHTML]; mts['base'] = [(document.getElementsByTagName('base')[0] || {}).href]; mts['referer'] = [document.location.href]; From c0f2f99f055bebe789449052e2169ce0ec018d32 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:09:01 -0400 Subject: [PATCH 36/66] Update dspxBidAdapter.js --- modules/dspxBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dspxBidAdapter.js b/modules/dspxBidAdapter.js index 28e627b0b1c..8e7562cc8fa 100644 --- a/modules/dspxBidAdapter.js +++ b/modules/dspxBidAdapter.js @@ -1,4 +1,4 @@ -// eslint-disable no-dom-manipulation +// eslint-disable prebid/no-dom-manipulation import {deepAccess, getBidIdParameter, isFn, logError, logMessage, logWarn} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; From 5a7cfa5cd7e8ebfc81cfccdb622a16e2fc972daa Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:10:09 -0400 Subject: [PATCH 37/66] Update fintezaAnalyticsAdapter.js --- modules/fintezaAnalyticsAdapter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/fintezaAnalyticsAdapter.js b/modules/fintezaAnalyticsAdapter.js index 62a7dfc957e..773cc2055e9 100644 --- a/modules/fintezaAnalyticsAdapter.js +++ b/modules/fintezaAnalyticsAdapter.js @@ -93,7 +93,7 @@ function trim(string) { } return string.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); } - +/* function parseCookies(cookie) { let values = {}; let arr, item; @@ -125,6 +125,7 @@ function parseCookies(cookie) { return values; } +*/ function getRandAsStr(digits) { let str = ''; From 07e187a8ee22f68ced41d735d59cb88004ef706c Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:11:17 -0400 Subject: [PATCH 38/66] Update ampliffyBidAdapter.js --- modules/ampliffyBidAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ampliffyBidAdapter.js b/modules/ampliffyBidAdapter.js index 9e379ec17d5..ab0b7a7d0ca 100644 --- a/modules/ampliffyBidAdapter.js +++ b/modules/ampliffyBidAdapter.js @@ -294,6 +294,7 @@ export function parseXML(xml, bid) { const htmlResource = companion.getElementsByTagName('HTMLResource')[0]; // eslint-disable-next-line prebid/no-dom-manipulation const htmlContent = document.createElement('html'); + // eslint-disable-next-line prebid/no-dom-manipulation htmlContent.innerHTML = htmlResource.textContent; ret.cpm = extractCPM(htmlContent, ct, ret.cpm); From cae738152b4798d1be87da30196f1ce64f9c203c Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:12:54 -0400 Subject: [PATCH 39/66] Update adlooxAnalyticsAdapter.js --- modules/adlooxAnalyticsAdapter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/adlooxAnalyticsAdapter.js b/modules/adlooxAnalyticsAdapter.js index e31ea290e11..6e7018b85a0 100644 --- a/modules/adlooxAnalyticsAdapter.js +++ b/modules/adlooxAnalyticsAdapter.js @@ -232,6 +232,8 @@ analyticsAdapter[`handle_${EVENTS.AUCTION_END}`] = function(auctionDetails) { link.setAttribute('href', `${uri.protocol}://${uri.host}${uri.pathname}`); link.setAttribute('rel', 'preload'); link.setAttribute('as', 'script'); + // TODO fix rules violation + // eslint-disable-next-line prebid/no-dom-manipulation insertElement(link); } From 1a9fe3448ebedbd43c099414e8bbdd66a8da52b0 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:16:28 -0400 Subject: [PATCH 40/66] Update invibesBidAdapter.js --- modules/invibesBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/invibesBidAdapter.js b/modules/invibesBidAdapter.js index 2b5f86640bb..2a53dfa1ebf 100644 --- a/modules/invibesBidAdapter.js +++ b/modules/invibesBidAdapter.js @@ -792,7 +792,7 @@ let keywords = (function () { prefix = prefix || ''; let title = document.title || headTag ? headTag.getElementsByTagName('title')[0] - // eslint-disable-next-line no-dom-manipulation + // eslint-disable-next-line prebid/no-dom-manipulation ? headTag.getElementsByTagName('title')[0].innerHTML : '' : ''; From 874b7f388efbccf7d9ea5772f996586a703e4e90 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:17:10 -0400 Subject: [PATCH 41/66] Update fintezaAnalyticsAdapter.js --- modules/fintezaAnalyticsAdapter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/fintezaAnalyticsAdapter.js b/modules/fintezaAnalyticsAdapter.js index 773cc2055e9..40456860fac 100644 --- a/modules/fintezaAnalyticsAdapter.js +++ b/modules/fintezaAnalyticsAdapter.js @@ -86,14 +86,14 @@ function initFirstVisit() { return visitDate; } - +/* function trim(string) { if (string.trim) { return string.trim(); } return string.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); } -/* + function parseCookies(cookie) { let values = {}; let arr, item; From 7bbb643d2716c49bf1637d9d806a6097f63114f7 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:18:33 -0400 Subject: [PATCH 42/66] Update dspxBidAdapter.js --- modules/dspxBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/dspxBidAdapter.js b/modules/dspxBidAdapter.js index 8e7562cc8fa..2f5c295f63b 100644 --- a/modules/dspxBidAdapter.js +++ b/modules/dspxBidAdapter.js @@ -1,4 +1,4 @@ -// eslint-disable prebid/no-dom-manipulation +/* eslint-disable prebid/no-dom-manipulation */ import {deepAccess, getBidIdParameter, isFn, logError, logMessage, logWarn} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; From a1b460e5e74faf8d0e97a0951f05a9dc809daa6b Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:23:40 -0400 Subject: [PATCH 43/66] Update connectIdSystem.js --- modules/connectIdSystem.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/connectIdSystem.js b/modules/connectIdSystem.js index 2ebc68baa84..d9edd221c42 100644 --- a/modules/connectIdSystem.js +++ b/modules/connectIdSystem.js @@ -313,11 +313,12 @@ export const connectIdSubmodule = { /** * Utility function that returns a boolean flag indicating if the user - * has opeted out via the Yahoo easy-opt-out mechanism. + * has opted out via the Yahoo easy-opt-out mechanism. * @returns {Boolean} */ userHasOptedOut() { try { + // TODO FIX THIS RULES VIOLATION return localStorage.getItem(OVERRIDE_OPT_OUT_KEY) === '1'; } catch { return false; From fc40a4af81d7e20e7dfdf8730329fbd8d13269e2 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:24:10 -0400 Subject: [PATCH 44/66] Update automatadAnalyticsAdapter.js --- modules/automatadAnalyticsAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/automatadAnalyticsAdapter.js b/modules/automatadAnalyticsAdapter.js index 523e8d558ca..8e72e3d5663 100644 --- a/modules/automatadAnalyticsAdapter.js +++ b/modules/automatadAnalyticsAdapter.js @@ -18,6 +18,7 @@ var isLoggingEnabled; var queuePointer = 0; var retryCount = 0; var timer = null const prettyLog = (level, text, isGroup = false, cb = () => {}) => { if (self.isLoggingEnabled === undefined) { + // TODO FIX THIS RULES VIOLATION if (window.localStorage.getItem('__aggLoggingEnabled')) { self.isLoggingEnabled = true } else { From 8cea733ad364f34ca61ac80139fffb5e0b6109ce Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:27:02 -0400 Subject: [PATCH 45/66] Update sonobiBidAdapter.js --- modules/sonobiBidAdapter.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index edc4f255d18..4008b5cf3d1 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -426,19 +426,13 @@ function loadOrCreateFirstPartyData() { }; var readData = function (key) { if (hasLocalStorage()) { + // TODO FIX RULES VIOLATION return window.localStorage.getItem(key); } return null; }; + // TODO FIX RULES VIOLATION - USE STORAGE MANAGER var hasLocalStorage = function () { - if (typeof localStorageEnabled != 'undefined') { return localStorageEnabled; } else { - try { - localStorageEnabled = !!window.localStorage; - return localStorageEnabled; - } catch (e) { - localStorageEnabled = false; - } - } return false; }; var generateGUID = function () { @@ -452,6 +446,7 @@ function loadOrCreateFirstPartyData() { var storeData = function (key, value) { try { if (hasLocalStorage()) { + // TODO FIX RULES VIOLATION window.localStorage.setItem(key, value); } } catch (error) { From aca39d5936f270a67c521d36799bd86555b34dd7 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 16:27:57 -0400 Subject: [PATCH 46/66] Update contxtfulRtdProvider.js --- modules/contxtfulRtdProvider.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/contxtfulRtdProvider.js b/modules/contxtfulRtdProvider.js index e2bb1f3b909..c4a8b7d87db 100644 --- a/modules/contxtfulRtdProvider.js +++ b/modules/contxtfulRtdProvider.js @@ -36,10 +36,7 @@ function getRxEngineReceptivity(requester) { } function loadSessionReceptivity(requester) { - let sessionStorageValue = sessionStorage.getItem(requester); - if (!sessionStorageValue) { - return null; - } + return null; try { // Check expiration of the cached value From f55e83fbfd9c1078acc534b250cbf825acf8a138 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 17:04:24 -0400 Subject: [PATCH 47/66] Update sonobiBidAdapter.js --- modules/sonobiBidAdapter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 4008b5cf3d1..908c21298e6 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -414,8 +414,6 @@ export function _getPlatform(context = window) { * @return {object} firstPartyData - Data object containing first party information */ function loadOrCreateFirstPartyData() { - var localStorageEnabled; - var FIRST_PARTY_KEY = '_iiq_fdata'; var tryParse = function (data) { try { From 74f711c463d5cc6da2bbfbd870ec267eca00ce81 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 17:05:42 -0400 Subject: [PATCH 48/66] Update contxtfulRtdProvider.js --- modules/contxtfulRtdProvider.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/contxtfulRtdProvider.js b/modules/contxtfulRtdProvider.js index c4a8b7d87db..80979174978 100644 --- a/modules/contxtfulRtdProvider.js +++ b/modules/contxtfulRtdProvider.js @@ -37,20 +37,6 @@ function getRxEngineReceptivity(requester) { function loadSessionReceptivity(requester) { return null; - - try { - // Check expiration of the cached value - let sessionStorageReceptivity = JSON.parse(sessionStorageValue); - let expiration = parseInt(sessionStorageReceptivity?.exp); - if (expiration < new Date().getTime()) { - return null; - } - - let rx = sessionStorageReceptivity?.rx; - return rx; - } catch { - return null; - } }; /** From a29d7d342d5c4a2ada9297f4a716d95f33d79da8 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 17:08:38 -0400 Subject: [PATCH 49/66] Update index.js --- plugins/eslint/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index af03d51856b..bba76beddc3 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -85,8 +85,10 @@ module.exports = { create: function(context) { const filename = context.getFilename(); const isAdapterFile = /.*Adapter\.js$/.test(filename); + const isProviderFile = /.*Provider\.js$/.test(filename); + const isIdSystemFile = /.*IdSystem\.js$/.test(filename); - if (!isAdapterFile) { + if (!isAdapterFile && !isProviderFile && !isIdSystemFile) { return {}; } return { @@ -122,8 +124,10 @@ module.exports = { create: function(context) { const filename = context.getFilename(); const isAdapterFile = /.*Adapter\.js$/.test(filename); + const isProviderFile = /.*Provider\.js$/.test(filename); + const isIdSystemFile = /.*IdSystem\.js$/.test(filename); - if (!isAdapterFile) { + if (!isAdapterFile && !isProviderFile && !isIdSystemFile) { return {}; } return { @@ -170,8 +174,10 @@ module.exports = { create: function(context) { const filename = context.getFilename(); const isAdapterFile = /.*Adapter\.js$/.test(filename); + const isProviderFile = /.*Provider\.js$/.test(filename); + const isIdSystemFile = /.*IdSystem\.js$/.test(filename); - if (!isAdapterFile) { + if (!isAdapterFile && !isProviderFile && !isIdSystemFile) { return {}; } return { From bf13e5961d526fc1d5f7e9d4007831606b3dc610 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 17:14:46 -0400 Subject: [PATCH 50/66] Update cleanioRtdProvider.js --- modules/cleanioRtdProvider.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/cleanioRtdProvider.js b/modules/cleanioRtdProvider.js index c3f3dd51a61..5772c8e8eb3 100644 --- a/modules/cleanioRtdProvider.js +++ b/modules/cleanioRtdProvider.js @@ -49,6 +49,7 @@ function pageInitStepPreloadScript(scriptURL) { linkElement.href = scriptURL; linkElement.onload = () => { preloadStatus = 1; }; linkElement.onerror = () => { preloadStatus = -1; }; + // eslint-disable-next-line prebid/no-dom-manipulation insertElement(linkElement); } From d9c6e50717f2c122d7216001bcc7dd1275de2529 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 17:15:49 -0400 Subject: [PATCH 51/66] Update connectIdSystem.js --- modules/connectIdSystem.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/connectIdSystem.js b/modules/connectIdSystem.js index d9edd221c42..22f92941312 100644 --- a/modules/connectIdSystem.js +++ b/modules/connectIdSystem.js @@ -319,6 +319,7 @@ export const connectIdSubmodule = { userHasOptedOut() { try { // TODO FIX THIS RULES VIOLATION + // eslint-disable-next-line return localStorage.getItem(OVERRIDE_OPT_OUT_KEY) === '1'; } catch { return false; From fa6471d0c3874f7988d0dd453c422efc610acb46 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 17:17:06 -0400 Subject: [PATCH 52/66] Update geoedgeRtdProvider.js --- modules/geoedgeRtdProvider.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/geoedgeRtdProvider.js b/modules/geoedgeRtdProvider.js index 46f7e7f7d6d..51e7f9ee60c 100644 --- a/modules/geoedgeRtdProvider.js +++ b/modules/geoedgeRtdProvider.js @@ -102,6 +102,7 @@ export function markAsLoaded() { export function preloadClient(key) { let iframe = createInvisibleIframe(); iframe.id = 'grumiFrame'; + // eslint-disable-next-line prebid/no-dom-manipulation insertElement(iframe); iframe.contentWindow.grumi = getInitialParams(key); let url = getClientUrl(key); From f8258d4786cf79032d1b82f0e4907ef543e31796 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 17:17:48 -0400 Subject: [PATCH 53/66] Update growthCodeRtdProvider.js --- modules/growthCodeRtdProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/growthCodeRtdProvider.js b/modules/growthCodeRtdProvider.js index b12b25a0951..a8893b9648e 100644 --- a/modules/growthCodeRtdProvider.js +++ b/modules/growthCodeRtdProvider.js @@ -75,7 +75,7 @@ function callServer(configParams, items, expiresAt, userConsent) { storage.removeDataFromLocalStorage(RTD_EXPIRE_KEY, null) } if ((items === null) && (isNaN(expiresAt))) { - let gcid = localStorage.getItem('gcid') + let gcid = storage.getDataFromLocalStorage('gcid') let url = configParams.url ? configParams.url : ENDPOINT_URL; url = tryAppendQueryString(url, 'pid', configParams.pid); From 01a8f4b9274418992ced113a4fec392fc3d454a1 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 17:19:33 -0400 Subject: [PATCH 54/66] Update sirdataRtdProvider.js --- modules/sirdataRtdProvider.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js index 9a222e20f9d..5dce37a51e7 100644 --- a/modules/sirdataRtdProvider.js +++ b/modules/sirdataRtdProvider.js @@ -1,3 +1,4 @@ +/* eslint-disable prebid/no-dom-manipulation */ /** * This module adds Sirdata provider to the real time data module * and now supports Seller Defined Audience @@ -219,6 +220,8 @@ export function postContentForSemanticAnalysis(postContentToken, actualUrl) { // Use the Beacon API if supported to send the payload if ('sendBeacon' in navigator) { + // TODO FIX RULES VIOLATION + // es-lint-disable-next-line prebid/no-direct-network-requests navigator.sendBeacon(url, payload); } else { // Fallback to using AJAX if Beacon API is not supported From db2e7bae719acc83364fe22ca8bd10aeb2c30be3 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 17:23:33 -0400 Subject: [PATCH 55/66] Update sirdataRtdProvider.js --- modules/sirdataRtdProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js index 5dce37a51e7..0593b528928 100644 --- a/modules/sirdataRtdProvider.js +++ b/modules/sirdataRtdProvider.js @@ -221,7 +221,7 @@ export function postContentForSemanticAnalysis(postContentToken, actualUrl) { // Use the Beacon API if supported to send the payload if ('sendBeacon' in navigator) { // TODO FIX RULES VIOLATION - // es-lint-disable-next-line prebid/no-direct-network-requests + // eslint-disable-next-line prebid/no-direct-network-requests navigator.sendBeacon(url, payload); } else { // Fallback to using AJAX if Beacon API is not supported From 679e93f1876922cad819f19c57a398bf85bb1455 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 20:09:22 -0400 Subject: [PATCH 56/66] Update contxtfulRtdProvider_spec.js --- test/spec/modules/contxtfulRtdProvider_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/contxtfulRtdProvider_spec.js b/test/spec/modules/contxtfulRtdProvider_spec.js index 01e7a242d19..cdba78a03de 100644 --- a/test/spec/modules/contxtfulRtdProvider_spec.js +++ b/test/spec/modules/contxtfulRtdProvider_spec.js @@ -322,14 +322,14 @@ describe('contxtfulRtdProvider', function () { ]; theories.forEach(([adUnits, expected, _description]) => { - it('uses non-expired info from session storage and adds receptivity to the ad units using session storage', function (done) { + it('does not use non-expired info from session storage and adds receptivity to the ad units using session storage', function (done) { let config = buildInitConfig(VERSION, CUSTOMER); // Simulate that there was a write to sessionStorage in the past. writeToStorage(config.params.customer, +100); contxtfulSubmodule.init(config); setTimeout(() => { - expect(contxtfulSubmodule.getTargetingData(adUnits, config)).to.deep.equal( + expect(contxtfulSubmodule.getTargetingData(adUnits, config)).to.not.equal( expected ); done(); From 292bb301838dbb9a8c34be89edc49464bbf5b43c Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Fri, 28 Jun 2024 20:31:41 -0400 Subject: [PATCH 57/66] Update contxtfulRtdProvider_spec.js --- test/spec/modules/contxtfulRtdProvider_spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/contxtfulRtdProvider_spec.js b/test/spec/modules/contxtfulRtdProvider_spec.js index cdba78a03de..e8e46d9dc9c 100644 --- a/test/spec/modules/contxtfulRtdProvider_spec.js +++ b/test/spec/modules/contxtfulRtdProvider_spec.js @@ -453,7 +453,7 @@ describe('contxtfulRtdProvider', function () { }); describe('getBidRequestData', function () { - it('uses non-expired info from session storage and adds receptivity to the reqBidsConfigObj', function (done) { + it('does not use non-expired info from session storage and adds receptivity to the reqBidsConfigObj', function (done) { let config = buildInitConfig(VERSION, CUSTOMER); // Simulate that there was a write to sessionStorage in the past. writeToStorage(config.params.bidders[0], +100); @@ -489,7 +489,7 @@ describe('contxtfulRtdProvider', function () { const noOp = () => undefined; contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, noOp, buildInitConfig(VERSION, CUSTOMER)); let actualOrtb2 = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]]; - expect(actualOrtb2).to.deep.equal(expectedOrtb2); + expect(actualOrtb2).to.not.equal(expectedOrtb2); done(); }, TIMEOUT); }); From 789e8b4ac98e6b114dd3ad8ea282ed9a0903fb22 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Sun, 30 Jun 2024 15:24:34 -0400 Subject: [PATCH 58/66] Update index.js Fix duplication --- plugins/eslint/index.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index bba76beddc3..4d6d328cd0d 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -1,6 +1,14 @@ const _ = require('lodash'); const { flagErrors } = require('./validateImports.js'); +function isMatchingFile(context) { + const filename = context.getFilename(); + const isAdapterFile = /.*Adapter\.js$/.test(filename); + const isProviderFile = /.*Provider\.js$/.test(filename); + const isIdSystemFile = /.*IdSystem\.js$/.test(filename); + return isAdapterFile || isProviderFile || isIdSystemFile; +} + module.exports = { rules: { 'no-outerText': { @@ -83,12 +91,7 @@ module.exports = { } }, create: function(context) { - const filename = context.getFilename(); - const isAdapterFile = /.*Adapter\.js$/.test(filename); - const isProviderFile = /.*Provider\.js$/.test(filename); - const isIdSystemFile = /.*IdSystem\.js$/.test(filename); - - if (!isAdapterFile && !isProviderFile && !isIdSystemFile) { + if (!isMatchingFile(context)) { return {}; } return { @@ -122,12 +125,7 @@ module.exports = { } }, create: function(context) { - const filename = context.getFilename(); - const isAdapterFile = /.*Adapter\.js$/.test(filename); - const isProviderFile = /.*Provider\.js$/.test(filename); - const isIdSystemFile = /.*IdSystem\.js$/.test(filename); - - if (!isAdapterFile && !isProviderFile && !isIdSystemFile) { + if (!isMatchingFile(context)) { return {}; } return { @@ -172,12 +170,7 @@ module.exports = { } }, create: function(context) { - const filename = context.getFilename(); - const isAdapterFile = /.*Adapter\.js$/.test(filename); - const isProviderFile = /.*Provider\.js$/.test(filename); - const isIdSystemFile = /.*IdSystem\.js$/.test(filename); - - if (!isAdapterFile && !isProviderFile && !isIdSystemFile) { + if (!isMatchingFile(context)) { return {}; } return { From abcc1b2578f2a0c1072c28932918a61a6cec4fdf Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Mon, 1 Jul 2024 11:58:31 -0400 Subject: [PATCH 59/66] Update index.js --- plugins/eslint/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index 4d6d328cd0d..c9168632183 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -87,7 +87,7 @@ module.exports = { }, messages: { noCookie: 'Usage of document.cookie is not allowed', - noLocalStorage: 'Usage of localStorage is not allowed', + noLocalStorage: 'Usage of localStorage or sessionStorage is not allowed', } }, create: function(context) { @@ -99,6 +99,11 @@ module.exports = { if ( (node.object.name === 'document' && node.property.name === 'cookie') || (node.object.name === 'localStorage' && + (node.property.name === 'getItem' || + node.property.name === 'setItem' || + node.property.name === 'removeItem' || + node.property.name === 'clear')) || + (node.object.name === 'sessionStorage' && (node.property.name === 'getItem' || node.property.name === 'setItem' || node.property.name === 'removeItem' || From 5d4f6b2fd1786efaa4ef932e88c999282529a8f8 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 1 Jul 2024 11:44:08 -0700 Subject: [PATCH 60/66] refactor custom linter rules --- .eslintrc.js | 39 +++-- modules/adlooxAnalyticsAdapter.js | 1 - modules/ampliffyBidAdapter.js | 2 - modules/automatadAnalyticsAdapter.js | 1 + modules/cleanioRtdProvider.js | 2 +- modules/cwireBidAdapter.js | 4 +- modules/debugging/debugging.js | 3 + modules/dgkeywordRtdProvider.js | 2 + modules/dspxBidAdapter.js | 1 - modules/etargetBidAdapter.js | 1 - modules/geoedgeRtdProvider.js | 1 - modules/invibesBidAdapter.js | 1 - modules/sirdataRtdProvider.js | 3 +- modules/sonobiBidAdapter.js | 2 + plugins/eslint/index.js | 207 +++++++-------------------- src/ajax.js | 1 + src/debugging.js | 1 + src/storageManager.js | 4 + src/utils.js | 1 + 19 files changed, 102 insertions(+), 175 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3a9761cc373..4701cce3732 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -83,31 +83,52 @@ module.exports = { files: key + '/**/*.js', rules: { 'prebid/validate-imports': ['error', allowedModules[key]], - 'prebid/no-innerText': 'error', - 'prebid/no-outerText': 'error', - 'prebid/no-cookie-or-localstorage': 'error', - 'prebid/no-dom-manipulation': 'error', - 'prebid/no-direct-network-requests': 'error', 'no-restricted-globals': [ 'error', { name: 'require', message: 'use import instead' } + ], + 'prebid/no-global': [ + 'error', + ...['localStorage', 'sessionStorage'].map(name => ({name, message: 'use storageManager instead'})), + { + name: 'XMLHttpRequest', + message: 'use ajax.js instead' + }, + ], + 'prebid/no-member': [ + 'error', + { + name: 'cookie', + target: 'document', + message: 'use storageManager instead' + }, + { + name: 'sendBeacon', + target: 'navigator', + message: 'use ajax.js instead' + }, + ...['outerText', 'innerText'].map(name => ({ + name, + message: 'use .textContent instead' + })) ] } })).concat([{ // code in other packages (such as plugins/eslint) is not "seen" by babel and its parser will complain. files: 'plugins/*/**/*.js', parser: 'esprima' - }, - { + }, { files: '**BidAdapter.js', rules: { 'no-restricted-imports': [ 'error', { - patterns: ["**/src/events.js", - "**/src/adloader.js"] + patterns: [ + '**/src/events.js', + '**/src/adloader.js' + ] } ] } diff --git a/modules/adlooxAnalyticsAdapter.js b/modules/adlooxAnalyticsAdapter.js index 6e7018b85a0..f18c9e72337 100644 --- a/modules/adlooxAnalyticsAdapter.js +++ b/modules/adlooxAnalyticsAdapter.js @@ -233,7 +233,6 @@ analyticsAdapter[`handle_${EVENTS.AUCTION_END}`] = function(auctionDetails) { link.setAttribute('rel', 'preload'); link.setAttribute('as', 'script'); // TODO fix rules violation - // eslint-disable-next-line prebid/no-dom-manipulation insertElement(link); } diff --git a/modules/ampliffyBidAdapter.js b/modules/ampliffyBidAdapter.js index ab0b7a7d0ca..e79b04ab4c4 100644 --- a/modules/ampliffyBidAdapter.js +++ b/modules/ampliffyBidAdapter.js @@ -292,9 +292,7 @@ export function parseXML(xml, bid) { if (ct) { const companion = xml.getElementsByTagName('Companion')[0]; const htmlResource = companion.getElementsByTagName('HTMLResource')[0]; - // eslint-disable-next-line prebid/no-dom-manipulation const htmlContent = document.createElement('html'); - // eslint-disable-next-line prebid/no-dom-manipulation htmlContent.innerHTML = htmlResource.textContent; ret.cpm = extractCPM(htmlContent, ct, ret.cpm); diff --git a/modules/automatadAnalyticsAdapter.js b/modules/automatadAnalyticsAdapter.js index 8e72e3d5663..7ed109ab705 100644 --- a/modules/automatadAnalyticsAdapter.js +++ b/modules/automatadAnalyticsAdapter.js @@ -19,6 +19,7 @@ var isLoggingEnabled; var queuePointer = 0; var retryCount = 0; var timer = null const prettyLog = (level, text, isGroup = false, cb = () => {}) => { if (self.isLoggingEnabled === undefined) { // TODO FIX THIS RULES VIOLATION + // eslint-disable-next-line prebid/no-global if (window.localStorage.getItem('__aggLoggingEnabled')) { self.isLoggingEnabled = true } else { diff --git a/modules/cleanioRtdProvider.js b/modules/cleanioRtdProvider.js index 5772c8e8eb3..1a5e64de3cc 100644 --- a/modules/cleanioRtdProvider.js +++ b/modules/cleanioRtdProvider.js @@ -43,13 +43,13 @@ let preloadStatus = 0; * @param {string} scriptURL The script URL to preload */ function pageInitStepPreloadScript(scriptURL) { + // TODO: this bypasses adLoader const linkElement = document.createElement('link'); linkElement.rel = 'preload'; linkElement.as = 'script'; linkElement.href = scriptURL; linkElement.onload = () => { preloadStatus = 1; }; linkElement.onerror = () => { preloadStatus = -1; }; - // eslint-disable-next-line prebid/no-dom-manipulation insertElement(linkElement); } diff --git a/modules/cwireBidAdapter.js b/modules/cwireBidAdapter.js index 87fdd305a01..aebe1a08dfb 100644 --- a/modules/cwireBidAdapter.js +++ b/modules/cwireBidAdapter.js @@ -225,7 +225,7 @@ export const spec = { } } // TODO FIX THIS RULES VIOLATION - // eslint-disable-next-line prebid/no-direct-network-requests + // eslint-disable-next-line prebid/no-member navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, @@ -239,7 +239,7 @@ export const spec = { } } // TODO FIX THIS RULES VIOLATION - // eslint-disable-next-line prebid/no-direct-network-requests + // eslint-disable-next-line prebid/no-member navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) }, diff --git a/modules/debugging/debugging.js b/modules/debugging/debugging.js index 63887074f04..ced8f7bf4a0 100644 --- a/modules/debugging/debugging.js +++ b/modules/debugging/debugging.js @@ -31,6 +31,7 @@ export function disableDebugging({hook, logger}) { } } +// eslint-disable-next-line prebid/no-global function saveDebuggingConfig(debugConfig, {sessionStorage = window.sessionStorage, DEBUG_KEY} = {}) { if (!debugConfig.enabled) { try { @@ -49,6 +50,7 @@ function saveDebuggingConfig(debugConfig, {sessionStorage = window.sessionStorag } } +// eslint-disable-next-line prebid/no-global export function getConfig(debugging, {getStorage = () => window.sessionStorage, DEBUG_KEY, config, hook, logger} = {}) { if (debugging == null) return; let sessionStorage; @@ -70,6 +72,7 @@ export function getConfig(debugging, {getStorage = () => window.sessionStorage, export function sessionLoader({DEBUG_KEY, storage, config, hook, logger}) { let overrides; try { + // eslint-disable-next-line prebid/no-global storage = storage || window.sessionStorage; overrides = JSON.parse(storage.getItem(DEBUG_KEY)); } catch (e) { diff --git a/modules/dgkeywordRtdProvider.js b/modules/dgkeywordRtdProvider.js index 14519ae2713..c97296f6982 100644 --- a/modules/dgkeywordRtdProvider.js +++ b/modules/dgkeywordRtdProvider.js @@ -101,6 +101,8 @@ export function getProfileApiUrl(customeUrl, enableReadFpid) { export function readFpidFromLocalStrage() { try { + // TODO: use storageManager + // eslint-disable-next-line prebid/no-global const fpid = window.localStorage.getItem('ope_fpid'); if (fpid) { return fpid; diff --git a/modules/dspxBidAdapter.js b/modules/dspxBidAdapter.js index 2f5c295f63b..2b819789ec1 100644 --- a/modules/dspxBidAdapter.js +++ b/modules/dspxBidAdapter.js @@ -1,4 +1,3 @@ -/* eslint-disable prebid/no-dom-manipulation */ import {deepAccess, getBidIdParameter, isFn, logError, logMessage, logWarn} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; diff --git a/modules/etargetBidAdapter.js b/modules/etargetBidAdapter.js index f05e2c1f9d7..1653d849297 100644 --- a/modules/etargetBidAdapter.js +++ b/modules/etargetBidAdapter.js @@ -89,7 +89,6 @@ export const spec = { } } } - // eslint-disable-next-line prebid/no-dom-manipulation mts['title'] = [(document.getElementsByTagName('title')[0] || []).innerHTML]; mts['base'] = [(document.getElementsByTagName('base')[0] || {}).href]; mts['referer'] = [document.location.href]; diff --git a/modules/geoedgeRtdProvider.js b/modules/geoedgeRtdProvider.js index 51e7f9ee60c..46f7e7f7d6d 100644 --- a/modules/geoedgeRtdProvider.js +++ b/modules/geoedgeRtdProvider.js @@ -102,7 +102,6 @@ export function markAsLoaded() { export function preloadClient(key) { let iframe = createInvisibleIframe(); iframe.id = 'grumiFrame'; - // eslint-disable-next-line prebid/no-dom-manipulation insertElement(iframe); iframe.contentWindow.grumi = getInitialParams(key); let url = getClientUrl(key); diff --git a/modules/invibesBidAdapter.js b/modules/invibesBidAdapter.js index 2a53dfa1ebf..a69311834b2 100644 --- a/modules/invibesBidAdapter.js +++ b/modules/invibesBidAdapter.js @@ -792,7 +792,6 @@ let keywords = (function () { prefix = prefix || ''; let title = document.title || headTag ? headTag.getElementsByTagName('title')[0] - // eslint-disable-next-line prebid/no-dom-manipulation ? headTag.getElementsByTagName('title')[0].innerHTML : '' : ''; diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js index 0593b528928..507d8d982f2 100644 --- a/modules/sirdataRtdProvider.js +++ b/modules/sirdataRtdProvider.js @@ -1,4 +1,3 @@ -/* eslint-disable prebid/no-dom-manipulation */ /** * This module adds Sirdata provider to the real time data module * and now supports Seller Defined Audience @@ -221,7 +220,7 @@ export function postContentForSemanticAnalysis(postContentToken, actualUrl) { // Use the Beacon API if supported to send the payload if ('sendBeacon' in navigator) { // TODO FIX RULES VIOLATION - // eslint-disable-next-line prebid/no-direct-network-requests + // eslint-disable-next-line prebid/no-member navigator.sendBeacon(url, payload); } else { // Fallback to using AJAX if Beacon API is not supported diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index 908c21298e6..720ce8ee269 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -425,6 +425,7 @@ function loadOrCreateFirstPartyData() { var readData = function (key) { if (hasLocalStorage()) { // TODO FIX RULES VIOLATION + // eslint-disable-next-line prebid/no-global return window.localStorage.getItem(key); } return null; @@ -445,6 +446,7 @@ function loadOrCreateFirstPartyData() { try { if (hasLocalStorage()) { // TODO FIX RULES VIOLATION + // eslint-disable-next-line prebid/no-global window.localStorage.setItem(key, value); } } catch (error) { diff --git a/plugins/eslint/index.js b/plugins/eslint/index.js index c9168632183..f8acf54683b 100644 --- a/plugins/eslint/index.js +++ b/plugins/eslint/index.js @@ -1,60 +1,13 @@ const _ = require('lodash'); const { flagErrors } = require('./validateImports.js'); +const noGlobal = require('eslint/lib/rules/no-restricted-globals.js'); -function isMatchingFile(context) { - const filename = context.getFilename(); - const isAdapterFile = /.*Adapter\.js$/.test(filename); - const isProviderFile = /.*Provider\.js$/.test(filename); - const isIdSystemFile = /.*IdSystem\.js$/.test(filename); - return isAdapterFile || isProviderFile || isIdSystemFile; +function getName(node) { + return node.type === 'Literal' ? node.value : node.name; } module.exports = { rules: { - 'no-outerText': { - meta: { - docs: { - description: '.outerText property on DOM elements should not be used due to performance issues' - }, - messages: { - noOuterText: 'Use of `.outerText` is not allowed. Use `.textContent` instead.', - } - }, - create: function(context) { - return { - MemberExpression(node) { - if (node.property && node.property.name === 'outerText') { - context.report({ - node: node.property, - messageId: 'noOuterText', - }); - } - } - }; - } - }, - 'no-innerText': { - meta: { - docs: { - description: '.innerText property on DOM elements should not be used due to performance issues' - }, - messages: { - noInnerText: 'Use of `.innerText` is not allowed. Use `.textContent` instead.', - } - }, - create: function(context) { - return { - MemberExpression(node) { - if (node.property && node.property.name === 'innerText') { - context.report({ - node: node.property, - messageId: 'noInnerText', - }); - } - } - }; - } - }, 'validate-imports': { meta: { docs: { @@ -80,126 +33,72 @@ module.exports = { }; } }, - 'no-cookie-or-localstorage': { + 'no-member': { meta: { - docs: { - description: 'Disallow use of document.cookie or localStorage' + schema: { + type: 'array', + items: { + type: 'object', + properties: { + target: { type: 'string' }, + name: { type: 'string' }, + message: { type: 'string' } + }, + required: ['name', 'message'], + additionalProperties: false + }, + uniqueItems: true, + minItems: 1 }, + messages: { - noCookie: 'Usage of document.cookie is not allowed', - noLocalStorage: 'Usage of localStorage or sessionStorage is not allowed', + noMember: "Unexpected use of '{{target}}.{{name}}'. {{message}}", } }, - create: function(context) { - if (!isMatchingFile(context)) { - return {}; - } + + create(context) { return { MemberExpression(node) { - if ( - (node.object.name === 'document' && node.property.name === 'cookie') || - (node.object.name === 'localStorage' && - (node.property.name === 'getItem' || - node.property.name === 'setItem' || - node.property.name === 'removeItem' || - node.property.name === 'clear')) || - (node.object.name === 'sessionStorage' && - (node.property.name === 'getItem' || - node.property.name === 'setItem' || - node.property.name === 'removeItem' || - node.property.name === 'clear')) - ) { - context.report({ - node, - messageId: node.object.name === 'document' ? 'noCookie' : 'noLocalStorage', - }); - } + context.options.forEach(({name, target, message}) => { + if (target === node.object.name && getName(node.property) === name) { + context.report({ + node, + messageId: 'noMember', + data: { + name, + target: target || '', + message + } + }); + } + }); } - }; - } - }, - 'no-dom-manipulation': { - meta: { - docs: { - description: 'Disallow use of methods to insert elements into the document' - }, - messages: { - noInsertElement: 'Usage of insertElement is not allowed. Import our methods instead.', - noAppendChild: 'Usage of appendChild is not allowed. Import our methods instead.', - noDomManipulation: 'Direct DOM manipulation is not allowed. Import our methods instead.' } - }, - create: function(context) { - if (!isMatchingFile(context)) { - return {}; - } - return { - CallExpression(node) { - const calleeName = node.callee.name; - if ( - calleeName === 'insertElement' || calleeName === 'appendChild' || - calleeName === 'insertBefore' || calleeName === 'replaceChild' || - calleeName === 'createElement' || calleeName === 'createElementNS' || - calleeName === 'createDocumentFragment' || calleeName === 'innerHTML' - ) { - context.report({ - node, - messageId: - calleeName === 'insertElement' - ? 'noInsertElement' - : calleeName === 'appendChild' - ? 'noAppendChild' - : 'noDomManipulation' - }); - } - }, - MemberExpression(node) { - if (node.property && node.property.name === 'innerHTML') { - context.report({ - node: node.property, - messageId: 'noDomManipulation', - }); - } - } - }; } }, - 'no-direct-network-requests': { - meta: { - docs: { - description: 'Disallow direct use of network requests methods (navigator.sendBeacon, XMLHttpRequest, fetch)' - }, - messages: { - noSendBeacon: 'Usage of navigator.sendBeacon and window.fetch are not allowed', - noXMLHttpRequest: 'Usage of XMLHttpRequest is not allowed' - } - }, - create: function(context) { - if (!isMatchingFile(context)) { - return {}; - } - return { + 'no-global': Object.assign({}, noGlobal, { + // no-restricted-global that also looks for `window.GLOBAL` + create(context) { + const globals = Object.fromEntries( + context.options.map(option => typeof option === 'string' ? [option, null] : [option.name, option.message]) + ) + return Object.assign(noGlobal.create(context), { MemberExpression(node) { - if ( - (node.object.name === 'navigator' && node.property.name === 'sendBeacon') || - (node.object.name === 'window' && node.property.name === 'fetch') - ) { + const name = getName(node.property); + if (node.object.name === 'window' && globals.hasOwnProperty(name)) { + const customMessage = globals[name]; context.report({ node, - messageId: 'noSendBeacon', - }); - } - }, - NewExpression(node) { - if (node.callee.name === 'XMLHttpRequest') { - context.report({ - node, - messageId: 'noXMLHttpRequest', - }); + messageId: customMessage == null ? 'defaultMessage' : 'customMessage', + data: { + name, + customMessage + } + }) } } - }; + }) } - } + }), } }; diff --git a/src/ajax.js b/src/ajax.js index 1ef100e7fd3..7e85bc9ca7f 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -104,6 +104,7 @@ function toXHR({status, statusText = '', headers, url}, responseText) { return xml; } return { + // eslint-disable-next-line prebid/no-global readyState: XMLHttpRequest.DONE, status, statusText, diff --git a/src/debugging.js b/src/debugging.js index f5d13d1a134..045855ccb28 100644 --- a/src/debugging.js +++ b/src/debugging.js @@ -73,6 +73,7 @@ export const reset = ctl.reset; export function loadSession() { let storage = null; try { + // eslint-disable-next-line prebid/no-global storage = window.sessionStorage; } catch (e) {} diff --git a/src/storageManager.js b/src/storageManager.js index 87d714f77b8..d2d26461eac 100644 --- a/src/storageManager.js +++ b/src/storageManager.js @@ -18,6 +18,8 @@ export const STORAGE_TYPE_COOKIES = 'cookie'; export let storageCallbacks = []; +/* eslint-disable prebid/no-global */ + /* * Storage manager constructor. Consumers should prefer one of `getStorageManager` or `getCoreStorageManager`. */ @@ -64,6 +66,7 @@ export function newStorageManager({moduleName, moduleType} = {}, {isAllowed = is const expiresPortion = (expires && expires !== '') ? ` ;expires=${expires}` : ''; const isNone = (sameSite != null && sameSite.toLowerCase() == 'none') const secure = (isNone) ? '; Secure' : ''; + // eslint-disable-next-line prebid/no-member document.cookie = `${key}=${encodeURIComponent(value)}${expiresPortion}; path=/${domainPortion}${sameSite ? `; SameSite=${sameSite}` : ''}${secure}`; } } @@ -186,6 +189,7 @@ export function newStorageManager({moduleName, moduleType} = {}, {isAllowed = is if (result && result.valid) { const all = []; if (hasDeviceAccess()) { + // eslint-disable-next-line prebid/no-member const cookies = document.cookie.split(';'); while (cookies.length) { const cookie = cookies.pop(); diff --git a/src/utils.js b/src/utils.js index 35596cb6442..0dbb26077c0 100644 --- a/src/utils.js +++ b/src/utils.js @@ -747,6 +747,7 @@ export function hasDeviceAccess() { * @returns {(boolean|undefined)} */ export function checkCookieSupport() { + // eslint-disable-next-line prebid/no-member if (window.navigator.cookieEnabled || !!document.cookie.length) { return true; } From 5973d8fcaa3924491e6422d7826d2565a8911af0 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 1 Jul 2024 13:51:38 -0700 Subject: [PATCH 61/66] use TODO and comments instead of quietly removing rule-breaking code --- modules/contxtfulRtdProvider.js | 24 +++++++++++++++++-- modules/fintezaAnalyticsAdapter.js | 19 ++++++++++++--- modules/relevatehealthBidAdapter.js | 3 ++- .../spec/modules/contxtfulRtdProvider_spec.js | 14 +++++++---- 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/modules/contxtfulRtdProvider.js b/modules/contxtfulRtdProvider.js index 80979174978..30bc1e87775 100644 --- a/modules/contxtfulRtdProvider.js +++ b/modules/contxtfulRtdProvider.js @@ -36,8 +36,28 @@ function getRxEngineReceptivity(requester) { } function loadSessionReceptivity(requester) { - return null; -}; + // TODO: commented out because of rule violations + /* + let sessionStorageValue = sessionStorage.getItem(requester); + if (!sessionStorageValue) { + return null; + } + + try { + // Check expiration of the cached value + let sessionStorageReceptivity = JSON.parse(sessionStorageValue); + let expiration = parseInt(sessionStorageReceptivity?.exp); + if (expiration < new Date().getTime()) { + return null; + } + + let rx = sessionStorageReceptivity?.rx; + return rx; + } catch { + return null; + } + */ +} /** * Prepare a receptivity batch diff --git a/modules/fintezaAnalyticsAdapter.js b/modules/fintezaAnalyticsAdapter.js index 40456860fac..78777cd6478 100644 --- a/modules/fintezaAnalyticsAdapter.js +++ b/modules/fintezaAnalyticsAdapter.js @@ -68,7 +68,13 @@ function initFirstVisit() { let now; let visitDate; let cookies; - cookies = {}; + + try { + // TODO: commented out because of rule violations + cookies = {} // parseCookies(document.cookie); + } catch (a) { + cookies = {}; + } visitDate = cookies[ FIRST_VISIT_DATE ]; @@ -86,6 +92,7 @@ function initFirstVisit() { return visitDate; } +// TODO: commented out because of rule violations /* function trim(string) { if (string.trim) { @@ -167,7 +174,12 @@ function initSession() { let sessionDuration; let isNew = false; - cookies = {}; + try { + // TODO: commented out because of rule violations + cookies = {} // parseCookies(document.cookie); + } catch (a) { + cookies = {}; + } sessionId = cookies[ SESSION_ID ]; @@ -255,7 +267,8 @@ function getTrackRequestLastTime() { ); } - cookie = {}; + // TODO: commented out because of rule violations + cookie = {} // parseCookies(document.cookie); cookie = cookie[ TRACK_TIME_KEY ]; if (cookie) { return parseInt(cookie, 10); diff --git a/modules/relevatehealthBidAdapter.js b/modules/relevatehealthBidAdapter.js index 6e50a0c526a..e010f3d8fcd 100644 --- a/modules/relevatehealthBidAdapter.js +++ b/modules/relevatehealthBidAdapter.js @@ -142,7 +142,8 @@ function buildUser(bid) { if (bid && bid.params) { return { id: bid.params.user_id && typeof bid.params.user_id == 'string' ? bid.params.user_id : '', - buyeruid: '', + // TODO: commented out because of rule violations + buyeruid: '', // localStorage.getItem('adx_profile_guid') ? localStorage.getItem('adx_profile_guid') : '', keywords: bid.params.keywords && typeof bid.params.keywords == 'string' ? bid.params.keywords : '', customdata: bid.params.customdata && typeof bid.params.customdata == 'string' ? bid.params.customdata : '' }; diff --git a/test/spec/modules/contxtfulRtdProvider_spec.js b/test/spec/modules/contxtfulRtdProvider_spec.js index e8e46d9dc9c..5dda23caafc 100644 --- a/test/spec/modules/contxtfulRtdProvider_spec.js +++ b/test/spec/modules/contxtfulRtdProvider_spec.js @@ -322,19 +322,22 @@ describe('contxtfulRtdProvider', function () { ]; theories.forEach(([adUnits, expected, _description]) => { - it('does not use non-expired info from session storage and adds receptivity to the ad units using session storage', function (done) { + // TODO: commented out because of rule violations + /* + it('uses non-expired info from session storage and adds receptivity to the ad units using session storage', function (done) { let config = buildInitConfig(VERSION, CUSTOMER); // Simulate that there was a write to sessionStorage in the past. writeToStorage(config.params.customer, +100); contxtfulSubmodule.init(config); setTimeout(() => { - expect(contxtfulSubmodule.getTargetingData(adUnits, config)).to.not.equal( + expect(contxtfulSubmodule.getTargetingData(adUnits, config)).to.deep.equal( expected ); done(); }, TIMEOUT); }); + */ }); }); @@ -453,7 +456,9 @@ describe('contxtfulRtdProvider', function () { }); describe('getBidRequestData', function () { - it('does not use non-expired info from session storage and adds receptivity to the reqBidsConfigObj', function (done) { + // TODO: commented out because of rule violations + /* + it('uses non-expired info from session storage and adds receptivity to the reqBidsConfigObj', function (done) { let config = buildInitConfig(VERSION, CUSTOMER); // Simulate that there was a write to sessionStorage in the past. writeToStorage(config.params.bidders[0], +100); @@ -489,10 +494,11 @@ describe('contxtfulRtdProvider', function () { const noOp = () => undefined; contxtfulSubmodule.getBidRequestData(reqBidsConfigObj, noOp, buildInitConfig(VERSION, CUSTOMER)); let actualOrtb2 = reqBidsConfigObj.ortb2Fragments.bidder[config.params.bidders[0]]; - expect(actualOrtb2).to.not.equal(expectedOrtb2); + expect(actualOrtb2).to.deep.equal(expectedOrtb2); done(); }, TIMEOUT); }); + */ }); describe('getBidRequestData', function () { From 831ea69d4954dd1b89b4775f44d17038b1b6b3d8 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 1 Jul 2024 15:25:07 -0700 Subject: [PATCH 62/66] Add linter GH action --- .github/workflows/linter.yml | 102 +++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/linter.yml diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 00000000000..aa429ec78f4 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,102 @@ +name: Check for linter warnings / exceptions + +on: + pull_request_target: + branches: + - master + +jobs: + check-duplication: + runs-on: ubuntu-latest + + steps: + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.base.sha }} + + - name: Fetch base and target branches + run: | + git fetch origin +refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }} + git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge:refs/remotes/pull/${{ github.event.pull_request.number }}/merge + + - name: Get the diff + run: git diff --name-only origin/${{ github.event.pull_request.base.ref }}...refs/remotes/pull/${{ github.event.pull_request.number }}/merge > __changed_files.txt + + - name: Run linter on base branch + run: npx eslint --no-inline-config --format json $(cat __changed_files.txt) > __base.json + + - name: Check out PR + run: git checkout ${{ github.event.pull_request.head.sha }} + + - name: Run linter on PR + run: npx eslint --no-inline-config --format json $(cat __changed_files.txt) > __pr.json + + - name: Compare them and post comment if necessary + if: env.filtered_report_exists == 'true' + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const path = require('path'); + const process = require('process'); + + function parse(fn) { + return JSON.parse(fs.readFileSync(fn)).reduce((memo, data) => { + const file = path.relative(process.cwd(), data.filePath); + if (!memo.hasOwnProperty(file)) { memo[file] = { errors: 0, warnings: 0} } + data.messages.forEach(({severity}) => { + memo[file][severity > 1 ? 'errors' : 'warnings']++; + }); + return memo; + }, {}) + } + + function mkDiff(old, new_) { + const files = Object.fromEntries( + Object.entries(new_) + .map(([file, {errors, warnings}]) => { + const {errors: oldErrors, warnings: oldWarnings} = old[file] || {}; + return [file, {errors: errors - (oldErrors ?? 0), warnings: warnings - (oldWarnings ?? 0)}] + }) + .filter(([_, {errors, warnings}]) => errors > 0 || warnings > 0) + ) + return Object.values(files).reduce((memo, {warnings, errors}) => { + memo.errors += errors; + memo.warnings += warnings; + return memo; + }, {errors: 0, warnings: 0, files}) + } + + function mkComment({errors, warnings, files}) { + if (errors === 0 && warnings === 0) return; + const summary = []; + if (errors) summary.push(`**${errors}** linter errors`) + if (warnings) summary.push(`**${warnings}** linter warnings`) + let cm = `This pr adds ${summary.join(' and ')} (possibly disabled through directives):\n\n`; + Object.entries(files).forEach(([file, {errors, warnings}]) => { + const summary = []; + if (errors) summary.push(`+${errors} errors`); + if (warnings) summary.push(`+${warnings} warnings`) + cm += ` * \`${file}\` (${summary.join(', ')})\n` + }) + return cm; + } + + const [base, pr] = ['__base.json', '__pr.json'].map(parse); + const comment = mkComment(mkDiff(base, pr)); + + if (comment) { + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: comment + }); + } From 44362d84782ef954aa802e4e25f8229c3070cba4 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 1 Jul 2024 15:32:33 -0700 Subject: [PATCH 63/66] Fix linter workflow name --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index aa429ec78f4..1542f2fd2ee 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -6,7 +6,7 @@ on: - master jobs: - check-duplication: + check-linter: runs-on: ubuntu-latest steps: From e4ece94b43ed2a164bb73600b2b3151d8d8b6ae9 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 1 Jul 2024 15:39:03 -0700 Subject: [PATCH 64/66] Run npm ci on linter check --- .github/workflows/linter.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 1542f2fd2ee..cf58dcd2a8a 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -26,6 +26,9 @@ jobs: git fetch origin +refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }} git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge:refs/remotes/pull/${{ github.event.pull_request.number }}/merge + - name: Install dependencies + run: npm ci + - name: Get the diff run: git diff --name-only origin/${{ github.event.pull_request.base.ref }}...refs/remotes/pull/${{ github.event.pull_request.number }}/merge > __changed_files.txt From 01f840647c4b754884896a0a587a0bd58468e40d Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 1 Jul 2024 15:48:22 -0700 Subject: [PATCH 65/66] Filter out missing (new) files --- .github/workflows/linter.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index cf58dcd2a8a..86c9c1532cb 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -33,13 +33,13 @@ jobs: run: git diff --name-only origin/${{ github.event.pull_request.base.ref }}...refs/remotes/pull/${{ github.event.pull_request.number }}/merge > __changed_files.txt - name: Run linter on base branch - run: npx eslint --no-inline-config --format json $(cat __changed_files.txt) > __base.json + run: npx eslint --no-inline-config --format json $(cat __changed_files.txt | xargs stat --printf '%n\n' 2> /dev/null) > __base.json - name: Check out PR run: git checkout ${{ github.event.pull_request.head.sha }} - name: Run linter on PR - run: npx eslint --no-inline-config --format json $(cat __changed_files.txt) > __pr.json + run: npx eslint --no-inline-config --format json $(cat __changed_files.txt | xargs stat --printf '%n\n' 2> /dev/null) > __pr.json - name: Compare them and post comment if necessary if: env.filtered_report_exists == 'true' From bad26d6f02f1df0418446ebddcf5a081f6ac183f Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 1 Jul 2024 15:49:12 -0700 Subject: [PATCH 66/66] Create test.js --- src/test.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/test.js diff --git a/src/test.js b/src/test.js new file mode 100644 index 00000000000..3a825e0f57f --- /dev/null +++ b/src/test.js @@ -0,0 +1 @@ +localStorage['test'] = 'val';