From 59e73d3a18ab23be6c38cda0985ab1a10c787045 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 18 Apr 2022 11:03:18 -0700 Subject: [PATCH 1/5] eslint validate-imports plugin: do not allow cross-module imports --- plugins/eslint/validateImports.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/eslint/validateImports.js b/plugins/eslint/validateImports.js index 37a87fffb50..324b75c4ce7 100644 --- a/plugins/eslint/validateImports.js +++ b/plugins/eslint/validateImports.js @@ -1,11 +1,17 @@ -let path = require('path'); -let _ = require('lodash'); -let resolveFrom = require('resolve-from'); +const path = require('path'); +const _ = require('lodash'); +const resolveFrom = require('resolve-from'); +const MODULES_PATH = path.resolve(__dirname, '../../modules'); + +function isInDirectory(filename, dir) { + const rel = path.relative(dir, filename); + return rel && !rel.startsWith('..') && !path.isAbsolute(rel); +} function flagErrors(context, node, importPath) { let absFileDir = path.dirname(context.getFilename()); - let absImportPath = path.resolve(absFileDir, importPath); + let absImportPath = importPath.startsWith('.') ? path.resolve(absFileDir, importPath) : require.resolve(importPath); try { resolveFrom(absFileDir, importPath); @@ -20,16 +26,9 @@ function flagErrors(context, node, importPath) { ) { context.report(node, `import "${importPath}" not in import whitelist`); } else { - let absModulePath = path.resolve(__dirname, '../../modules'); - - // don't allow import of any files directly within modules folder or index.js files within modules' sub-folders - if ( - path.dirname(absImportPath) === absModulePath || ( - absImportPath.startsWith(absModulePath) && - path.basename(absImportPath) === 'index.js' - ) - ) { - context.report(node, `import "${importPath}" cannot require module entry point`); + // do not allow cross-module imports + if (isInDirectory(absImportPath, MODULES_PATH) && (!isInDirectory(absImportPath, absFileDir) || absFileDir === MODULES_PATH)) { + context.report(node, `import "${importPath}": importing from modules is not allowed`); } // don't allow extension-less local imports From 0d37778965e74d85cae4ae06510d6fe5097d5a4b Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Mon, 5 Sep 2022 07:58:02 -0600 Subject: [PATCH 2/5] Update onetag --- modules/onetagBidAdapter.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 89c614dba23..9e53c3ec02b 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -6,7 +6,6 @@ import {Renderer} from '../src/Renderer.js'; import {find} from '../src/polyfill.js'; import {getStorageManager} from '../src/storageManager.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {createEidsArray} from './userId/eids.js'; import {deepClone} from '../src/utils.js'; const ENDPOINT = 'https://onetag-sys.com/prebid-request'; @@ -65,8 +64,8 @@ function buildRequests(validBidRequests, bidderRequest) { if (bidderRequest && bidderRequest.uspConsent) { payload.usPrivacy = bidderRequest.uspConsent; } - if (validBidRequests && validBidRequests.length !== 0 && validBidRequests[0].userId) { - payload.userId = createEidsArray(validBidRequests[0].userId); + if (validBidRequests && validBidRequests.length !== 0 && validBidRequests[0].userIdAsEids) { + payload.userId = validBidRequests[0].userIdAsEids; } try { if (storage.hasLocalStorage()) { From 9351fb2c63b12e4022680ead75e709141f3e7a53 Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Mon, 5 Sep 2022 08:01:38 -0600 Subject: [PATCH 3/5] fix conflicts --- modules/onetagBidAdapter.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 9e53c3ec02b..8c19a6fe730 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -1,12 +1,12 @@ 'use strict'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import {INSTREAM, OUTSTREAM} from '../src/video.js'; -import {Renderer} from '../src/Renderer.js'; -import {find} from '../src/polyfill.js'; -import {getStorageManager} from '../src/storageManager.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {deepClone} from '../src/utils.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { INSTREAM, OUTSTREAM } from '../src/video.js'; +import { Renderer } from '../src/Renderer.js'; +import { find } from '../src/polyfill.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { deepClone, logError, deepAccess } from '../src/utils.js'; const ENDPOINT = 'https://onetag-sys.com/prebid-request'; const USER_SYNC_ENDPOINT = 'https://onetag-sys.com/usync/'; From bd8751fb1f83bc7b57ee97fbec23398b509d5410 Mon Sep 17 00:00:00 2001 From: Chris Huie Date: Mon, 5 Sep 2022 07:06:01 -0700 Subject: [PATCH 4/5] update imports --- modules/onetagBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 8c19a6fe730..735b0e0c5cb 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -6,7 +6,7 @@ import { Renderer } from '../src/Renderer.js'; import { find } from '../src/polyfill.js'; import { getStorageManager } from '../src/storageManager.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { deepClone, logError, deepAccess } from '../src/utils.js'; +import { deepClone } from '../src/utils.js'; const ENDPOINT = 'https://onetag-sys.com/prebid-request'; const USER_SYNC_ENDPOINT = 'https://onetag-sys.com/usync/'; From 075170b7102136e70a1cfd9c07b44efb4c518af7 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Tue, 4 Apr 2023 09:00:18 -0700 Subject: [PATCH 5/5] refactor audiencerun & jixie --- modules/audiencerunBidAdapter.js | 19 ++-- modules/jixieBidAdapter.js | 9 +- .../modules/audiencerunBidAdapter_spec.js | 19 ++-- test/spec/modules/jixieBidAdapter_spec.js | 102 ++++++++---------- 4 files changed, 62 insertions(+), 87 deletions(-) diff --git a/modules/audiencerunBidAdapter.js b/modules/audiencerunBidAdapter.js index 754a48ede75..efd88aa6f58 100644 --- a/modules/audiencerunBidAdapter.js +++ b/modules/audiencerunBidAdapter.js @@ -1,18 +1,17 @@ import { + _each, deepAccess, - isFn, - logError, - getValue, + formatQS, getBidIdParameter, - _each, + getValue, isArray, + isFn, + logError, triggerPixel, - formatQS, } from '../src/utils.js'; -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; -import { createEidsArray } from './userId/eids.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; const BIDDER_CODE = 'audiencerun'; const BASE_URL = 'https://d.audiencerun.com'; @@ -135,7 +134,7 @@ export const spec = { payload.uspConsent = deepAccess(bidderRequest, 'uspConsent'); payload.schain = deepAccess(bidRequests, '0.schain'); - payload.userId = deepAccess(bidRequests, '0.userId') ? createEidsArray(bidRequests[0].userId) : []; + payload.userId = deepAccess(bidRequests, '0.userIdAsEids') || [] if (bidderRequest && bidderRequest.gdprConsent) { payload.gdpr = { diff --git a/modules/jixieBidAdapter.js b/modules/jixieBidAdapter.js index 5eeab197f3a..586fce84804 100644 --- a/modules/jixieBidAdapter.js +++ b/modules/jixieBidAdapter.js @@ -6,7 +6,6 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {ajax} from '../src/ajax.js'; import {getRefererInfo} from '../src/refererDetection.js'; import {Renderer} from '../src/Renderer.js'; -import {createEidsArray} from './userId/eids.js'; const BIDDER_CODE = 'jixie'; export const storage = getStorageManager({bidderCode: BIDDER_CODE}); @@ -190,12 +189,10 @@ export const spec = { let miscDims = internal.getMiscDims(); let schain = deepAccess(validBidRequests[0], 'schain'); + let eids1 = validBidRequests[0].userIdAsEids // all available user ids are sent to our backend in the standard array layout: - if (validBidRequests[0].userId) { - let eids1 = createEidsArray(validBidRequests[0].userId); - if (eids1.length) { - eids = eids1; - } + if (eids1 && eids1.length) { + eids = eids1; } // we want to send this blob of info to our backend: let pg = config.getConfig('priceGranularity'); diff --git a/test/spec/modules/audiencerunBidAdapter_spec.js b/test/spec/modules/audiencerunBidAdapter_spec.js index 57de8bdb0df..5c736345068 100644 --- a/test/spec/modules/audiencerunBidAdapter_spec.js +++ b/test/spec/modules/audiencerunBidAdapter_spec.js @@ -218,16 +218,7 @@ describe('AudienceRun bid adapter tests', function () { it('should add userid eids information to the request', function () { const bid = Object.assign({}, bidRequest); - bid.userId = { - pubcid: '01EAJWWNEPN3CYMM5N8M5VXY22', - unsuported: '666', - } - - const request = spec.buildRequests([bid]); - const payload = JSON.parse(request.data); - - expect(payload.userId).to.exist; - expect(payload.userId).to.deep.equal([ + bid.userIdAsEids = [ { source: 'pubcid.org', uids: [ @@ -237,7 +228,13 @@ describe('AudienceRun bid adapter tests', function () { }, ], }, - ]); + ]; + + const request = spec.buildRequests([bid]); + const payload = JSON.parse(request.data); + + expect(payload.userId).to.exist; + expect(payload.userId).to.deep.equal(bid.userIdAsEids); }); it('should add schain object if available', function() { diff --git a/test/spec/modules/jixieBidAdapter_spec.js b/test/spec/modules/jixieBidAdapter_spec.js index c354de3c3ac..5bf2a3b6fc9 100644 --- a/test/spec/modules/jixieBidAdapter_spec.js +++ b/test/spec/modules/jixieBidAdapter_spec.js @@ -309,71 +309,53 @@ describe('jixie Adapter', function () { it('should populate eids when supported userIds are available', function () { const oneSpecialBidReq = Object.assign({}, bidRequests_[0], { - userId: { - tdid: '11111111-2222-3333-4444-555555555555', - uid2: { id: 'AbCdEfGhIjKlMnO9qdQBW7qtMw8f1WTUvtkHe6u+fqLfhbtsqrJ697Z6YoI3IB9klGUv1wvlFIbwH7ELDlqQBGtj8AC1v7fMJ/Q45E7W90dts7UQLTDMLNmtHBRDXVb0Fpas4Vh3yN1jGVQNhzXC/RpGIVtZE8dCxcjfa7VfcTNcvxxxxx==' }, - pubProvidedId: [{ - source: 'puburl1.com', - uids: [{ - id: 'pubid1', - atype: 1, - ext: { - stype: 'ppuid' - } - }] - }, { - source: 'puburl2.com', - uids: [{ - id: 'pubid2' - }] - }] - } - }); - const request = spec.buildRequests([oneSpecialBidReq], bidderRequest_); - const payload = JSON.parse(request.data); - expect(payload.eids).to.deep.include({ - 'source': 'adserver.org', - 'uids': [ + userIdAsEids: [ { - 'id': '11111111-2222-3333-4444-555555555555', - 'atype': 1, - 'ext': { - 'rtiPartner': 'TDID' - } - } - ] - }); - expect(payload.eids).to.deep.include({ - 'source': 'uidapi.com', - 'uids': [ + 'source': 'adserver.org', + 'uids': [ + { + 'id': '11111111-2222-3333-4444-555555555555', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + } + ] + }, { - 'id': 'AbCdEfGhIjKlMnO9qdQBW7qtMw8f1WTUvtkHe6u+fqLfhbtsqrJ697Z6YoI3IB9klGUv1wvlFIbwH7ELDlqQBGtj8AC1v7fMJ/Q45E7W90dts7UQLTDMLNmtHBRDXVb0Fpas4Vh3yN1jGVQNhzXC/RpGIVtZE8dCxcjfa7VfcTNcvxxxxx==', - 'atype': 3 - } - ] - }); - - expect(payload.eids).to.deep.include({ - 'source': 'puburl1.com', - 'uids': [ + 'source': 'uidapi.com', + 'uids': [ + { + 'id': 'AbCdEfGhIjKlMnO9qdQBW7qtMw8f1WTUvtkHe6u+fqLfhbtsqrJ697Z6YoI3IB9klGUv1wvlFIbwH7ELDlqQBGtj8AC1v7fMJ/Q45E7W90dts7UQLTDMLNmtHBRDXVb0Fpas4Vh3yN1jGVQNhzXC/RpGIVtZE8dCxcjfa7VfcTNcvxxxxx==', + 'atype': 3 + } + ] + }, { - 'id': 'pubid1', - 'atype': 1, - 'ext': { - 'stype': 'ppuid' - } - } - ] - }); - - expect(payload.eids).to.deep.include({ - 'source': 'puburl2.com', - 'uids': [ + 'source': 'puburl1.com', + 'uids': [ + { + 'id': 'pubid1', + 'atype': 1, + 'ext': { + 'stype': 'ppuid' + } + } + ] + }, { - 'id': 'pubid2' - } - ] + 'source': 'puburl2.com', + 'uids': [ + { + 'id': 'pubid2' + } + ] + }, + ], }); + const request = spec.buildRequests([oneSpecialBidReq], bidderRequest_); + const payload = JSON.parse(request.data); + expect(payload.eids).to.eql(oneSpecialBidReq.userIdAsEids); }); });// describe