-
Notifications
You must be signed in to change notification settings - Fork 762
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
Adapter Name Case Insensitive: EID Permissions #3187
Merged
VeronikaSolovei9
merged 1 commit into
prebid:master
from
SyntaxNode:adapter-case-eids-permission
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,9 +126,12 @@ func NewEndpoint( | |
ipValidator, | ||
storedRespFetcher, | ||
hookExecutionPlanBuilder, | ||
tmaxAdjustments}).Auction), nil | ||
tmaxAdjustments, | ||
openrtb_ext.NormalizeBidderName}).Auction), nil | ||
} | ||
|
||
type normalizeBidderName func(name string) (openrtb_ext.BidderName, bool) | ||
|
||
type endpointDeps struct { | ||
uuidGenerator uuidutil.UUIDGenerator | ||
ex exchange.Exchange | ||
|
@@ -149,6 +152,7 @@ type endpointDeps struct { | |
storedRespFetcher stored_requests.Fetcher | ||
hookExecutionPlanBuilder hooks.ExecutionPlanBuilder | ||
tmaxAdjustments *exchange.TmaxAdjustmentsPreprocessed | ||
normalizeBidderName normalizeBidderName | ||
} | ||
|
||
func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { | ||
|
@@ -765,7 +769,7 @@ func (deps *endpointDeps) validateRequest(req *openrtb_ext.RequestWrapper, isAmp | |
} | ||
} | ||
|
||
var aliases map[string]string | ||
var requestAliases map[string]string | ||
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. Making clear these are request aliases, not hardcoded aliases. Request alias names are still case sensitive. |
||
reqExt, err := req.GetRequestExt() | ||
if err != nil { | ||
return []error{fmt.Errorf("request.ext is invalid: %v", err)} | ||
|
@@ -777,25 +781,25 @@ func (deps *endpointDeps) validateRequest(req *openrtb_ext.RequestWrapper, isAmp | |
} | ||
|
||
if reqPrebid != nil { | ||
aliases = reqPrebid.Aliases | ||
requestAliases = reqPrebid.Aliases | ||
|
||
if err := deps.validateAliases(aliases); err != nil { | ||
if err := deps.validateAliases(requestAliases); err != nil { | ||
return []error{err} | ||
} | ||
|
||
if err := deps.validateAliasesGVLIDs(reqPrebid.AliasGVLIDs, aliases); err != nil { | ||
if err := deps.validateAliasesGVLIDs(reqPrebid.AliasGVLIDs, requestAliases); err != nil { | ||
return []error{err} | ||
} | ||
|
||
if err := deps.validateBidAdjustmentFactors(reqPrebid.BidAdjustmentFactors, aliases); err != nil { | ||
if err := deps.validateBidAdjustmentFactors(reqPrebid.BidAdjustmentFactors, requestAliases); err != nil { | ||
return []error{err} | ||
} | ||
|
||
if err := validateSChains(reqPrebid.SChains); err != nil { | ||
return []error{err} | ||
} | ||
|
||
if err := deps.validateEidPermissions(reqPrebid.Data, aliases); err != nil { | ||
if err := deps.validateEidPermissions(reqPrebid.Data, requestAliases); err != nil { | ||
return []error{err} | ||
} | ||
|
||
|
@@ -844,7 +848,7 @@ func (deps *endpointDeps) validateRequest(req *openrtb_ext.RequestWrapper, isAmp | |
} | ||
} | ||
|
||
if errs := deps.validateUser(req, aliases, gpp); errs != nil { | ||
if errs := deps.validateUser(req, requestAliases, gpp); errs != nil { | ||
if len(errs) > 0 { | ||
errL = append(errL, errs...) | ||
} | ||
|
@@ -871,7 +875,7 @@ func (deps *endpointDeps) validateRequest(req *openrtb_ext.RequestWrapper, isAmp | |
if errortypes.ContainsFatalError([]error{err}) { | ||
return errL | ||
} | ||
} else if _, err := ccpaPolicy.Parse(exchange.GetValidBidders(aliases)); err != nil { | ||
} else if _, err := ccpaPolicy.Parse(exchange.GetValidBidders(requestAliases)); err != nil { | ||
if _, invalidConsent := err.(*errortypes.Warning); invalidConsent { | ||
errL = append(errL, &errortypes.Warning{ | ||
Message: fmt.Sprintf("CCPA consent is invalid and will be ignored. (%v)", err), | ||
|
@@ -894,7 +898,7 @@ func (deps *endpointDeps) validateRequest(req *openrtb_ext.RequestWrapper, isAmp | |
} | ||
impIDs[imp.ID] = i | ||
|
||
errs := deps.validateImp(imp, aliases, i, hasStoredResponses, storedBidResp) | ||
errs := deps.validateImp(imp, requestAliases, i, hasStoredResponses, storedBidResp) | ||
if len(errs) > 0 { | ||
errL = append(errL, errs...) | ||
} | ||
|
@@ -986,7 +990,7 @@ func validateSChains(sChains []*openrtb_ext.ExtRequestPrebidSChain) error { | |
return err | ||
} | ||
|
||
func (deps *endpointDeps) validateEidPermissions(prebid *openrtb_ext.ExtRequestPrebidData, aliases map[string]string) error { | ||
func (deps *endpointDeps) validateEidPermissions(prebid *openrtb_ext.ExtRequestPrebidData, requestAliases map[string]string) error { | ||
if prebid == nil { | ||
return nil | ||
} | ||
|
@@ -1006,28 +1010,24 @@ func (deps *endpointDeps) validateEidPermissions(prebid *openrtb_ext.ExtRequestP | |
return fmt.Errorf(`request.ext.prebid.data.eidpermissions[%d] missing or empty required field: "bidders"`, i) | ||
} | ||
|
||
if err := validateBidders(eid.Bidders, deps.bidderMap, aliases); err != nil { | ||
if err := deps.validateBidders(eid.Bidders, deps.bidderMap, requestAliases); err != nil { | ||
return fmt.Errorf(`request.ext.prebid.data.eidpermissions[%d] contains %v`, i, err) | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func validateBidders(bidders []string, knownBidders map[string]openrtb_ext.BidderName, knownAliases map[string]string) error { | ||
func (deps *endpointDeps) validateBidders(bidders []string, knownBidders map[string]openrtb_ext.BidderName, knownRequestAliases map[string]string) error { | ||
for _, bidder := range bidders { | ||
if bidder == "*" { | ||
if len(bidders) > 1 { | ||
return errors.New(`bidder wildcard "*" mixed with specific bidders`) | ||
} | ||
} else { | ||
bidderName := bidder | ||
normalizedCoreBidder, ok := openrtb_ext.NormalizeBidderName(bidderName) | ||
if ok { | ||
bidderName = normalizedCoreBidder.String() | ||
} | ||
_, isCoreBidder := knownBidders[bidderName] | ||
_, isAlias := knownAliases[bidder] | ||
bidderNormalized, _ := deps.normalizeBidderName(bidder) | ||
_, isCoreBidder := knownBidders[bidderNormalized.String()] | ||
_, isAlias := knownRequestAliases[bidder] | ||
if !isCoreBidder && !isAlias { | ||
return fmt.Errorf(`unrecognized bidder "%v"`, bidder) | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry. I hate to add yet another parameter here, but I can't test it properly otherwise.