-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request validation upgrade to 2.6 locations #3906
Changes from 1 commit
c4fcd13
10e1faf
a8e5a44
590e56b
3a3c492
04e460f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -784,6 +784,10 @@ func (deps *endpointDeps) validateRequest(account *config.Account, httpReq *http | |
} | ||
} | ||
|
||
if err := deps.validateSourceSChain(req); err != nil { | ||
return []error{err} | ||
} | ||
|
||
var requestAliases map[string]string | ||
reqExt, err := req.GetRequestExt() | ||
if err != nil { | ||
|
@@ -810,7 +814,7 @@ func (deps *endpointDeps) validateRequest(account *config.Account, httpReq *http | |
return []error{err} | ||
} | ||
|
||
if err := validateSChains(reqPrebid.SChains); err != nil { | ||
if err := validateSChains(reqPrebid.SChains); err != nil { //!!! delete this? should be in req.Source.SChain | ||
return []error{err} | ||
} | ||
|
||
|
@@ -823,7 +827,7 @@ func (deps *endpointDeps) validateRequest(account *config.Account, httpReq *http | |
} | ||
} | ||
|
||
if err := mapSChains(req); err != nil { | ||
if err := mapSChains(req); err != nil { // do we need this? | ||
return []error{err} | ||
} | ||
|
||
|
@@ -1279,7 +1283,7 @@ func (deps *endpointDeps) validateUser(req *openrtb_ext.RequestWrapper, aliases | |
// Check if the buyeruids are valid | ||
prebid := userExt.GetPrebid() | ||
if prebid != nil { | ||
if len(prebid.BuyerUIDs) < 1 { | ||
if len(prebid.BuyerUIDs) < 1 { // how to replace validation to user.buyeruid(string) | ||
return append(errL, errors.New(`request.user.ext.prebid requires a "buyeruids" property with at least one ID defined. If none exist, then request.user.ext.prebid should not be defined.`)) | ||
} | ||
for bidderName := range prebid.BuyerUIDs { | ||
|
@@ -1294,9 +1298,8 @@ func (deps *endpointDeps) validateUser(req *openrtb_ext.RequestWrapper, aliases | |
} | ||
|
||
// Check Universal User ID | ||
eids := userExt.GetEid() | ||
if eids != nil { | ||
eidsValue := *eids | ||
if req.User.EIDs != nil { | ||
eidsValue := req.User.EIDs | ||
for eidIndex, eid := range eidsValue { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: I think you can iterate over |
||
if eid.Source == "" { | ||
return append(errL, fmt.Errorf("request.user.ext.eids[%d] missing required field: \"source\"", eidIndex)) | ||
|
@@ -1370,7 +1373,20 @@ func validateDevice(device *openrtb2.Device) error { | |
if device.Geo != nil && device.Geo.Accuracy < 0 { | ||
return errors.New("request.device.geo.accuracy must be a positive number") | ||
} | ||
|
||
if device.SUA != nil { | ||
if len(device.SUA.Browsers) > 0 { | ||
for i, browser := range device.SUA.Browsers { | ||
if len(browser.Brand) == 0 { | ||
return fmt.Errorf("request.device.sua.browsers[%d].brand cannot be empty", i) | ||
} | ||
} | ||
} | ||
if device.SUA.Platform != nil { | ||
if len(device.SUA.Platform.Brand) == 0 { | ||
return errors.New("request.device.sua.platform.brand cannot be empty") | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where did this validation logic come from? Is this new 2.6 behavior? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is from the OpenRTB 2.6 specification, paragraph 3.2.30. We discussed offline that we can omit validation for the fields we don't use in PBS core, so I'm open to delete this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove this validation. PBS's approach is to just validate the schema (attributes & datatypes) for fields we do not use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted |
||
return nil | ||
} | ||
|
||
|
@@ -1467,6 +1483,29 @@ func fillChannel(reqWrapper *openrtb_ext.RequestWrapper, isAmp bool) error { | |
|
||
} | ||
|
||
func (deps *endpointDeps) validateSourceSChain(req *openrtb_ext.RequestWrapper) error { | ||
if req.Source.SChain == nil { | ||
return nil | ||
} | ||
sChain := req.Source.SChain | ||
|
||
if len(sChain.Ver) == 0 { | ||
return errors.New("request.source.schain.ver cannot be empty") | ||
} | ||
if len(sChain.Nodes) == 0 { | ||
return errors.New("request.source.schain.nodes cannot be empty") | ||
} | ||
for i, node := range sChain.Nodes { | ||
if len(node.ASI) == 0 { | ||
return fmt.Errorf("request.source.schain.nodes[%d].asi cannot be empty", i) | ||
} | ||
if len(node.SID) == 0 { | ||
return fmt.Errorf("request.source.schain.nodes[%d].sid cannot be empty", i) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did these validation rules come from https://github.com/InteractiveAdvertisingBureau/openrtb/blob/main/supplychainobject.md? There are a couple of other fields marked as required in this spec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found this in OpenRTB 2.6 spec, paragraph 3.2.25 and 3.2.26. You are probably referring to this required field: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove this validation. PBS's approach is to just validate the schema (attributes & datatypes) for fields we do not use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverted |
||
return nil | ||
} | ||
|
||
func sanitizeRequest(r *openrtb_ext.RequestWrapper, ipValidator iputil.IPValidator) { | ||
if r.Device != nil { | ||
if ip, ver := iputil.ParseIP(r.Device.IP); ip == nil || ver != iputil.IPv4 || !ipValidator.IsValid(ip, ver) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get rid of this. It should now be handled in
moveSupplyChainFrom24To25
fromconvert_up.go
.