Skip to content

Commit

Permalink
Merge branch 'master' into smarthub_adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartHubSolutions committed Apr 17, 2024
2 parents cc8d3d4 + a35a668 commit 6b84943
Show file tree
Hide file tree
Showing 266 changed files with 18,123 additions and 2,346 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/helpers/pull-request-utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const synchronizeEvent = "synchronize",
openedEvent = "opened",
completedStatus = "completed",
resultSize = 100
resultSize = 100,
adminPermission = "admin",
writePermission = "write"

class diffHelper {
constructor(input) {
Expand Down Expand Up @@ -407,8 +409,31 @@ class coverageHelper {
}
}

class userHelper {
constructor(input) {
this.owner = input.context.repo.owner
this.repo = input.context.repo.repo
this.github = input.github
this.user = input.user
}

/*
Checks if the user has write permissions for the repository
@returns {boolean} - returns true if the user has write permissions, otherwise false
*/
async hasWritePermissions() {
const { data } = await this.github.rest.repos.getCollaboratorPermissionLevel({
owner: this.owner,
repo: this.repo,
username: this.user,
})
return data.permission === writePermission || data.permission === adminPermission
}
}

module.exports = {
diffHelper: (input) => new diffHelper(input),
semgrepHelper: (input) => new semgrepHelper(input),
coverageHelper: (input) => new coverageHelper(input),
userHelper: (input) => new userHelper(input),
}
2 changes: 1 addition & 1 deletion .github/workflows/issue_prioritization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@36464acb844fc53b9b8b2401da68844f6b05ebb0
uses: tibdex/github-app-token@v2.1.0
with:
app_id: ${{ secrets.PBS_PROJECT_APP_ID }}
private_key: ${{ secrets.PBS_PROJECT_APP_PEM }}
Expand Down
25 changes: 18 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,25 @@ jobs:
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.repository }}
ref: master
- name: Check user permission
uses: actions-cool/[email protected]
uses: actions/github-script@v7
id: check
with:
require: 'write'
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const utils = require('./.github/workflows/helpers/pull-request-utils.js')
const helper = utils.userHelper({github, context, user: '${{ github.actor }}'})
const hasPermission = await helper.hasWritePermissions()
return hasPermission
outputs:
hasWritePermission: ${{ steps.check.outputs.require-result }}
hasWritePermission: ${{ steps.check.outputs.result }}

build-master:
name: Build master
Expand All @@ -40,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.repository }}
Expand All @@ -52,13 +64,12 @@ jobs:
publish-tag:
name: Publish tag
needs: build-master
if: contains(needs.check-permission.outputs.hasWritePermission, 'true')
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout Prebid Server
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create & publish tag
Expand Down Expand Up @@ -111,7 +122,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Prebid Server
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build image
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Resolves to empty string for push events and falls back to HEAD.
ref: ${{ github.event.pull_request.head.sha }}
Expand All @@ -29,6 +29,6 @@ jobs:
severity: 'CRITICAL,HIGH'

- name: Upload Results To GitHub Security Tab
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
6 changes: 3 additions & 3 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
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
id: calculate_diff
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
result-encoding: string
script: |
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Add pull request comment
id: add_pull_request_comment
if: contains(steps.should_run_semgrep.outputs.hasChanges, 'true')
uses: actions/github-script@v6.4.1
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:

steps:
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.20.5

- name: Checkout Merged Branch
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Validate
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:

steps:
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Resolves to empty string for push events and falls back to HEAD.
ref: ${{ github.event.pull_request.head.sha }}
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ image:
# format runs format
format:
./scripts/format.sh -f true

