Skip to content

Commit

Permalink
Fixes GDPR bug about being overly strict on publisher restrictions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hhhjort authored Mar 4, 2021
1 parent ee2ec39 commit 87277e1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
10 changes: 6 additions & 4 deletions gdpr/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,17 @@ func (p *permissionsImpl) checkPurpose(consent tcf2.ConsentMetadata, vendor api.
if consent.CheckPubRestriction(uint8(purpose), pubRestrictNotAllowed, vendorID) {
return false
}

purposeAllowed := vendor.Purpose(purpose) && consent.PurposeAllowed(purpose) && consent.VendorConsent(vendorID)
legitInterest := vendor.LegitimateInterest(purpose) && consent.PurposeLITransparency(purpose) && consent.VendorLegitInterest(vendorID)

if consent.CheckPubRestriction(uint8(purpose), pubRestrictRequireConsent, vendorID) {
return vendor.PurposeStrict(purpose) && consent.PurposeAllowed(purpose) && consent.VendorConsent(vendorID)
return purposeAllowed
}
if consent.CheckPubRestriction(uint8(purpose), pubRestrictRequireLegitInterest, vendorID) {
// Need LITransparency here
return vendor.LegitimateInterestStrict(purpose) && consent.PurposeLITransparency(purpose) && consent.VendorLegitInterest(vendorID)
return legitInterest
}
purposeAllowed := vendor.Purpose(purpose) && consent.PurposeAllowed(purpose) && consent.VendorConsent(vendorID)
legitInterest := vendor.LegitimateInterest(purpose) && consent.PurposeLITransparency(purpose) && consent.VendorLegitInterest(vendorID)

return purposeAllowed || legitInterest
}
Expand Down
19 changes: 19 additions & 0 deletions gdpr/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ func buildTCF2VendorList34() tcf2VendorList {
Purposes: []int{2, 4, 7},
SpecialPurposes: []int{1},
},
"20": {
ID: 20,
Purposes: []int{1},
LegIntPurposes: []int{2, 7},
FlexiblePurposes: []int{2, 7},
},
"32": {
ID: 32,
Purposes: []int{1, 2, 4, 7},
Expand Down Expand Up @@ -353,11 +359,13 @@ func TestAllowPersonalInfoTCF2(t *testing.T) {
openrtb_ext.BidderAppnexus: 2,
openrtb_ext.BidderPubmatic: 6,
openrtb_ext.BidderRubicon: 8,
openrtb_ext.BidderOpenx: 20,
},
fetchVendorList: map[uint8]func(ctx context.Context, id uint16) (vendorlist.VendorList, error){
tcf1SpecVersion: nil,
tcf2SpecVersion: listFetcher(map[uint16]vendorlist.VendorList{
34: parseVendorListDataV2(t, vendorListData),
74: parseVendorListDataV2(t, vendorListData),
}),
},
}
Expand Down Expand Up @@ -389,6 +397,17 @@ func TestAllowPersonalInfoTCF2(t *testing.T) {
allowGeo: false,
allowID: true,
},
{
// This requires publisher restrictions on any claimed purposes, 2-10. Vendor must declare all claimed purposes
// as flex with legit interest as primary.
// Using vendor 20 for this.
description: "OpenX vendor test, Specific purposes/LIs claimed, no geo claimed, Publisher restrictions apply",
bidder: openrtb_ext.BidderOpenx,
consent: "CPAavcCPAavcCAGABCFRBKCsAP_AAH_AAAqIHFNf_X_fb3_j-_59_9t0eY1f9_7_v-0zjgeds-8Nyd_X_L8X5mM7vB36pq4KuR4Eu3LBAQdlHOHcTUmw6IkVqTPsbk2Mr7NKJ7PEinMbe2dYGH9_n9XT_ZKY79_____7__-_____7_f__-__3_vp9V---wOJAIMBAUAgAEMAAQIFCIQAAQhiQAAAABBCIBQJIAEqgAWVwEdoIEACAxAQgQAgBBQgwCAAQAAJKAgBACwQCAAiAQAAgAEAIAAEIAILACQEAAAEAJCAAiACECAgiAAg5DAgIgCCAFABAAAuJDACAMooASBAPGQGAAKAAqACGAEwALgAjgBlgDUAHZAPsA_ACMAFLAK2AbwBMQCbAFogLYAYEAw8BkQDOQGeAM-EQHwAVABWAC4AIYAZAAywBqADZAHYAPwAgABGAClgFPANYAdUA-QCGwEOgIvASIAmwBOwCkQFyAMCAYSAw8Bk4DOQGfCQAYADgBzgN_CQTgAEAALgAoACoAGQAOAAeABAACIAFQAMIAaABqADyAIYAigBMgCqAKwAWAAuABvADmAHoAQ0AiACJgEsAS4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QDaAG4APQAh0BF4CRAE2AJ2AUOApoBWwCxQFsALgAXIAu0BhoDDwGMAMiAZIAycBlwDOQGeAM-gaQBpMDWANZAbGVABAA-Ab-A.YAAAAAAAAAAA",
allowPI: true,
allowGeo: false,
allowID: true,
},
}

for _, td := range testDefs {
Expand Down

0 comments on commit 87277e1

Please sign in to comment.