Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
VeronikaSolovei9 committed Sep 24, 2023
1 parent 330af18 commit edf120a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
31 changes: 8 additions & 23 deletions exchange/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/prebid/prebid-server/ortb"
"math/rand"

"github.com/buger/jsonparser"
Expand Down Expand Up @@ -184,23 +185,17 @@ func (rs *requestSplitter) cleanOpenRTBRequests(ctx context.Context,
passIDActivityAllowed := auctionReq.Activities.Allow(privacy.ActivityTransmitUserFPD, scopedName, privacy.NewRequestFromBidRequest(*req))
if !passIDActivityAllowed {
//UFPD
privacy.ScrubDeviceIDs(reqWrapper)
privacy.ScrubUserIDs(reqWrapper)
privacy.ScrubUserExt(reqWrapper, "data")
privacy.ScrubUserFPD(reqWrapper)
} else {
// run existing policies (GDPR, CCPA, COPPA, LMT)
// potentially block passing IDs based on GDPR
if gdprEnforced {
if gdprErr == nil {
if !auctionPermissions.PassID {
privacy.ScrubDeviceIDs(reqWrapper)
privacy.ScrubUserDemographics(reqWrapper)
privacy.ScrubUserExt(reqWrapper, "eids")
privacy.ScrubGdprID(reqWrapper)
}
} else {
privacy.ScrubDeviceIDs(reqWrapper)
privacy.ScrubUserDemographics(reqWrapper)
privacy.ScrubUserExt(reqWrapper, "eids")
privacy.ScrubGdprID(reqWrapper)
}
}
// potentially block passing IDs based on CCPA
Expand All @@ -211,20 +206,17 @@ func (rs *requestSplitter) cleanOpenRTBRequests(ctx context.Context,

passGeoActivityAllowed := auctionReq.Activities.Allow(privacy.ActivityTransmitPreciseGeo, scopedName, privacy.NewRequestFromBidRequest(*req))
if !passGeoActivityAllowed {
privacy.ScrubGEO(reqWrapper)
privacy.ScrubDeviceIP(reqWrapper, ipConf)
privacy.ScrubGeoAndDeviceIP(reqWrapper, ipConf)
} else {
// run existing policies (GDPR, CCPA, COPPA, LMT)
// potentially block passing geo based on GDPR
if gdprEnforced {
if gdprErr == nil {
if !auctionPermissions.PassGeo {
privacy.ScrubDeviceIP(reqWrapper, ipConf)
privacy.ScrubGEO(reqWrapper)
privacy.ScrubGeoAndDeviceIP(reqWrapper, ipConf)
}
} else {
privacy.ScrubDeviceIP(reqWrapper, ipConf)
privacy.ScrubGEO(reqWrapper)
privacy.ScrubGeoAndDeviceIP(reqWrapper, ipConf)
}
}
// potentially block passing geo based on CCPA
Expand Down Expand Up @@ -267,15 +259,8 @@ func cloneBidderReq(req *openrtb2.BidRequest) *openrtb_ext.RequestWrapper {
newReq = ptrutil.Clone(req)

if req.User != nil {
var userCopy *openrtb2.User
userCopy = ptrutil.Clone(req.User)
userCopy := ortb.CloneUser(req.User)
newReq.User = userCopy

if req.User.Geo != nil {
var userGeoCopy *openrtb2.Geo
userGeoCopy = ptrutil.Clone(req.User.Geo)
newReq.User.Geo = userGeoCopy
}
}

if req.Device != nil {
Expand Down
18 changes: 18 additions & 0 deletions privacy/scrubber.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ func ScrubDeviceIDsIPsUserDemoExt(reqWrapper *openrtb_ext.RequestWrapper, ipConf
}
}

func ScrubUserFPD(reqWrapper *openrtb_ext.RequestWrapper) {
ScrubDeviceIDs(reqWrapper)
ScrubUserIDs(reqWrapper)
ScrubUserExt(reqWrapper, "data")
reqWrapper.User.EIDs = nil
}

func ScrubGdprID(reqWrapper *openrtb_ext.RequestWrapper) {
ScrubDeviceIDs(reqWrapper)
ScrubUserDemographics(reqWrapper)
ScrubUserExt(reqWrapper, "eids")
}

func ScrubGeoAndDeviceIP(reqWrapper *openrtb_ext.RequestWrapper, ipConf IPConf) {
ScrubDeviceIP(reqWrapper, ipConf)
ScrubGEO(reqWrapper)
}

func scrubIP(ip string, ones, bits int) string {
if ip == "" {
return ""
Expand Down

0 comments on commit edf120a

Please sign in to comment.