Skip to content

Commit

Permalink
Schain module: do not share schain objects across different bid reque…
Browse files Browse the repository at this point in the history
…sts (#10021)
  • Loading branch information
dgirardi authored Jun 1, 2023
1 parent 27ea1ad commit 382599e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/schain.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
isInteger,
_each,
logWarn,
deepAccess, deepSetValue
deepAccess, deepSetValue, deepClone
} from '../src/utils.js';
import {registerOrtbProcessor, REQUEST} from '../src/pbjsORTB.js';

Expand Down Expand Up @@ -180,7 +180,7 @@ export function makeBidRequestsHook(fn, bidderRequests) {
bidderRequest.bids.forEach(bid => {
let result = resolveSchainConfig(schainConfig, bidder);
if (result) {
bid.schain = result;
bid.schain = deepClone(result);
}
});
});
Expand Down
9 changes: 9 additions & 0 deletions test/spec/modules/schain_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,15 @@ describe('#makeBidRequestsHook', function() {
makeBidRequestsHook(testCallback, testBidderRequests);
});

it('should not share the same schain object between different bid requests', (done) => {
config.setBidderConfig(goodStrictBidderConfig);
makeBidRequestsHook((requests) => {
requests[0].bids[0].schain.field = 'value';
expect(requests[1].bids[0].schain.field).to.not.exist;
done();
}, deepClone(bidderRequests))
});

it('should reject bad strict config but allow a bad relaxed config for bidders trying to override it', function () {
function testCallback(bidderRequests) {
expect(bidderRequests[0].bids[0].schain).to.exist;
Expand Down

0 comments on commit 382599e

Please sign in to comment.