Skip to content

Commit

Permalink
Merge branch 'prebid:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SylviaF authored Jun 24, 2024
2 parents d776f1b + 4dc4005 commit b74708d
Show file tree
Hide file tree
Showing 168 changed files with 5,277 additions and 650 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/adapter-code-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
name: Adapter code coverage
name: Adapter Code Coverage

on:
pull_request_target:
paths: ["adapters/*/*.go"]

permissions:
pull-requests: write
contents: write

jobs:
run-coverage:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.20.5
go-version: 1.22.3

- name: Checkout pull request branch
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}

- name: Get adapter directories
- name: Discover Adapter Directories
id: get_directories
uses: actions/github-script@v7
with:
Expand All @@ -40,7 +43,7 @@ jobs:
// run coverage for maximum of 2 directories
return (directories.length == 0 || directories.length > 2) ? "" : JSON.stringify(directories)
- name: Run coverage tests
- name: Run Coverage Tests
id: run_coverage
if: steps.get_directories.outputs.result != ''
run: |
Expand All @@ -67,14 +70,14 @@ jobs:
cd ..
rm -f -r ./*
- name: Checkout coverage-preview branch
- name: Checkout Coverage Preview Branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: coverage-preview
repository: prebid/prebid-server

- name: Commit coverage files to coverage-preview branch
- name: Upload Coverage Results
if: steps.run_coverage.outputs.coverage_dir != ''
id: commit_coverage
run: |
Expand All @@ -88,11 +91,11 @@ jobs:
git push origin coverage-preview
echo "remote_coverage_preview_dir=${directory}" >> $GITHUB_OUTPUT
- name: Checkout master branch
- name: Checkout Master Branch
if: steps.get_directories.outputs.result != ''
run: git checkout master

- name: Add coverage summary to pull request
- name: Add Coverage Summary To Pull Request
if: steps.run_coverage.outputs.coverage_dir != '' && steps.commit_coverage.outputs.remote_coverage_preview_dir != ''
uses: actions/github-script@v7
with:
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
name: Adapter semgrep checks
name: Adapter Semgrep Check

on:
pull_request_target:
paths: ["adapters/*/*.go"]

permissions:
pull-requests: write

jobs:
semgrep-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}

- name: Calculate diff
- name: Calculate Code Diff
id: calculate_diff
uses: actions/github-script@v7
with:
Expand All @@ -29,7 +32,7 @@ jobs:
const helper = utils.diffHelper({github, context, fileNameFilter, event: "${{github.event.action}}", testName: "${{github.job}}"})
return await helper.buildDiff()
- name: Should run semgrep
- name: Check For Changes
id: should_run_semgrep
run: |
hasChanges=$(echo '${{ steps.calculate_diff.outputs.result }}' | jq .pullRequest.hasChanges)
Expand All @@ -41,15 +44,15 @@ jobs:
pip3 install semgrep==1.22.0
semgrep --version
- name: Run semgrep tests
- name: Run Semgrep
id: run_semgrep_tests
if: contains(steps.should_run_semgrep.outputs.hasChanges, 'true')
run: |
unqouted_string=$(echo '${{ steps.calculate_diff.outputs.result }}' | jq .pullRequest.files | tr -d '"')
outputs=$(semgrep --gitlab-sast --config=.semgrep/adapter $unqouted_string | jq '[.vulnerabilities[] | {"file": .location.file, "severity": .severity, "start": .location.start_line, "end": .location.end_line, "message": (.message | gsub("\\n"; "\n"))}]' | jq -c | jq -R)
echo "semgrep_result=${outputs}" >> "$GITHUB_OUTPUT"
- name: Add pull request comment
- name: Add Pull Request Comment
id: add_pull_request_comment
if: contains(steps.should_run_semgrep.outputs.hasChanges, 'true')
uses: actions/github-script@v7
Expand All @@ -66,7 +69,7 @@ jobs:
const { previousScan, currentScan } = await helper.addReviewComments()
return previousScan.unAddressedComments + currentScan.newComments
- name: Adapter semgrep checks result
- name: Check Results
if: contains(steps.should_run_semgrep.outputs.hasChanges, 'true')
run: |
if [ "${{steps.add_pull_request_comment.outputs.result}}" -ne "0" ]; then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.20.5
go-version: 1.22.3

