Skip to content
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

Prebid v2.1.0 #668

Open
wants to merge 145 commits into
base: ci_backup_20240402
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
48e6275
DOOH support (#2758)
minaguib Sep 20, 2023
db87119
Record tmax timeout error in adapter error metric (#3104)
onkarvhanumante Sep 20, 2023
55302c6
Cleanup Prometheus Type Conversions (#3106)
SyntaxNode Sep 20, 2023
b9c2614
make case insensitive comparison in auction request (#3113)
gargcreation1992 Sep 25, 2023
a91e40c
Silvermob: host validation (us, eu, apac) (#3110)
freemmy Sep 26, 2023
63170b8
make bidderInfo endpoint case insensitive (#3136)
gargcreation1992 Sep 26, 2023
bc81af5
extract directory name only if file is not removed and file is in ada…
onkarvhanumante Sep 26, 2023
00bdbef
Support case insensitive bidder name in ext.prebid.storedbidresponse.…
onkarvhanumante Sep 26, 2023
940355c
Support case insensitive bidder name in adjustment factors (#3140)
onkarvhanumante Sep 26, 2023
27498c8
Support case insensitive bidder name in ext.prebid.data.eidpermission…
onkarvhanumante Sep 26, 2023
6738217
Remove Adapter: RhythmOne (#3129)
SyntaxNode Sep 26, 2023
18edf18
make NormalizeBidderName to do faster lookup (#3138)
gargcreation1992 Sep 26, 2023
d10ccf6
Remove Adapter: Applogy (#3130)
SyntaxNode Sep 26, 2023
aff482f
Remove Adapter: Define Media (#3132)
SyntaxNode Sep 26, 2023
10d854c
Remove Adapter: Kubient (#3133)
SyntaxNode Sep 26, 2023
03779e3
Remove Adapter: NinthDecimal (#3142)
SyntaxNode Sep 26, 2023
e3cf3c3
Remove Adapter: Yeahmobi (#3143)
SyntaxNode Sep 26, 2023
f2230c8
Remove Adapter: engageBDR (#3131)
SyntaxNode Sep 26, 2023
0d96c9d
Remove Adapter: Nano Interactive (#3134)
SyntaxNode Sep 26, 2023
efdda05
Remove Config Backwards Compatibility: File System Stored Requests (#…
bsardo Sep 27, 2023
0c8f79b
Remove Config Backwards Compatibility: Enable Events (#3135)
bsardo Sep 27, 2023
fc36944
Remove Config Backwards Compatibility: Enable GZIP (#3125)
bsardo Sep 27, 2023
f879f63
Remove Config Backwards Compatibility: DB Connection Info (#3146)
bsardo Sep 28, 2023
0d488ee
ImproveDigital: updates (#3077)
ishihanvcs Sep 29, 2023
6a36178
[ORBIDDER] add user sync redirect url (#3118)
arneschulz1984 Sep 29, 2023
4ad946b
Adnuntius: Add Price Type (#3084)
mikael-lundin Sep 29, 2023
9e14c09
Rubicon: Remove eids logic (#3111)
SerhiiNahornyi Sep 29, 2023
061aa84
Adapter alias - syncer changes (#3082)
onkarvhanumante Sep 29, 2023
1a5f12c
Remove Config Backwards Compatibility: Host GDPR Options (#3153)
bsardo Sep 29, 2023
5cc92ae
Remove Config Backwards Compatibility: Account GDPR Purpose (#3154)
bsardo Sep 29, 2023
1360786
Remove Deprecated Config: Account Blacklist (#3156)
SyntaxNode Oct 2, 2023
a2e387f
Remove Config Backwards Compatibility: Account GDPR/CCPA Integration …
bsardo Oct 3, 2023
781dc7b
Remove Config Backwards Compatibility: User Sync URL (#3163)
SyntaxNode Oct 4, 2023
134e9aa
Analytics activities (#3024)
VeronikaSolovei9 Oct 4, 2023
324a973
update lunamedia contact info (#3137)
bretg Oct 5, 2023
8cdfe48
enable adapter alias feature (#3179)
gargcreation1992 Oct 5, 2023
23bc394
New Adapter: smartx (#3109)
fkoch-sc Oct 9, 2023
1944dbb
Adapter Name Case Insensitive: EID Permissions (#3187)
SyntaxNode Oct 9, 2023
e76b4b3
OneTag: ORTB 2.6 initial support (#3128)
EmanueleSimonelli Oct 10, 2023
c8f3b2d
Adapter Name Case Insensitive: SetUID Endpoint (#3186)
SyntaxNode Oct 10, 2023
81c78ff
pubmatic: add fledge support (#3174)
pm-nilesh-chate Oct 11, 2023
3c7d852
New Adapter: Edge226 (#3105)
Edge226Ads Oct 16, 2023
6f4bb59
New Adapter: Teads (#3112)
github-maxime-liege Oct 16, 2023
dff9b3b
Updated User Sync Support and GPP Support Flag (#3181)
vrtcal-dev Oct 16, 2023
987e640
make event endpoint case insensitive (#3199)
gargcreation1992 Oct 16, 2023
05e06bb
New Adapter: LemmaDigital (#3157)
lm-ved Oct 16, 2023
2dbf671
minduration non-required (#3185)
ikagotso Oct 16, 2023
c45ab81
add supportCORS to orbidder user sync config (#3193)
arneschulz1984 Oct 16, 2023
9d216fb
Adapter Name Case Insensitive: /vtrack endpoint (#3196)
onkarvhanumante Oct 16, 2023
5b44d36
Prometheus metrics: bidder name should be in lowercase (#3198)
onkarvhanumante Oct 16, 2023
6c6aa9a
InfluxDB metrics : bidder name should be in lowercase (#3209)
onkarvhanumante Oct 16, 2023
eea6ffe
migrate adform alias to use new pattern (#3180)
gargcreation1992 Oct 17, 2023
293cadc
migrate copper alias to use new pattern (#3182)
gargcreation1992 Oct 17, 2023
1384564
update cookie sync endpoint to be case insensitive (#3103)
gargcreation1992 Oct 17, 2023
b3e5d1d
Adapter Name Case Insensitive: user.ext.prebid.buyeruids (#3152)
Sonali-More-Xandr Oct 17, 2023
f152b0d
Adapter Name Case Insensitive: Bid Adjustment Factors (#3210)
AlexBVolcy Oct 17, 2023
17109ca
Welcome Back: yeahmobi (#3228)
SyntaxNode Oct 18, 2023
11ef54d
Adapter Name Case Insensitive: First Party Data (#3211)
SyntaxNode Oct 18, 2023
bde7bcf
Adapter Name Case Insensitive: ext.prebid.multibid (#3217)
guscarreon Oct 18, 2023
f4425b6
migrate janet alias to use new pattern (#3189)
gargcreation1992 Oct 18, 2023
83c7946
migrate janet alias to use new pattern (#3190)
gargcreation1992 Oct 18, 2023
32ddaca
migrate streamkey alias to use new pattern (#3191)
gargcreation1992 Oct 18, 2023
9bfe196
migrate viewdeos alias to use new pattern (#3192)
gargcreation1992 Oct 18, 2023
91881fe
migrate limelight aliases to follow new pattern (#3183)
onkarvhanumante Oct 18, 2023
ac7a0d4
migrate apacdex aliases to use new pattern (#3184)
onkarvhanumante Oct 18, 2023
bc77035
Update release workflow to support major version release (#3235)
onkarvhanumante Oct 18, 2023
8131a14
New Adapter: IQX (#3164)
IQzoneIT Oct 19, 2023
e8d93cc
HuaweiAds: Fixing the fill rate issue (#3219)
ahmetfaruk59 Oct 19, 2023
34ddf1a
DXKulture adapter (#3176)
bev-devops Oct 19, 2023
6f630fd
JSON Serialization: Change Libraries (#3225)
bsardo Oct 19, 2023
cd03a0f
Restore Alias User Syncs (#3244)
SyntaxNode Oct 19, 2023
50ad642
Revert "Remove Adapter: Define Media" (#3242)
dennisjay Oct 19, 2023
53e0adc
Adapter Name Case Insensitive: Stored Bid Responses (#3197)
VeronikaSolovei9 Oct 20, 2023
6b98a81
Adapter Name Case Insensitive: alternate bidder codes (#3229)
guscarreon Oct 20, 2023
ec729e6
Increment Package Version To V2 (#3245)
SyntaxNode Oct 20, 2023
2540dd8
RTBHouse: native support (#3212)
piotrj-rtbh Oct 30, 2023
8e9f3f3
Rubicon: Add `imp[].ext.rp.rtb.formats` logic (#3255)
SerhiiNahornyi Oct 30, 2023
3834c22
Revert "Rubicon: Add `imp[].ext.rp.rtb.formats` logic (#3255)" (#3268)
Sonali-More-Xandr Oct 30, 2023
72463be
Revert "RTBHouse: native support (#3212)" (#3271)
bsardo Oct 30, 2023
b200357
Increment to V2 in Dockerfile and Makefile (#3272)
guscarreon Oct 31, 2023
5941d46
Fix: BidderInfo OpenRTB field data lost on start up (#3178)
ashishshinde-pubm Nov 13, 2023
9099264
Fix for null string unmarshal error (#3284)
VeronikaSolovei9 Nov 13, 2023
f52dbb1
Fix: use bidder info fs config as base when merging overrides (#3289)
bsardo Nov 14, 2023
180eb41
Fix: Revert JSON lib used to prepare /bidders/params response (#3300)
bsardo Nov 15, 2023
ea04a39
Bump golang.org/x/net from 0.7.0 to 0.17.0 (#3202)
dependabot[bot] Nov 16, 2023
ee0869d
Bump google.golang.org/grpc from 1.53.0 to 1.56.3 (#3258)
dependabot[bot] Nov 16, 2023
fb94284
Floors: Dynamic fetch (#2732)
pm-nikhil-vaidya Nov 16, 2023
f9f5546
Modularity: Make request wrapper accessible in bidder request hook (#…
VeronikaSolovei9 Nov 16, 2023
b904b53
fix: pass through bid.prebid.meta, currently it is being dropped (#3100)
ccorbo Nov 16, 2023
905436f
Add debug flag to cookie sync endpoint (#3107)
AlexBVolcy Nov 16, 2023
6a20c0e
Privacy scrubber refactoring (#3108)
VeronikaSolovei9 Nov 16, 2023
79d2f27
Zeta Global SSP: Update endpoints (#3201)
abermanov-zeta Nov 16, 2023
832fbf2
PubMatic: Support hardcoded alias (#3224)
pm-nilesh-chate Nov 16, 2023
9693797
GumGum: Add product parameter (#3253)
gg-natalia Nov 16, 2023
738884f
Migrate yahooAdvertising alias of yahooAds to use new pattern (#3203)
Sonali-More-Xandr Nov 17, 2023
21ee27b
Migrate synacormedia alias of imds to use new pattern (#3205)
Sonali-More-Xandr Nov 17, 2023
7e06aae
Migrate epsilon alias of conversant to use new pattern (#3207)
Sonali-More-Xandr Nov 17, 2023
f5f1e07
BMTM: app support (#3280)
Nov 17, 2023
515b937
HuaweiAds: Increase fill rate for native ads (#3279)
ahmetfaruk59 Nov 20, 2023
cad9097
Flipp: abide by privacy concerns when using flippExt userKey (#3250)
hasan-kanjee Nov 20, 2023
01f3320
New Adapter: oms (#3264)
m6yf Nov 20, 2023
94d8682
adquery: added device ip and ua to bidder request (#1) (#3288)
wgalecki Nov 20, 2023
ea01ccf
update contact email address (#3298)
Vungle-GordonTian Nov 20, 2023
1e89053
Change endpoint for Teads adapter (#3303)
github-maxime-liege Nov 20, 2023
06e1145
New Adapter: Alkimi (#3247)
kalidas-alkimi Nov 20, 2023
e5c920a
Pass currency converter to modules (#3278)
pm-nilesh-chate Nov 20, 2023
6869211
Adapter Name Case Insensitive: dealTier (#3218)
guscarreon Nov 20, 2023
8419142
bliink: iframe added to usersync (#3243)
LouisBillaut Nov 23, 2023
54039e9
Add indicue adapter (#3291)
GeneGenie Nov 23, 2023
6f5b03e
Huaweiads: Remove empty image assets from response (#3308)
ahmetfaruk59 Nov 23, 2023
4cc2faa
IX: add privacy sandbox support (#3252)
ccorbo Nov 23, 2023
eb79f41
Migrate yahoossp alias of yahooAds to use new pattern (#3208)
Sonali-More-Xandr Nov 27, 2023
7558fde
Migrate trustx alias of grid to use new pattern (#3206)
Sonali-More-Xandr Nov 27, 2023
fb5e849
Migrate freewheelsspold alias of frewheelssp to use new pattern (#3204)
Sonali-More-Xandr Nov 27, 2023
9cf8acc
Fix: flakey deal tier test (#3322)
bsardo Nov 27, 2023
020a7dd
Fix: refactor flakey category dedupe test (#3310)
bsardo Nov 27, 2023
df072ff
Allow bidders to skip sync for GDPR/GPP (#3265)
AlexBVolcy Nov 27, 2023
d82c997
Boldwin: add user sync url (#3316)
Wls-demo Nov 28, 2023
b7d474f
Fix: Adhese handle 200 response with empty array body (#3323)
bsardo Nov 28, 2023
a6dea2f
Yieldmo: Get bid type from bid.ext.mediatype in bid response (#3295)
ym-prasanth Nov 30, 2023
e2da446
Fix: setuid endpoint sets cookie when both GDPR and GPP are set (#3165)
ashishshinde-pubm Dec 1, 2023
4de96b2
Fix: single bid processing from alternatebiddercode (#3313)
ashishshinde-pubm Dec 4, 2023
1fe320f
HuaweiAds: add popular sizes for video native (#3324)
ahmetfaruk59 Dec 5, 2023
c7f3e22
Add Embi media adapter (#3325)
apykhteyev Dec 5, 2023
db74611
RTBHouse: native support (renewal) (#3328)
piotrj-rtbh Dec 5, 2023
005a2d1
New Adapter: Relevant Digital (#3216)
hugolm84 Dec 5, 2023
3f42b89
Liftoff: Add site support and fill seat (#3327)
Vungle-GordonTian Dec 5, 2023
8128b24
Add Flag for Host to Enabled/Disable Bidder from Usersync (#3285)
AlexBVolcy Dec 5, 2023
9644543
seedingAlliance: make suntContent alias, add finative alias and add s…
sag-henmus Dec 7, 2023
ec873dc
Modules activities (#3057)
VeronikaSolovei9 Dec 11, 2023
25ce28c
Merge branch 'prebid_v2.0.2' into prebid_v2.1.0
Pubmatic-Supriya-Patil Dec 12, 2023
a90806c
Merge branch 'ci' into prebid_v2.1.0
Pubmatic-Supriya-Patil Dec 12, 2023
d4750c7
Merge branch 'ci' into prebid_v2.1.0
Pubmatic-Supriya-Patil Dec 12, 2023
7067a78
UT Fix TestInitiateReloader
Pubmatic-Supriya-Patil Dec 13, 2023
c05ba76
Added missing code
Pubmatic-Supriya-Patil Dec 15, 2023
823227a
UT Fix
Pubmatic-Supriya-Patil Dec 15, 2023
dbb3b41
Fix: Pass through entire bid.prebid.meta
Pubmatic-Supriya-Patil Dec 18, 2023
e09eb13
Merge branch 'ci' of github.com:PubMatic-OpenWrap/prebid-server into …
Pubmatic-Supriya-Patil Feb 14, 2024
cbb68bc
Merge branch 'ci' of github.com:PubMatic-OpenWrap/prebid-server into …
Pubmatic-Supriya-Patil Feb 15, 2024
9849cba
formatting changes
Pubmatic-Supriya-Patil Feb 15, 2024
25b8f08
Merge branch 'ci' of github.com:PubMatic-OpenWrap/prebid-server into …
Pubmatic-Supriya-Patil Feb 16, 2024
cc0f527
Added currency conversion fix
Pubmatic-Supriya-Patil Feb 16, 2024
b5e9905
Merge tag 'v2.2.0' into prebid_v2.1.0
Pubmatic-Supriya-Patil Feb 21, 2024
17efdb2
Merge branch 'ci' of github.com:PubMatic-OpenWrap/prebid-server into …
Pubmatic-Supriya-Patil Feb 21, 2024
4d32a33
Updated import to v2 version
Pubmatic-Supriya-Patil Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions .github/workflows/adapter-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
result-encoding: string
script: |
const utils = require('./.github/workflows/helpers/pull-request-utils.js')
function directoryExtractor(filepath) {
// extract directory name from filepath of the form adapters/<adapter-name>/*.go
if (filepath.startsWith("adapters/") && filepath.split("/").length > 2) {
function directoryExtractor(filepath, status) {
// extract directory name only if file is not removed and file is in adapters directory
if (status != "removed" && filepath.startsWith("adapters/") && filepath.split("/").length > 2) {
return filepath.split("/")[1]
}
return ""
Expand All @@ -41,7 +41,7 @@ jobs:

- name: Run coverage tests
id: run_coverage
if: ${{ steps.get_directories.outputs.result }} != ""
if: steps.get_directories.outputs.result != ''
run: |
git config --global url."https://${USERNAME}:${TOKEN}@git.pubmatic.com".insteadOf "https://git.pubmatic.com"

Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
repository: PubMatic-OpenWrap/prebid-server

- name: Commit coverage files to coverage-preview branch
if: ${{ steps.run_coverage.outputs.coverage_dir }} != ""
if: steps.run_coverage.outputs.coverage_dir != ''
id: commit_coverage
run: |
directory=.github/preview/${{ github.run_id }}_$(date +%s)
Expand All @@ -95,11 +95,11 @@ jobs:
echo "remote_coverage_preview_dir=${directory}" >> $GITHUB_OUTPUT

- name: Checkout master branch
if: ${{ steps.get_directories.outputs.result }} != ""
if: steps.get_directories.outputs.result != ''
run: git checkout master

- name: Add coverage summary to pull request
if: ${{ steps.run_coverage.outputs.coverage_dir }} != "" && ${{ steps.commit_coverage.outputs.remote_coverage_preview_dir }} != ""
if: steps.run_coverage.outputs.coverage_dir != '' && steps.commit_coverage.outputs.remote_coverage_preview_dir != ''
uses: actions/github-script@v6
with:
script: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/helpers/pull-request-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ class diffHelper {
})

const directories = []
for (const { filename } of data) {
const directory = directoryExtractor(filename)
for (const { filename, status } of data) {
const directory = directoryExtractor(filename, status)
if (directory != "" && !directories.includes(directory)) {
directories.push(directory)
}
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ on:
releaseType:
type: choice
options:
- major
- minor
- patch
default: minor
required: true
description: 'minor: v0.X.0, patch: v0.0.X'
description: 'major: vX.0.0, minor: v0.X.0, patch: v0.0.X'
debug:
type: boolean
default: true
Expand Down Expand Up @@ -78,11 +79,18 @@ jobs:

nextTag=''
releaseType=${{ inputs.releaseType }}
if [ $releaseType == "minor" ]; then
# increment minor version and reset patch version
nextTag=$(echo "${currentTag}" | awk -F. '{OFS="."; $2+=1; $3=0; print $0}')
if [ $releaseType == "major" ]; then
# PBS-GO skipped the v1.0.0 major release - https://github.com/prebid/prebid-server/issues/3068
# If the current tag is v0.x.x, the script sets the next release tag to v2.0.0
# Otherwise, the script increments the major version by 1 and sets the minor and patch versions to zero
# For example, v2.x.x will be incremented to v3.0.0
major=$(echo "${currentTag}" | awk -F. '{gsub(/^v/, "", $1); if($1 == 0) $1=2; else $1+=1; print $1}')
nextTag="v${major}.0.0"
elif [ $releaseType == "minor" ]; then
# Increment minor version and reset patch version
nextTag=$(echo "${currentTag}" | awk -F. '{OFS="."; $2+=1; $3=0; print $0}')
else
# increment patch version
# Increment patch version
nextTag=$(echo "${currentTag}" | awk -F. '{OFS="."; $3+=1; print $0}')
fi

Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ vendor

# build artifacts
prebid-server
build
debug
/build
/debug
__debug_bin

# config files
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN go mod tidy
RUN go mod vendor
ARG TEST="true"
RUN if [ "$TEST" != "false" ]; then ./validate.sh ; fi
RUN go build -mod=vendor -ldflags "-X github.com/prebid/prebid-server/version.Ver=`git describe --tags | sed 's/^v//'` -X github.com/prebid/prebid-server/version.Rev=`git rev-parse HEAD`" .
RUN go build -mod=vendor -ldflags "-X github.com/prebid/prebid-server/v2/version.Ver=`git describe --tags | sed 's/^v//'` -X github.com/prebid/prebid-server/v2/version.Rev=`git rev-parse HEAD`" .

FROM ubuntu:20.04 AS release
LABEL maintainer="hans.hjort@xandr.com"
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test: deps
ifeq "$(adapter)" ""
./validate.sh
else
go test github.com/prebid/prebid-server/adapters/$(adapter) -bench=.
go test github.com/prebid/prebid-server/v2/adapters/$(adapter) -bench=.
endif

# build-modules generates modules/builder.go file which provides a list of all available modules
Expand Down Expand Up @@ -43,16 +43,16 @@ mockgeninstall:
mockgendb:
mkdir -p modules/pubmatic/openwrap/database/mock modules/pubmatic/openwrap/database/mock_driver
mockgen database/sql/driver Driver,Connector,Conn,DriverContext > modules/pubmatic/openwrap/database/mock_driver/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/modules/pubmatic/openwrap/database Database > modules/pubmatic/openwrap/database/mock/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/modules/pubmatic/openwrap/database Database > modules/pubmatic/openwrap/database/mock/mock.go

mockgencache:
mkdir -p modules/pubmatic/openwrap/cache/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/modules/pubmatic/openwrap/cache Cache > modules/pubmatic/openwrap/cache/mock/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/modules/pubmatic/openwrap/cache Cache > modules/pubmatic/openwrap/cache/mock/mock.go

mockgenmetrics:
mkdir -p modules/pubmatic/openwrap/metrics/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/modules/pubmatic/openwrap/metrics MetricsEngine > modules/pubmatic/openwrap/metrics/mock/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/modules/pubmatic/openwrap/metrics MetricsEngine > modules/pubmatic/openwrap/metrics/mock/mock.go

mockgenlogger:
mkdir -p analytics/pubmatic/mhttp/mock
mockgen github.com/PubMatic-OpenWrap/prebid-server/analytics/pubmatic/mhttp HttpCallInterface,MultiHttpContextInterface > analytics/pubmatic/mhttp/mock/mock.go
mockgen github.com/PubMatic-OpenWrap/prebid-server/v2/analytics/pubmatic/mhttp HttpCallInterface,MultiHttpContextInterface > analytics/pubmatic/mhttp/mock/mock.go
170 changes: 15 additions & 155 deletions account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,27 @@ package account

import (
"context"
"encoding/json"
"fmt"
"github.com/buger/jsonparser"

"github.com/prebid/go-gdpr/consentconstants"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/errortypes"
"github.com/prebid/prebid-server/metrics"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/prebid/prebid-server/stored_requests"
"github.com/prebid/prebid-server/util/iputil"
jsonpatch "gopkg.in/evanphx/json-patch.v4"

"github.com/prebid/prebid-server/v2/config"
"github.com/prebid/prebid-server/v2/errortypes"
"github.com/prebid/prebid-server/v2/metrics"
"github.com/prebid/prebid-server/v2/openrtb_ext"
"github.com/prebid/prebid-server/v2/stored_requests"
"github.com/prebid/prebid-server/v2/util/iputil"
"github.com/prebid/prebid-server/v2/util/jsonutil"
)

// GetAccount looks up the config.Account object referenced by the given accountID, with access rules applied
func GetAccount(ctx context.Context, cfg *config.Configuration, fetcher stored_requests.AccountFetcher, accountID string, me metrics.MetricsEngine) (account *config.Account, errs []error) {
// Check BlacklistedAcctMap until we have deprecated it
if _, found := cfg.BlacklistedAcctMap[accountID]; found {
return nil, []error{&errortypes.BlacklistedAcct{
Message: fmt.Sprintf("Prebid-server has disabled Account ID: %s, please reach out to the prebid server host.", accountID),
}}
}
if cfg.AccountRequired && accountID == metrics.PublisherUnknown {
return nil, []error{&errortypes.AcctRequired{
Message: fmt.Sprintf("Prebid-server has been configured to discard requests without a valid Account ID. Please reach out to the prebid server host."),
}}
}

if accountJSON, accErrs := fetcher.FetchAccount(ctx, cfg.AccountDefaultsJSON(), accountID); len(accErrs) > 0 || accountJSON == nil {
// accountID does not reference a valid account
for _, e := range accErrs {
Expand All @@ -49,45 +44,12 @@ func GetAccount(ctx context.Context, cfg *config.Configuration, fetcher stored_r
} else {
// accountID resolved to a valid account, merge with AccountDefaults for a complete config
account = &config.Account{}
err := json.Unmarshal(accountJSON, account)

// this logic exists for backwards compatibility. If the initial unmarshal fails above, we attempt to
// resolve it by converting the GDPR enforce purpose fields and then attempting an unmarshal again before
// declaring a malformed account error.
// unmarshal fetched account to determine if it is well-formed
var deprecatedPurposeFields []string
if _, ok := err.(*json.UnmarshalTypeError); ok {
// attempt to convert deprecated GDPR enforce purpose fields to resolve issue
accountJSON, err, deprecatedPurposeFields = ConvertGDPREnforcePurposeFields(accountJSON)
// unmarshal again to check if unmarshal error still exists after GDPR field conversion
err = json.Unmarshal(accountJSON, account)

if _, ok := err.(*json.UnmarshalTypeError); ok {
return nil, []error{&errortypes.MalformedAcct{
Message: fmt.Sprintf("The prebid-server account config for account id \"%s\" is malformed. Please reach out to the prebid server host.", accountID),
}}
}
}
usingGDPRChannelEnabled := useGDPRChannelEnabled(account)
usingCCPAChannelEnabled := useCCPAChannelEnabled(account)

if usingGDPRChannelEnabled {
me.RecordAccountGDPRChannelEnabledWarning(accountID)
}
if usingCCPAChannelEnabled {
me.RecordAccountCCPAChannelEnabledWarning(accountID)
}
for _, purposeName := range deprecatedPurposeFields {
me.RecordAccountGDPRPurposeWarning(accountID, purposeName)
}
if len(deprecatedPurposeFields) > 0 || usingGDPRChannelEnabled || usingCCPAChannelEnabled {
me.RecordAccountUpgradeStatus(accountID)
if err := jsonutil.UnmarshalValid(accountJSON, account); err != nil {
return nil, []error{&errortypes.MalformedAcct{
Message: fmt.Sprintf("The prebid-server account config for account id \"%s\" is malformed. Please reach out to the prebid server host.", accountID),
}}
}

if err != nil {
errs = append(errs, err)
return nil, errs
}
// Fill in ID if needed, so it can be left out of account definition
if len(account.ID) == 0 {
account.ID = accountID
Expand All @@ -97,7 +59,7 @@ func GetAccount(ctx context.Context, cfg *config.Configuration, fetcher stored_r
setDerivedConfig(account)
}
if account.Disabled {
errs = append(errs, &errortypes.BlacklistedAcct{
errs = append(errs, &errortypes.AccountDisabled{
Message: fmt.Sprintf("Prebid-server has disabled Account ID: %s, please reach out to the prebid server host.", accountID),
})
return nil, errs
Expand All @@ -111,9 +73,6 @@ func GetAccount(ctx context.Context, cfg *config.Configuration, fetcher stored_r
account.Privacy.IPv4Config.AnonKeepBits = iputil.IPv4DefaultMaskingBitSize
}

// set the value of events.enabled field based on deprecated events_enabled field and ensure backward compatibility
deprecateEventsEnabledField(account)

return account, nil
}

Expand Down Expand Up @@ -178,102 +137,3 @@ func setDerivedConfig(account *config.Account) {
}
}
}

// PatchAccount represents the GDPR portion of a publisher account configuration that can be mutated
// for backwards compatibility reasons
type PatchAccount struct {
GDPR map[string]*PatchAccountGDPRPurpose `json:"gdpr"`
}

// PatchAccountGDPRPurpose represents account-specific GDPR purpose configuration data that can be mutated
// for backwards compatibility reasons
type PatchAccountGDPRPurpose struct {
EnforceAlgo string `json:"enforce_algo,omitempty"`
EnforcePurpose *bool `json:"enforce_purpose,omitempty"`
}

// ConvertGDPREnforcePurposeFields is responsible for ensuring account GDPR config backwards compatibility
// given the recent type change of gdpr.purpose{1-10}.enforce_purpose from a string to a bool. This function
// iterates over each GDPR purpose config and sets enforce_purpose and enforce_algo to the appropriate
// bool and string values respectively if enforce_purpose is a string and enforce_algo is not set
func ConvertGDPREnforcePurposeFields(config []byte) (newConfig []byte, err error, deprecatedPurposeFields []string) {
gdprJSON, _, _, err := jsonparser.Get(config, "gdpr")
if err != nil && err == jsonparser.KeyPathNotFoundError {
return config, nil, deprecatedPurposeFields
}
if err != nil {
return nil, err, deprecatedPurposeFields
}

newAccount := PatchAccount{
GDPR: map[string]*PatchAccountGDPRPurpose{},
}

for i := 1; i <= 10; i++ {
purposeName := fmt.Sprintf("purpose%d", i)

enforcePurpose, purposeDataType, _, err := jsonparser.Get(gdprJSON, purposeName, "enforce_purpose")
if err != nil && err == jsonparser.KeyPathNotFoundError {
continue
}
if err != nil {
return nil, err, deprecatedPurposeFields
}
if purposeDataType != jsonparser.String {
continue
} else {
deprecatedPurposeFields = append(deprecatedPurposeFields, purposeName)
}

_, _, _, err = jsonparser.Get(gdprJSON, purposeName, "enforce_algo")
if err != nil && err != jsonparser.KeyPathNotFoundError {
return nil, err, deprecatedPurposeFields
}
if err == nil {
continue
}

newEnforcePurpose := false
if string(enforcePurpose) == "full" {
newEnforcePurpose = true
}

newAccount.GDPR[purposeName] = &PatchAccountGDPRPurpose{
EnforceAlgo: "full",
EnforcePurpose: &newEnforcePurpose,
}
}

patchConfig, err := json.Marshal(newAccount)
if err != nil {
return nil, err, deprecatedPurposeFields
}

newConfig, err = jsonpatch.MergePatch(config, patchConfig)
if err != nil {
return nil, err, deprecatedPurposeFields
}

return newConfig, nil, deprecatedPurposeFields
}

func useGDPRChannelEnabled(account *config.Account) bool {
return account.GDPR.ChannelEnabled.IsSet() && !account.GDPR.IntegrationEnabled.IsSet()
}

func useCCPAChannelEnabled(account *config.Account) bool {
return account.CCPA.ChannelEnabled.IsSet() && !account.CCPA.IntegrationEnabled.IsSet()
}

// deprecateEventsEnabledField is responsible for ensuring backwards compatibility of "events_enabled" field.
// This function favors "events.enabled" field over deprecated "events_enabled" field, if values for both are set.
// If only deprecated "events_enabled" field is set then it sets the same value to "events.enabled" field.
func deprecateEventsEnabledField(account *config.Account) {
if account != nil {
if account.Events.Enabled == nil {
account.Events.Enabled = account.EventsEnabled
}
// assign the old value to the new value so old and new are always the same even though the new value is what is used in the application code.
account.EventsEnabled = account.Events.Enabled
}
}
Loading
Loading