# formatcheck runs format for diagnostics, without modifying the code
formatcheck:
./scripts/format.sh -f false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Bid Adapters transform OpenRTB requests and responses for communicating with a b
Analytics Modules enable business intelligence tools to collect data from Prebid Server to provide publishers and hosts with valuable insights into their header bidding traffic. We welcome you to contribute a module for your platform. Refer to our guide on [building an analytics module](https://docs.prebid.org/prebid-server/developers/pbs-build-an-analytics-adapter.html) for further information.

### Auction Module
Auction Modules allow hosts to extend the behavior of Prebid Server at specfic spots in the auction pipeline using existing modules or by developing custom functionality. Auction Modules may provide creative validation, traffic optimization, and real time data services amoung many other potential uses. We welcome vendors and community members to contribute modules that publishers and hosts may find useful. Consult our guide on [building an auction module](https://docs.prebid.org/prebid-server/developers/add-a-module.html) for more information.
Auction Modules allow hosts to extend the behavior of Prebid Server at specfic spots in the auction pipeline using existing modules or by developing custom functionality. Auction Modules may provide creative validation, traffic optimization, and real time data services among many other potential uses. We welcome vendors and community members to contribute modules that publishers and hosts may find useful. Consult our guide on [building an auction module](https://docs.prebid.org/prebid-server/developers/add-a-module.html) for more information.

### Feature
We welcome everyone to contribute to this project by implementing a specification or by proposing a new feature. Please review the [prioritized project board](https://github.com/orgs/prebid/projects/4), where you can select an issue labeled "Ready For Dev". To avoid redundant effort, kindly leave a comment on the issue stating your intention to take it on. To propose a feature, [open a new issue](https://github.com/prebid/prebid-server/issues/new/choose) with as much detail as possible for consideration by the Prebid Server Committee.
Expand Down
2 changes: 1 addition & 1 deletion account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func setDerivedConfig(account *config.Account) {
if pc.VendorExceptions == nil {
continue
}
pc.VendorExceptionMap = make(map[openrtb_ext.BidderName]struct{})
pc.VendorExceptionMap = make(map[string]struct{})
for _, v := range pc.VendorExceptions {
pc.VendorExceptionMap[v] = struct{}{}
}
Expand Down
8 changes: 4 additions & 4 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestGetAccount(t *testing.T) {
func TestSetDerivedConfig(t *testing.T) {
tests := []struct {
description string
purpose1VendorExceptions []openrtb_ext.BidderName
purpose1VendorExceptions []string
feature1VendorExceptions []openrtb_ext.BidderName
basicEnforcementVendors []string
enforceAlgo string
Expand All @@ -134,11 +134,11 @@ func TestSetDerivedConfig(t *testing.T) {
},
{
description: "One purpose 1 vendor exception",
purpose1VendorExceptions: []openrtb_ext.BidderName{"appnexus"},
purpose1VendorExceptions: []string{"appnexus"},
},
{
description: "Multiple purpose 1 vendor exceptions",
purpose1VendorExceptions: []openrtb_ext.BidderName{"appnexus", "rubicon"},
purpose1VendorExceptions: []string{"appnexus", "rubicon"},
},
{
description: "Nil feature 1 vendor exceptions",
Expand Down Expand Up @@ -192,7 +192,7 @@ func TestSetDerivedConfig(t *testing.T) {

setDerivedConfig(&account)

purpose1ExceptionMapKeys := make([]openrtb_ext.BidderName, 0)
purpose1ExceptionMapKeys := make([]string, 0)
for k := range account.GDPR.Purpose1.VendorExceptionMap {
purpose1ExceptionMapKeys = append(purpose1ExceptionMapKeys, k)
}
Expand Down
45 changes: 39 additions & 6 deletions adapters/adnuntius/adnuntius.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type adnAdunit struct {
type extDeviceAdnuntius struct {
NoCookies bool `json:"noCookies,omitempty"`
}
type siteExt struct {
Data interface{} `json:"data"`
}

type Ad struct {
Bid struct {
Expand Down Expand Up @@ -71,9 +74,10 @@ type adnMetaData struct {
Usi string `json:"usi,omitempty"`
}
type adnRequest struct {
AdUnits []adnAdunit `json:"adUnits"`
MetaData adnMetaData `json:"metaData,omitempty"`
Context string `json:"context,omitempty"`
AdUnits []adnAdunit `json:"adUnits"`
MetaData adnMetaData `json:"metaData,omitempty"`
Context string `json:"context,omitempty"`
KeyValues interface{} `json:"kv,omitempty"`
}

type RequestExt struct {
Expand Down Expand Up @@ -138,7 +142,6 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter, noCookies bool
if deviceExt.NoCookies {
noCookies = true
}

}

_, offset := a.time.Now().Zone()
Expand Down Expand Up @@ -249,11 +252,31 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters
site = ortbRequest.Site.Page
}

extSite, erro := getSiteExtAsKv(&ortbRequest)
if erro != nil {
return nil, []error{fmt.Errorf("failed to parse site Ext: %v", err)}
}

for _, networkAdunits := range networkAdunitMap {

adnuntiusRequest := adnRequest{
AdUnits: networkAdunits,
Context: site,
AdUnits: networkAdunits,
Context: site,
KeyValues: extSite.Data,
}

var extUser openrtb_ext.ExtUser
if ortbRequest.User != nil && ortbRequest.User.Ext != nil {
if err := json.Unmarshal(ortbRequest.User.Ext, &extUser); err != nil {
return nil, []error{fmt.Errorf("failed to parse Ext User: %v", err)}
}
}

// Will change when our adserver can accept multiple user IDS
if extUser.Eids != nil && len(extUser.Eids) > 0 {
if len(extUser.Eids[0].UIDs) > 0 {
adnuntiusRequest.MetaData.Usi = extUser.Eids[0].UIDs[0].ID
}
}

ortbUser := ortbRequest.User
Expand Down Expand Up @@ -310,6 +333,16 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapte
return bidResponse, nil
}

func getSiteExtAsKv(request *openrtb2.BidRequest) (siteExt, error) {
var extSite siteExt
if request.Site != nil && request.Site.Ext != nil {
if err := json.Unmarshal(request.Site.Ext, &extSite); err != nil {
return extSite, fmt.Errorf("failed to parse ExtSite in Adnuntius: %v", err)
}
}
return extSite, nil
}

func getGDPR(request *openrtb2.BidRequest) (string, string, error) {

gdpr := ""
Expand Down
Loading

0 comments on commit 6b84943

Please sign in to comment.