Skip to content

Commit 0841703

Browse files
author
Kanceliarenko
committed
Merge remote-tracking branch 'prebid-server/master'
2026.04.03
2 parents 664cc14 + 99009c0 commit 0841703

4,949 files changed

Lines changed: 213115 additions & 39206 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
1616

1717
# [Optional] Uncomment this line to install global node packages.
1818
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
19+
20+
RUN addgroup --system --gid 2001 prebidgroup && adduser --system --uid 1001 --ingroup prebidgroup prebid
21+
USER prebid

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"dockerfile": "Dockerfile",
77
"args": {
88
// Update the VARIANT arg to pick a version of Go
9-
"VARIANT": "1.20",
9+
"VARIANT": "1.24",
1010
// Options
1111
"INSTALL_NODE": "false",
1212
"NODE_VERSION": "lts/*"

.github/workflows/adapter-code-coverage.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1-
name: Adapter code coverage
1+
name: Adapter Code Coverage
2+
23
on:
34
pull_request_target:
45
paths: ["adapters/*/*.go"]
6+
57
permissions:
68
pull-requests: write
79
contents: write
10+
811
jobs:
912
run-coverage:
1013
runs-on: ubuntu-latest
1114
steps:
1215
- name: Install Go
1316
uses: actions/setup-go@v5
1417
with:
15-
go-version: 1.20.5
18+
go-version: 1.24.0
1619

17-
- name: Checkout pull request branch
20+
- name: Checkout Code
1821
uses: actions/checkout@v4
1922
with:
2023
fetch-depth: 0
2124
ref: ${{github.event.pull_request.head.ref}}
2225
repository: ${{github.event.pull_request.head.repo.full_name}}
2326

24-
- name: Get adapter directories
27+
- name: Discover Adapter Directories
2528
id: get_directories
2629
uses: actions/github-script@v7
2730
with:
@@ -40,7 +43,7 @@ jobs:
4043
// run coverage for maximum of 2 directories
4144
return (directories.length == 0 || directories.length > 2) ? "" : JSON.stringify(directories)
4245
43-
- name: Run coverage tests
46+
- name: Run Coverage Tests
4447
id: run_coverage
4548
if: steps.get_directories.outputs.result != ''
4649
run: |
@@ -67,14 +70,14 @@ jobs:
6770
cd ..
6871
rm -f -r ./*
6972
70-
- name: Checkout coverage-preview branch
73+
- name: Checkout Coverage Preview Branch
7174
uses: actions/checkout@v4
7275
with:
7376
fetch-depth: 0
7477
ref: coverage-preview
7578
repository: prebid/prebid-server
7679

77-
- name: Commit coverage files to coverage-preview branch
80+
- name: Upload Coverage Results
7881
if: steps.run_coverage.outputs.coverage_dir != ''
7982
id: commit_coverage
8083
run: |
@@ -88,11 +91,11 @@ jobs:
8891
git push origin coverage-preview
8992
echo "remote_coverage_preview_dir=${directory}" >> $GITHUB_OUTPUT
9093
91-
- name: Checkout master branch
94+
- name: Checkout Master Branch
9295
if: steps.get_directories.outputs.result != ''
9396
run: git checkout master
9497

95-
- name: Add coverage summary to pull request
98+
- name: Add Coverage Summary To Pull Request
9699
if: steps.run_coverage.outputs.coverage_dir != '' && steps.commit_coverage.outputs.remote_coverage_preview_dir != ''
97100
uses: actions/github-script@v7
98101
with:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Notify Code Path Changes
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize]
6+
paths:
7+
- '**'
8+
9+
env:
10+
OAUTH2_CLIENT_ID: ${{ secrets.OAUTH2_CLIENT_ID }}
11+
OAUTH2_CLIENT_SECRET: ${{ secrets.OAUTH2_CLIENT_SECRET }}
12+
OAUTH2_REFRESH_TOKEN: ${{ secrets.OAUTH2_REFRESH_TOKEN }}
13+
GITHUB_REPOSITORY: ${{ github.repository }}
14+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
notify:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout Code
25+
uses: actions/checkout@v3
26+
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: '18'
31+
32+
- name: Install dependencies
33+
run: npm install axios nodemailer
34+
35+
- name: Run Notification Script
36+
run: |
37+
node .github/workflows/scripts/send-notification-on-change.js

.github/workflows/publishonly.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: PublishOnly
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
imageToPublish:
7+
type: string
8+
required: true
9+
description: 'Already built docker image to publish to docker hub'
10+
11+
publish-docker-image:
12+
name: Publish docker image
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Login to docker Hub
16+
id: login
17+
uses: docker/login-action@v2.1.0
18+
with:
19+
username: ${{ secrets.DOCKERHUB_USER }}
20+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
21+
- name: Publish to docker Hub
22+
if: steps.login.outcome == 'success'
23+
run: |
24+
docker push docker.io/prebid/prebid-server:${{ inputs.imageToPublish }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# when a changed file paths matches the regex, send an alert email
2+
# structure of the file is:
3+
#
4+
# javascriptRegex : email address
5+
#
6+
# For example, in PBS Go, there are many paths that can belong to bid adapter:
7+
#
8+
# /adapters/BIDDERCODE
9+
# /openrtb_ext/imp_BIDDERCODE.go
10+
# /static/bidder-params/BIDDERCODE.json
11+
# /static/bidder-info/BIDDERCODE.yaml
12+
#
13+
# The aim is to find a minimal set of regex patterns that matches any file in these paths
14+
15+
rubicon: header-bidding@magnite.com
16+
pubmatic: header-bidding@pubmatic.com
17+
openx: prebid@openx.com
18+
adapters/ix|imp_ix|ix.json|ix.yaml: pdu-supply-prebid@indexexchange.com
19+
medianet: prebid@media.net
20+
gumgum: prebid@gumgum.com
21+
kargo: kraken@kargo.com
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// send-notification-on-change.js
2+
//
3+
// called by the code-path-changes.yml workflow, this script queries github for
4+
// the changes in the current PR, checks the config file for whether any of those
5+
// file paths are set to alert an email address, and sends email to multiple
6+
// parties if needed
7+
8+
const fs = require('fs');
9+
const path = require('path');
10+
const axios = require('axios');
11+
const nodemailer = require('nodemailer');
12+
13+
async function getAccessToken(clientId, clientSecret, refreshToken) {
14+
try {
15+
const response = await axios.post('https://oauth2.googleapis.com/token', {
16+
client_id: clientId,
17+
client_secret: clientSecret,
18+
refresh_token: refreshToken,
19+
grant_type: 'refresh_token',
20+
});
21+
return response.data.access_token;
22+
} catch (error) {
23+
console.error('Failed to fetch access token:', error.response?.data || error.message);
24+
process.exit(1);
25+
}
26+
}
27+
28+
(async () => {
29+
const configFilePath = path.join(__dirname, 'codepath-notification');
30+
const repo = process.env.GITHUB_REPOSITORY;
31+
const prNumber = process.env.GITHUB_PR_NUMBER;
32+
const token = process.env.GITHUB_TOKEN;
33+
34+
// Generate OAuth2 access token
35+
const clientId = process.env.OAUTH2_CLIENT_ID;
36+
const clientSecret = process.env.OAUTH2_CLIENT_SECRET;
37+
const refreshToken = process.env.OAUTH2_REFRESH_TOKEN;
38+
39+
// validate params
40+
if (!repo || !prNumber || !token || !clientId || !clientSecret || !refreshToken) {
41+
console.error('Missing required environment variables.');
42+
process.exit(1);
43+
}
44+
45+
// the whole process is in a big try/catch. e.g. if the config file doesn't exist, github is down, etc.
46+
try {
47+
// Read and process the configuration file
48+
const configFileContent = fs.readFileSync(configFilePath, 'utf-8');
49+
const configRules = configFileContent
50+
.split('\n')
51+
.filter(line => line.trim() !== '' && !line.trim().startsWith('#')) // Ignore empty lines and comments
52+
.map(line => {
53+
const [regex, email] = line.split(':').map(part => part.trim());
54+
return { regex: new RegExp(regex), email };
55+
});
56+
57+
// Fetch changed files from github
58+
const [owner, repoName] = repo.split('/');
59+
const apiUrl = `https://api.github.com/repos/${owner}/${repoName}/pulls/${prNumber}/files`;
60+
const response = await axios.get(apiUrl, {
61+
headers: {
62+
Authorization: `Bearer ${token}`,
63+
Accept: 'application/vnd.github.v3+json',
64+
},
65+
});
66+
67+
const changedFiles = response.data.map(file => file.filename);
68+
console.log('Changed files:', changedFiles);
69+
70+
// match file pathnames that are in the config and group them by email address
71+
const matchesByEmail = {};
72+
changedFiles.forEach(file => {
73+
configRules.forEach(rule => {
74+
if (rule.regex.test(file)) {
75+
if (!matchesByEmail[rule.email]) {
76+
matchesByEmail[rule.email] = [];
77+
}
78+
matchesByEmail[rule.email].push(file);
79+
}
80+
});
81+
});
82+
83+
// Exit successfully if no matches were found
84+
if (Object.keys(matchesByEmail).length === 0) {
85+
console.log('No matches found. Exiting successfully.');
86+
process.exit(0);
87+
}
88+
89+
console.log('Grouped matches by email:', matchesByEmail);
90+
91+
// get ready to email the changes
92+
const accessToken = await getAccessToken(clientId, clientSecret, refreshToken);
93+
94+
// Configure Nodemailer with OAuth2
95+
// service: 'Gmail',
96+
const transporter = nodemailer.createTransport({
97+
host: "smtp.gmail.com",
98+
port: 465,
99+
secure: true,
100+
auth: {
101+
type: 'OAuth2',
102+
user: 'info@prebid.org',
103+
clientId: clientId,
104+
clientSecret: clientSecret,
105+
refreshToken: refreshToken,
106+
accessToken: accessToken
107+
},
108+
});
109+
110+
// Send one email per recipient
111+
for (const [email, files] of Object.entries(matchesByEmail)) {
112+
const emailBody = `
113+
${email},
114+
<p>
115+
Files owned by you have been changed in open source ${repo}. The <a href="https://github.com/${repo}/pull/${prNumber}">pull request is #${prNumber}</a>. These are the files you own that have been modified:
116+
<ul>
117+
${files.map(file => `<li>${file}</li>`).join('')}
118+
</ul>
119+
`;
120+
121+
try {
122+
await transporter.sendMail({
123+
from: `"Prebid Info" <info@prebid.org>`,
124+
to: email,
125+
subject: `Files have been changed in open source ${repo}`,
126+
html: emailBody,
127+
});
128+
129+
console.log(`Email sent successfully to ${email}`);
130+
console.log(`${emailBody}`);
131+
} catch (error) {
132+
console.error(`Failed to send email to ${email}:`, error.message);
133+
}
134+
}
135+
} catch (error) {
136+
console.error('Error:', error.message);
137+
process.exit(1);
138+
}
139+
})();

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
build:
1313
name: Trivy
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout Code
1717
uses: actions/checkout@v4

.github/workflows/semgrep.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
name: Adapter semgrep checks
1+
name: Adapter Semgrep Check
2+
23
on:
34
pull_request_target:
45
paths: ["adapters/*/*.go"]
6+
57
permissions:
68
pull-requests: write
9+
710
jobs:
811
semgrep-check:
912
runs-on: ubuntu-latest
1013
steps:
11-
- name: Checkout repo
14+
- name: Checkout Code
1215
uses: actions/checkout@v4
1316
with:
1417
fetch-depth: 0
1518
ref: ${{github.event.pull_request.head.ref}}
1619
repository: ${{github.event.pull_request.head.repo.full_name}}
1720

18-
- name: Calculate diff
21+
- name: Calculate Code Diff
1922
id: calculate_diff
2023
uses: actions/github-script@v7
2124
with:
@@ -29,7 +32,7 @@ jobs:
2932
const helper = utils.diffHelper({github, context, fileNameFilter, event: "${{github.event.action}}", testName: "${{github.job}}"})
3033
return await helper.buildDiff()
3134
32-
- name: Should run semgrep
35+
- name: Check For Changes
3336
id: should_run_semgrep
3437
run: |
3538
hasChanges=$(echo '${{ steps.calculate_diff.outputs.result }}' | jq .pullRequest.hasChanges)
@@ -41,15 +44,15 @@ jobs:
4144
pip3 install semgrep==1.22.0
4245
semgrep --version
4346
44-
- name: Run semgrep tests
47+
- name: Run Semgrep
4548
id: run_semgrep_tests
4649
if: contains(steps.should_run_semgrep.outputs.hasChanges, 'true')
4750
run: |
4851
unqouted_string=$(echo '${{ steps.calculate_diff.outputs.result }}' | jq .pullRequest.files | tr -d '"')
4952
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)
5053
echo "semgrep_result=${outputs}" >> "$GITHUB_OUTPUT"
5154
52-
- name: Add pull request comment
55+
- name: Add Pull Request Comment
5356
id: add_pull_request_comment
5457
if: contains(steps.should_run_semgrep.outputs.hasChanges, 'true')
5558
uses: actions/github-script@v7
@@ -66,7 +69,7 @@ jobs:
6669
const { previousScan, currentScan } = await helper.addReviewComments()
6770
return previousScan.unAddressedComments + currentScan.newComments
6871
69-
- name: Adapter semgrep checks result
72+
- name: Check Results
7073
if: contains(steps.should_run_semgrep.outputs.hasChanges, 'true')
7174
run: |
7275
if [ "${{steps.add_pull_request_comment.outputs.result}}" -ne "0" ]; then

0 commit comments

Comments
 (0)