Skip to content

Commit 4b6e3d1

Browse files
author
Mark R
committed
impression: Specify imp.secure as json.Number to mitigate malformed bid requests (+ tests)
1 parent 705b5ee commit 4b6e3d1

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

bidrequest_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package openrtb
22

33
import (
4+
"encoding/json"
45
. "github.com/onsi/ginkgo"
56
. "github.com/onsi/gomega"
67
)
@@ -28,6 +29,7 @@ var _ = Describe("BidRequest", func() {
2829
Imp: []Impression{
2930
{
3031
ID: "1",
32+
Secure: json.Number("1"),
3133
Banner: &Banner{W: 300, H: 250, Pos: AdPosAboveFold, BAttr: []int{13}},
3234
},
3335
},

impression.go

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package openrtb
22

3-
import "errors"
3+
import (
4+
"encoding/json"
5+
"errors"
6+
)
47

58
// Validation errors
69
var (
@@ -16,22 +19,22 @@ var (
1619
// The presence of Banner, Video, and/or Native objects
1720
// subordinate to the Imp object indicates the type of impression being offered.
1821
type Impression struct {
19-
ID string `json:"id"` // A unique identifier for this impression
20-
Banner *Banner `json:"banner,omitempty"`
21-
Video *Video `json:"video,omitempty"`
22-
Audio *Audio `json:"audio,omitempty"`
23-
Native *Native `json:"native,omitempty"`
24-
Pmp *Pmp `json:"pmp,omitempty"` // A reference to the PMP object containing any Deals eligible for the impression object.
25-
DisplayManager string `json:"displaymanager,omitempty"` // Name of ad mediation partner, SDK technology, etc
26-
DisplayManagerVer string `json:"displaymanagerver,omitempty"` // Version of the above
27-
Instl int `json:"instl,omitempty"` // Interstitial, Default: 0 ("1": Interstitial, "0": Something else)
28-
TagID string `json:"tagid,omitempty"` // IDentifier for specific ad placement or ad tag
29-
BidFloor float64 `json:"bidfloor,omitempty"` // Bid floor for this impression in CPM
30-
BidFloorCurrency string `json:"bidfloorcur,omitempty"` // Currency of bid floor
31-
Secure int `json:"secure,omitempty"` // Flag to indicate whether the impression requires secure HTTPS URL creative assets and markup.
32-
Exp int `json:"exp,omitempty"` // Advisory as to the number of seconds that may elapse between the auction and the actual impression.
33-
IFrameBuster []string `json:"iframebuster,omitempty"` // Array of names for supportediframe busters.
34-
Ext Extension `json:"ext,omitempty"`
22+
ID string `json:"id"` // A unique identifier for this impression
23+
Banner *Banner `json:"banner,omitempty"`
24+
Video *Video `json:"video,omitempty"`
25+
Audio *Audio `json:"audio,omitempty"`
26+
Native *Native `json:"native,omitempty"`
27+
Pmp *Pmp `json:"pmp,omitempty"` // A reference to the PMP object containing any Deals eligible for the impression object.
28+
DisplayManager string `json:"displaymanager,omitempty"` // Name of ad mediation partner, SDK technology, etc
29+
DisplayManagerVer string `json:"displaymanagerver,omitempty"` // Version of the above
30+
Instl int `json:"instl,omitempty"` // Interstitial, Default: 0 ("1": Interstitial, "0": Something else)
31+
TagID string `json:"tagid,omitempty"` // IDentifier for specific ad placement or ad tag
32+
BidFloor float64 `json:"bidfloor,omitempty"` // Bid floor for this impression in CPM
33+
BidFloorCurrency string `json:"bidfloorcur,omitempty"` // Currency of bid floor
34+
Secure json.Number `json:"secure,omitempty"` // Flag to indicate whether the impression requires secure HTTPS URL creative assets and markup.
35+
Exp int `json:"exp,omitempty"` // Advisory as to the number of seconds that may elapse between the auction and the actual impression.
36+
IFrameBuster []string `json:"iframebuster,omitempty"` // Array of names for supportediframe busters.
37+
Ext Extension `json:"ext,omitempty"`
3538
}
3639

3740
func (imp *Impression) assetCount() int {

testdata/breq.banner.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"imp": [
66
{
77
"id": "1",
8+
"secure": "1",
89
"banner": {
910
"w": 300,
1011
"h": 250,

0 commit comments

Comments
 (0)