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

Build test #944

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions:
pull-requests: write
jobs:
semgrep-check:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04.5
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Install semgrep
if: contains(steps.should_run_semgrep.outputs.hasChanges, 'true')
run: |
pip3 install semgrep==1.22.0
pip3 install semgrep==1.22.0 --break-system-packages.
semgrep --version

- name: Run semgrep tests
Expand Down
39 changes: 33 additions & 6 deletions adapters/pubmatic/pubmatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type extRequestAdServer struct {
Wrapper *pubmaticWrapperExt `json:"wrapper,omitempty"`
Acat []string `json:"acat,omitempty"`
Marketplace *marketplaceReqExt `json:"marketplace,omitempty"`
SendBurl bool `json:"sendburl,omitempty"`
openrtb_ext.ExtRequest
}

Expand All @@ -113,6 +114,11 @@ func (a *PubmaticAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ad
extractWrapperExtFromImp := true
extractPubIDFromImp := true

displayManager, displayManagerVer := "", ""
if request.App != nil && request.App.Ext != nil {
displayManager, displayManagerVer = getDisplayManagerAndVer(request.App)
}

newReqExt, cookies, err := extractPubmaticExtFromRequest(request)
if err != nil {
return nil, []error{err}
Expand All @@ -125,7 +131,7 @@ func (a *PubmaticAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ad
impFloorsMap := map[string][]float64{}

for i := 0; i < len(request.Imp); i++ {
wrapperExtFromImp, pubIDFromImp, floors, err := parseImpressionObject(&request.Imp[i], extractWrapperExtFromImp, extractPubIDFromImp)
wrapperExtFromImp, pubIDFromImp, floors, err := parseImpressionObject(&request.Imp[i], extractWrapperExtFromImp, extractPubIDFromImp, displayManager, displayManagerVer)
// If the parsing is failed, remove imp and add the error.
if err != nil {
errs = append(errs, err)
Expand Down Expand Up @@ -383,7 +389,7 @@ func assignBannerWidthAndHeight(banner *openrtb2.Banner, w, h int64) *openrtb2.B
}

// parseImpressionObject parse the imp to get it ready to send to pubmatic
func parseImpressionObject(imp *openrtb2.Imp, extractWrapperExtFromImp, extractPubIDFromImp bool) (*pubmaticWrapperExt, string, []float64, error) {
func parseImpressionObject(imp *openrtb2.Imp, extractWrapperExtFromImp, extractPubIDFromImp bool, displayManager, displayManagerVer string) (*pubmaticWrapperExt, string, []float64, error) {
var wrapExt *pubmaticWrapperExt
var pubID string
var floors []float64
Expand All @@ -397,6 +403,12 @@ func parseImpressionObject(imp *openrtb2.Imp, extractWrapperExtFromImp, extractP
imp.Audio = nil
}

// Populate imp.displaymanager and imp.displaymanagerver if the SDK failed to do it.
if imp.DisplayManager == "" && imp.DisplayManagerVer == "" && displayManager != "" && displayManagerVer != "" {
imp.DisplayManager = displayManager
imp.DisplayManagerVer = displayManagerVer
}

var bidderExt ExtImpBidderPubmatic
if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil {
return wrapExt, pubID, floors, err
Expand Down Expand Up @@ -451,10 +463,6 @@ func parseImpressionObject(imp *openrtb2.Imp, extractWrapperExtFromImp, extractP
extMap[pmZoneIDKeyName] = pubmaticExt.PmZoneID
}

if pubmaticExt.SendBurl {
extMap[sendBurlKey] = pubmaticExt.SendBurl
}

if bidderExt.SKAdnetwork != nil {
extMap[skAdnetworkKey] = bidderExt.SKAdnetwork
}
Expand Down Expand Up @@ -560,6 +568,9 @@ func extractPubmaticExtFromRequest(request *openrtb2.BidRequest) (extRequestAdSe
if wrapperObj, present := reqExtBidderParams["Cookie"]; present && len(wrapperObj) != 0 {
err = json.Unmarshal(wrapperObj, &cookies)
}
if sendBurl, ok := reqExtBidderParams[sendBurlKey]; ok {
pmReqExt.SendBurl, _ = strconv.ParseBool(string(sendBurl))
}
// OW patch -end-

return pmReqExt, cookies, nil
Expand Down Expand Up @@ -854,3 +865,19 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co
}
return bidder, nil
}

// getDisplayManagerAndVer returns the display manager and version from the request.app.ext or request.app.prebid.ext source and version
func getDisplayManagerAndVer(app *openrtb2.App) (string, string) {
if source, err := jsonparser.GetString(app.Ext, openrtb_ext.PrebidExtKey, "source"); err == nil && source != "" {
if version, err := jsonparser.GetString(app.Ext, openrtb_ext.PrebidExtKey, "version"); err == nil && version != "" {
return source, version
}
}

if source, err := jsonparser.GetString(app.Ext, "source"); err == nil && source != "" {
if version, err := jsonparser.GetString(app.Ext, "version"); err == nil && version != "" {
return source, version
}
}
return "", ""
}
Loading
Loading