github.com/prebid/prebid-server@v0.275.0/.semgrep/adapter/parse-bid-type-check.go (about) 1 /* 2 parse-bid-type-check tests 3 https://semgrep.dev/docs/writing-rules/testing-rules 4 "ruleid" prefix in comment indicates patterns that should be flagged by semgrep 5 "ok" prefix in comment indidcates patterns that should not be flagged by the semgrep 6 */ 7 8 func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { 9 if bid.Ext != nil { 10 var bidExt openrtb_ext.ExtBid 11 err := json.Unmarshal(bid.Ext, &bidExt) 12 if err == nil && bidExt.Prebid != nil { 13 // ruleid: parse-bid-type-check 14 return openrtb_ext.ParseBidType(string(bidExt.Prebid.Type)) 15 } 16 } 17 18 return "", &errortypes.BadServerResponse{ 19 Message: fmt.Sprintf("Failed to parse impression \"%s\" mediatype", bid.ImpID), 20 } 21 } 22 23 func getMediaTypeForBid(bid openrtb2.Bid) (openrtb_ext.BidType, error) { 24 var bidExt bidExt 25 // ruleid: parse-bid-type-check 26 bidType, err := openrtb_ext.ParseBidType(bidExt.Prebid.Type) 27 28 return bidType, err 29 }