Skip to content

Commit

Permalink
don't allow null or undefined bid properties (#2865)
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich authored and jsnellbaker committed Jul 23, 2018
1 parent 8f4fc07 commit f5170d9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/adapters/bidderFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ function validBidSize(adUnitCode, bid, bidRequests) {
export function isValid(adUnitCode, bid, bidRequests) {
function hasValidKeys() {
let bidKeys = Object.keys(bid);
return COMMON_BID_RESPONSE_KEYS.every(key => includes(bidKeys, key));
return COMMON_BID_RESPONSE_KEYS.every(key => includes(bidKeys, key) && !includes([undefined, null], bid[key]));
}

function errorMessage(msg) {
Expand Down
30 changes: 30 additions & 0 deletions test/spec/unit/core/bidderFactory_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,36 @@ describe('bidders created by newBidder', () => {

expect(logErrorSpy.calledOnce).to.equal(true);
});

it('should logError when required bid response params are undefined', () => {
const bidder = newBidder(spec);

const bid = {
'ad': 'creative',
'cpm': '1.99',
'width': 300,
'height': 250,
'requestId': '1',
'creativeId': 'some-id',
'currency': undefined,
'netRevenue': true,
'ttl': 360
};

spec.isBidRequestValid.returns(true);
spec.buildRequests.returns({
method: 'POST',
url: 'test.url.com',
data: {}
});
spec.getUserSyncs.returns([]);

spec.interpretResponse.returns(bid);

bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub);

expect(logErrorSpy.calledOnce).to.equal(true);
});
});

describe('when the ajax call fails', () => {
Expand Down

0 comments on commit f5170d9

Please sign in to comment.