- name: Checkout Merged Branch
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
validate:
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
go-version: [1.21.x, 1.22.x]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y wget
WORKDIR /tmp
RUN wget https://dl.google.com/go/go1.20.5.linux-amd64.tar.gz && \
tar -xf go1.20.5.linux-amd64.tar.gz && \
RUN wget https://dl.google.com/go/go1.22.3.linux-amd64.tar.gz && \
tar -xf go1.22.3.linux-amd64.tar.gz && \
mv go /usr/local
RUN mkdir -p /app/prebid-server/
WORKDIR /app/prebid-server/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Ensure that you deploy the `/static` directory, as Prebid Server requires those

## Developing

Prebid Server requires [Go](https://go.dev) version 1.19 or newer. You can develop on any operating system that Go supports; however, please note that our helper scripts are written in bash.
Prebid Server requires [Go](https://go.dev) version 1.21 or newer. You can develop on any operating system that Go supports; however, please note that our helper scripts are written in bash.

1. Clone The Repository
``` bash
Expand Down
1 change: 1 addition & 0 deletions adapters/adgeneration/adgeneration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func checkBidResponse(t *testing.T, bidderResponse *adapters.BidderResponse, exp
var expectedCrID string = "Dummy_supership.jp"
var extectedDealID string = "test-deal-id"

//nolint: staticcheck // false positive SA5011: possible nil pointer dereference
assert.Equal(t, expectedCurrency, bidderResponse.Currency)
assert.Equal(t, 1, len(bidderResponse.Bids))
assert.Equal(t, expectedID, bidderResponse.Bids[0].Bid.ID)
Expand Down
6 changes: 5 additions & 1 deletion adapters/adtarget/adtarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ func validateImpressionAndSetExt(imp *openrtb2.Imp) (int, error) {
impExtBuffer, err = json.Marshal(&adtargetImpExt{
Adtarget: impExt,
})

if err != nil {
return 0, &errortypes.BadInput{
Message: fmt.Sprintf("ignoring imp id=%s, error while encoding impExt, err: %s", imp.ID, err),
}
}
if impExt.BidFloor > 0 {
imp.BidFloor = impExt.BidFloor
}
Expand Down
2 changes: 1 addition & 1 deletion adapters/advangelists/advangelists.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (adapter *AdvangelistsAdapter) buildEndpointURL(params *openrtb_ext.ExtImpA

// MakeBids translates advangelists bid response to prebid-server specific format
func (adapter *AdvangelistsAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
var msg = ""
var msg string
if response.StatusCode == http.StatusNoContent {
return nil, nil
}
Expand Down
3 changes: 3 additions & 0 deletions adapters/algorix/algorix.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func preProcess(request *openrtb2.BidRequest) {
videoCopy := *request.Imp[i].Video
videoExt := algorixVideoExt{Rewarded: 1}
videoCopy.Ext, err = json.Marshal(&videoExt)
if err != nil {
continue
}
request.Imp[i].Video = &videoCopy
}
}
Expand Down
4 changes: 2 additions & 2 deletions adapters/appnexus/appnexus.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"maps"
"net/http"
"net/url"
"strconv"
Expand All @@ -13,7 +14,6 @@ import (
"github.com/prebid/openrtb/v20/adcom1"
"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v2/config"
"github.com/prebid/prebid-server/v2/util/maputil"
"github.com/prebid/prebid-server/v2/util/ptrutil"
"github.com/prebid/prebid-server/v2/util/randomutil"

Expand Down Expand Up @@ -315,7 +315,7 @@ func splitRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, requestExt
errs = append(errs, err)
}

requestExtClone := maputil.Clone(requestExt)
requestExtClone := maps.Clone(requestExt)
requestExtClone["appnexus"] = appnexusExtJson

request.Ext, err = json.Marshal(requestExtClone)
Expand Down
8 changes: 4 additions & 4 deletions adapters/beintoo/beintoo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (a *BeintooAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada

if len(request.Imp) == 0 {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("No Imps in Bid Request"),
Message: "No Imps in Bid Request",
}}
}

Expand All @@ -36,7 +36,7 @@ func (a *BeintooAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
data, err := json.Marshal(request)
if err != nil {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("Error in packaging request to JSON"),
Message: "Error in packaging request to JSON",
}}
}

Expand Down Expand Up @@ -95,7 +95,7 @@ func buildImpBanner(imp *openrtb2.Imp) error {

if imp.Banner == nil {
return &errortypes.BadInput{
Message: fmt.Sprintf("Request needs to include a Banner object"),
Message: "Request needs to include a Banner object",
}
}

Expand All @@ -105,7 +105,7 @@ func buildImpBanner(imp *openrtb2.Imp) error {
if banner.W == nil && banner.H == nil {
if len(banner.Format) == 0 {
return &errortypes.BadInput{
Message: fmt.Sprintf("Need at least one size to build request"),
Message: "Need at least one size to build request",
}
}
format := banner.Format[0]
Expand Down
8 changes: 4 additions & 4 deletions adapters/between/between.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (a *BetweenAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
var errors []error
if len(request.Imp) == 0 {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("No valid Imps in Bid Request"),
Message: "No valid Imps in Bid Request",
}}
}
ext, errors := preprocess(request)
Expand All @@ -40,7 +40,7 @@ func (a *BetweenAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *ada
data, err := json.Marshal(request)
if err != nil {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("Error in packaging request to JSON"),
Message: "Error in packaging request to JSON",
}}
}
headers := http.Header{}
Expand Down Expand Up @@ -103,14 +103,14 @@ func (a *BetweenAdapter) buildEndpointURL(e *openrtb_ext.ExtImpBetween) (string,
func buildImpBanner(imp *openrtb2.Imp) error {
if imp.Banner == nil {
return &errortypes.BadInput{
Message: fmt.Sprintf("Request needs to include a Banner object"),
Message: "Request needs to include a Banner object",
}
}
banner := *imp.Banner
if banner.W == nil && banner.H == nil {
if len(banner.Format) == 0 {
return &errortypes.BadInput{
Message: fmt.Sprintf("Need at least one size to build request"),
Message: "Need at least one size to build request",
}
}
format := banner.Format[0]
Expand Down
2 changes: 1 addition & 1 deletion adapters/bluesea/bluesea.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func extraImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpBluesea, error) {
}
if len(blueseaImpExt.PubId) == 0 || len(blueseaImpExt.Token) == 0 {
return nil, &errortypes.BadInput{
Message: fmt.Sprintf("Error in parsing imp.ext.bidder, empty pubid or token"),
Message: "Error in parsing imp.ext.bidder, empty pubid or token",
}
}
return &blueseaImpExt, nil
Expand Down
12 changes: 6 additions & 6 deletions adapters/cadent_aperture_mx/cadentaperturemx.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E

if len(request.Imp) == 0 {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("No Imps in Bid Request"),
Message: "No Imps in Bid Request",
}}
}

Expand All @@ -51,7 +51,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E
data, err := json.Marshal(request)
if err != nil {
return nil, []error{&errortypes.BadInput{
Message: fmt.Sprintf("Error in packaging request to JSON"),
Message: "Error in packaging request to JSON",
}}
}

Expand Down Expand Up @@ -117,7 +117,7 @@ func buildImpBanner(imp *openrtb2.Imp) error {

if imp.Banner == nil {
return &errortypes.BadInput{
Message: fmt.Sprintf("Request needs to include a Banner object"),
Message: "Request needs to include a Banner object",
}
}

Expand All @@ -127,7 +127,7 @@ func buildImpBanner(imp *openrtb2.Imp) error {
if banner.W == nil && banner.H == nil {
if len(banner.Format) == 0 {
return &errortypes.BadInput{
Message: fmt.Sprintf("Need at least one size to build request"),
Message: "Need at least one size to build request",
}
}
format := banner.Format[0]
Expand All @@ -144,13 +144,13 @@ func buildImpVideo(imp *openrtb2.Imp) error {

if len(imp.Video.MIMEs) == 0 {
return &errortypes.BadInput{
Message: fmt.Sprintf("Video: missing required field mimes"),
Message: "Video: missing required field mimes",
}
}

if (imp.Video.H == nil || *imp.Video.H == 0) && (imp.Video.W == nil || *imp.Video.W == 0) {
return &errortypes.BadInput{
Message: fmt.Sprintf("Video: Need at least one size to build request"),
Message: "Video: Need at least one size to build request",
}
}

Expand Down
Loading

0 comments on commit b74708d

Please sign in to comment.