Skip to content

Commit 71ef4f8

Browse files
Merge pull request #3 from pm-priyanka-deshmane/master
Master
2 parents 7d8f5a1 + 0471cf6 commit 71ef4f8

File tree

518 files changed

+44831
-30610
lines changed

Some content is hidden

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

518 files changed

+44831
-30610
lines changed

.eslintrc.js

+31-5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module.exports = {
6161
'no-useless-escape': 'off',
6262
'no-console': 'error',
6363
'jsdoc/check-types': 'off',
64+
'jsdoc/no-defaults': 'off',
6465
'jsdoc/newline-after-description': 'off',
6566
'jsdoc/require-jsdoc': 'off',
6667
'jsdoc/require-param': 'off',
@@ -83,27 +84,52 @@ module.exports = {
8384
files: key + '/**/*.js',
8485
rules: {
8586
'prebid/validate-imports': ['error', allowedModules[key]],
86-
'prebid/no-innerText': ['error', allowedModules[key]],
8787
'no-restricted-globals': [
8888
'error',
8989
{
9090
name: 'require',
9191
message: 'use import instead'
9292
}
93+
],
94+
'prebid/no-global': [
95+
'error',
96+
...['localStorage', 'sessionStorage'].map(name => ({name, message: 'use storageManager instead'})),
97+
{
98+
name: 'XMLHttpRequest',
99+
message: 'use ajax.js instead'
100+
},
101+
],
102+
'prebid/no-member': [
103+
'error',
104+
{
105+
name: 'cookie',
106+
target: 'document',
107+
message: 'use storageManager instead'
108+
},
109+
{
110+
name: 'sendBeacon',
111+
target: 'navigator',
112+
message: 'use ajax.js instead'
113+
},
114+
...['outerText', 'innerText'].map(name => ({
115+
name,
116+
message: 'use .textContent instead'
117+
}))
93118
]
94119
}
95120
})).concat([{
96121
// code in other packages (such as plugins/eslint) is not "seen" by babel and its parser will complain.
97122
files: 'plugins/*/**/*.js',
98123
parser: 'esprima'
99-
},
100-
{
124+
}, {
101125
files: '**BidAdapter.js',
102126
rules: {
103127
'no-restricted-imports': [
104128
'error', {
105-
patterns: ["**/src/events.js",
106-
"**/src/adloader.js"]
129+
patterns: [
130+
'**/src/events.js',
131+
'**/src/adloader.js'
132+
]
107133
}
108134
]
109135
}

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ For any user facing change, submit a link to a PR on the docs repo at https://gi
4141
}
4242
```
4343
44-
Be sure to test the integration with your adserver using the [Hello World](/integrationExamples/gpt/hello_world.html) sample page. -->
44+
Be sure to test the integration with your adserver using the [Hello World](https://github.com/prebid/Prebid.js/blob/master/integrationExamples/gpt/hello_world.html) sample page. -->
4545

4646

4747
## Other information

.github/codeql/codeql-config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ paths:
22
- src
33
- modules
44
- libraries
5+
queries:
6+
- name: Prebid queries
7+
uses: ./.github/codeql/queries
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @id prebid/device-memory
3+
* @name Access to navigator.deviceMemory
4+
* @kind problem
5+
* @problem.severity warning
6+
* @description Finds uses of deviceMemory
7+
*/
8+
9+
import prebid
10+
11+
from SourceNode nav
12+
where
13+
nav = windowPropertyRead("navigator")
14+
select nav.getAPropertyRead("deviceMemory"), "deviceMemory is an indicator of fingerprinting"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @id prebid/hardware-concurrency
3+
* @name Access to navigator.hardwareConcurrency
4+
* @kind problem
5+
* @problem.severity warning
6+
* @description Finds uses of hardwareConcurrency
7+
*/
8+
9+
import prebid
10+
11+
from SourceNode nav
12+
where
13+
nav = windowPropertyRead("navigator")
14+
select nav.getAPropertyRead("hardwareConcurrency"), "hardwareConcurrency is an indicator of fingerprinting"

.github/codeql/queries/prebid.qll

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import javascript
2+
import DataFlow
3+
4+
SourceNode otherWindow() {
5+
result = globalVarRef("top") or
6+
result = globalVarRef("self") or
7+
result = globalVarRef("parent") or
8+
result = globalVarRef("frames").getAPropertyRead() or
9+
result = DOM::documentRef().getAPropertyRead("defaultView")
10+
}
11+
12+
SourceNode connectedWindow(SourceNode win) {
13+
result = win.getAPropertyRead("self") or
14+
result = win.getAPropertyRead("top") or
15+
result = win.getAPropertyRead("parent") or
16+
result = win.getAPropertyRead("frames").getAPropertyRead() or
17+
result = win.getAPropertyRead("document").getAPropertyRead("defaultView")
18+
}
19+
20+
SourceNode relatedWindow(SourceNode win) {
21+
result = connectedWindow(win) or
22+
result = relatedWindow+(connectedWindow(win))
23+
}
24+
25+
SourceNode anyWindow() {
26+
result = otherWindow() or
27+
result = relatedWindow(otherWindow())
28+
}
29+
30+
/*
31+
Matches uses of property `prop` done on any window object.
32+
*/
33+
SourceNode windowPropertyRead(string prop) {
34+
result = globalVarRef(prop) or
35+
result = anyWindow().getAPropertyRead(prop)
36+
}

.github/codeql/queries/qlpack.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
library: false
3+
warnOnImplicitThis: false
4+
name: queries
5+
version: 0.0.1
6+
dependencies:
7+
codeql/javascript-all: ^1.1.1
8+
codeql/javascript-queries: ^1.1.0

.github/release-drafter.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
name-template: 'Prebid $RESOLVED_VERSION Release'
33
tag-template: '$RESOLVED_VERSION'
4+
autolabeler:
5+
- label: 'maintenance'
6+
title:
7+
- '/^(?!.*(bug|initial|release|fix)).*$/i'
48
categories:
59
- title: '🚀 New Features'
610
label: 'feature'

.github/workflows/jscpd.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
run: |
3030
echo '{
3131
"threshold": 20,
32-
"minTokens": 50,
32+
"minTokens": 100,
3333
"reporters": [
3434
"json"
3535
],
@@ -101,15 +101,15 @@ jobs:
101101
const filteredReport = JSON.parse(fs.readFileSync('filtered-jscpd-report.json', 'utf8'));
102102
let comment = "Whoa there, partner! 🌵🤠 We wrangled some duplicated code in your PR:\n\n";
103103
function link(dup) {
104-
return `https://github.com/${{ github.event.repository.full_name }}/blob/${{ github.event.pull_request.head.sha }}/${dup.name}#L${dup.start}-L${dup.end - 1}`
104+
return `https://github.com/${{ github.event.repository.full_name }}/blob/${{ github.event.pull_request.head.sha }}/${dup.name}#L${dup.start + 1}-L${dup.end - 1}`
105105
}
106106
filteredReport.forEach(duplication => {
107107
const firstFile = duplication.firstFile;
108108
const secondFile = duplication.secondFile;
109109
const lines = duplication.lines;
110110
comment += `- [\`${firstFile.name}\`](${link(firstFile)}) has ${lines} duplicated lines with [\`${secondFile.name}\`](${link(secondFile)})\n`;
111111
});
112-
comment += "\nReducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. Keep up the great work! 🚀";
112+
comment += "\nReducing code duplication by importing common functions from a library not only makes our code cleaner but also easier to maintain. Please move the common code from both files into a library and import it in each. We hate that we have to mention this, however, commits designed to hide from this utility by renaming variables or reordering an object are poor conduct. We will not look upon them kindly! Keep up the great work! 🚀";
113113
github.rest.issues.createComment({
114114
owner: context.repo.owner,
115115
repo: context.repo.repo,

.github/workflows/linter.yml

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Check for linter warnings / exceptions
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- master
7+
8+
jobs:
9+
check-linter:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Set up Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: '20'
17+
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
ref: ${{ github.event.pull_request.base.sha }}
23+
24+
- name: Fetch base and target branches
25+
run: |
26+
git fetch origin +refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}
27+
git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge:refs/remotes/pull/${{ github.event.pull_request.number }}/merge
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Get the diff
33+
run: git diff --name-only origin/${{ github.event.pull_request.base.ref }}...refs/remotes/pull/${{ github.event.pull_request.number }}/merge | grep '^\(modules\|src\|libraries\|creative\)/.*\.js$' > __changed_files.txt || true
34+
35+
- name: Run linter on base branch
36+
run: npx eslint --no-inline-config --format json $(cat __changed_files.txt | xargs stat --printf '%n\n' 2> /dev/null) > __base.json || true
37+
38+
- name: Check out PR
39+
run: git checkout ${{ github.event.pull_request.head.sha }}
40+
41+
- name: Install dependencies
42+
run: npm ci
43+
44+
- name: Run linter on PR
45+
run: npx eslint --no-inline-config --format json $(cat __changed_files.txt | xargs stat --printf '%n\n' 2> /dev/null) > __pr.json || true
46+
47+
- name: Compare them and post comment if necessary
48+
uses: actions/github-script@v7
49+
with:
50+
script: |
51+
const fs = require('fs');
52+
const path = require('path');
53+
const process = require('process');
54+
55+
function parse(fn) {
56+
return JSON.parse(fs.readFileSync(fn)).reduce((memo, data) => {
57+
const file = path.relative(process.cwd(), data.filePath);
58+
if (!memo.hasOwnProperty(file)) { memo[file] = { errors: 0, warnings: 0} }
59+
data.messages.forEach(({severity}) => {
60+
memo[file][severity > 1 ? 'errors' : 'warnings']++;
61+
});
62+
return memo;
63+
}, {})
64+
}
65+
66+
function mkDiff(old, new_) {
67+
const files = Object.fromEntries(
68+
Object.entries(new_)
69+
.map(([file, {errors, warnings}]) => {
70+
const {errors: oldErrors, warnings: oldWarnings} = old[file] || {};
71+
return [file, {errors: Math.max(0, errors - (oldErrors ?? 0)), warnings: Math.max(0, warnings - (oldWarnings ?? 0))}]
72+
})
73+
.filter(([_, {errors, warnings}]) => errors > 0 || warnings > 0)
74+
)
75+
return Object.values(files).reduce((memo, {warnings, errors}) => {
76+
memo.errors += errors;
77+
memo.warnings += warnings;
78+
return memo;
79+
}, {errors: 0, warnings: 0, files})
80+
}
81+
82+
function mkComment({errors, warnings, files}) {
83+
function pl(noun, number) {
84+
return noun + (number === 1 ? '' : 's')
85+
}
86+
if (errors === 0 && warnings === 0) return;
87+
const summary = [];
88+
if (errors) summary.push(`**${errors}** linter ${pl('error', errors)}`)
89+
if (warnings) summary.push(`**${warnings}** linter ${pl('warning', warnings)}`)
90+
let cm = `Tread carefully! This PR adds ${summary.join(' and ')} (possibly disabled through directives):\n\n`;
91+
Object.entries(files).forEach(([file, {errors, warnings}]) => {
92+
const summary = [];
93+
if (errors) summary.push(`+${errors} ${pl('error', errors)}`);
94+
if (warnings) summary.push(`+${warnings} ${pl('warning', warnings)}`)
95+
cm += ` * \`${file}\` (${summary.join(', ')})\n`
96+
})
97+
return cm;
98+
}
99+
100+
const [base, pr] = ['__base.json', '__pr.json'].map(parse);
101+
const comment = mkComment(mkDiff(base, pr));
102+
103+
if (comment) {
104+
github.rest.issues.createComment({
105+
owner: context.repo.owner,
106+
repo: context.repo.repo,
107+
issue_number: context.issue.number,
108+
body: comment
109+
});
110+
}

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[![Build Status](https://circleci.com/gh/prebid/Prebid.js.svg?style=svg)](https://circleci.com/gh/prebid/Prebid.js)
2-
[![Percentage of issues still open](http://isitmaintained.com/badge/open/prebid/Prebid.js.svg)](http://isitmaintained.com/project/prebid/Prebid.js "Percentage of issues still open")
2+
[![Percentage of issues still open](http://isitmaintained.com/badge/open/prebid/Prebid.js.svg)](https://isitmaintained.com/project/prebid/Prebid.js "Percentage of issues still open")
33
[![Coverage Status](https://coveralls.io/repos/github/prebid/Prebid.js/badge.svg)](https://coveralls.io/github/prebid/Prebid.js)
44

55
# Prebid.js
66

77
> A free and open source library for publishers to quickly implement header bidding.
88
99
This README is for developers who want to contribute to Prebid.js.
10-
Additional documentation can be found at [the Prebid homepage](http://prebid.org).
11-
Working examples can be found in [the developer docs](http://prebid.org/dev-docs/getting-started.html).
10+
Additional documentation can be found at [the Prebid.js documentation homepage](https://docs.prebid.org/prebid/prebidjs.html).
11+
Working examples can be found in [the developer docs](https://prebid.org/dev-docs/getting-started.html).
1212

1313
Prebid.js is open source software that is offered for free as a convenience. While it is designed to help companies address legal requirements associated with header bidding, we cannot and do not warrant that your use of Prebid.js will satisfy legal requirements. You are solely responsible for ensuring that your use of Prebid.js complies with all applicable laws. We strongly encourage you to obtain legal advice when using Prebid.js to ensure your implementation complies with all laws where you operate.
1414

@@ -374,7 +374,7 @@ The results will be in
374374

375375
*Note*: Starting in June 2016, all pull requests to Prebid.js need to include tests with greater than 80% code coverage before they can be merged. For more information, see [#421](https://github.com/prebid/Prebid.js/issues/421).
376376

377-
For instructions on writing tests for Prebid.js, see [Testing Prebid.js](http://prebid.org/dev-docs/testing-prebid.html).
377+
For instructions on writing tests for Prebid.js, see [Testing Prebid.js](https://prebid.org/dev-docs/testing-prebid.html).
378378

379379
### Supported Browsers
380380

creative/crossDomain.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ function isPrebidWindow(win) {
3232

3333
export function renderer(win) {
3434
let target = win.parent;
35-
while (target !== win.top && !isPrebidWindow(target)) {
36-
target = target.parent;
35+
try {
36+
while (target !== win.top && !isPrebidWindow(target)) {
37+
target = target.parent;
38+
}
39+
if (!isPrebidWindow(target)) target = win.parent;
40+
} catch (e) {
3741
}
38-
if (!isPrebidWindow(target)) target = win.parent;
3942

4043
return function ({adId, pubUrl, clickUrl}) {
4144
const pubDomain = new URL(pubUrl, window.location).origin;

0 commit comments

Comments
 (0)