Skip to content

Commit

Permalink
Merge branch 'main' into use_json_for_data
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3Rabbit authored Oct 19, 2024
2 parents f52bf61 + 849eb7e commit d0c2e03
Show file tree
Hide file tree
Showing 26 changed files with 724 additions and 467 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-css.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
sudo apt-get --only-upgrade install google-chrome-stable
google-chrome --version
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: RUNNING TEST - LINUX
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
with:
node-version: '20.x'
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: RUNNING TEST - LINUX
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-html.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
sudo apt-get --only-upgrade install google-chrome-stable
google-chrome --version
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: RUNNING TEST - LINUX
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-http.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
sudo apt-get --only-upgrade install google-chrome-stable
google-chrome --version
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: RUNNING TEST - LINUX
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-pa11y.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
with:
node-version: '20.x'
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
# Havn't yet been able to start Google Chrome in headless mode in pa11y since move to Chrome in Pa11y 5
- if: ${{ matrix.os == 'ubuntu-20.04' }}
name: RUNNING TEST - LINUX
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-sitespeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
sudo apt-get --only-upgrade install google-chrome-stable
google-chrome --version
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: RUNNING TEST - LINUX
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-software.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
sudo apt-get --only-upgrade install google-chrome-stable
google-chrome --version
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: RUNNING TEST - LINUX
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-tracking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
name: Setup GeckoDriver (Used for Selenium)
run: wget -q -O - https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz | tar -xvzf -
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: RUNNING TEST - LINUX
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-ylt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: sudo apt-get install libjpeg-dev libfontconfig
shell: bash
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: RUNNING TEST - LINUX
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-software.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
sudo apt-get --only-upgrade install google-chrome-stable
google-chrome --version
- name: Setup npm packages
run: npm install --production
run: npm install --omit=dev
- name: Update USER_AGENT in our defaults/settings.json
run: python update_software.py -b
- name: Checkout advisory-database repo
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM sitespeedio/sitespeed.io:35.0.0
FROM sitespeedio/sitespeed.io:35.2.0

USER root

Expand Down Expand Up @@ -62,7 +62,7 @@ RUN chown --recursive sitespeedio:sitespeedio /usr/src/runner
# Run everything after as non-privileged user.
USER sitespeedio

RUN npm install --production
RUN npm install --omit=dev

RUN python3.12 -m pip install -r requirements.txt --break-system-packages && \
python3.12 -m pip install --upgrade pip --break-system-packages && \
Expand Down
2 changes: 1 addition & 1 deletion defaults/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"details": false,
"improve-only": true
},
"useragent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0",
"useragent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0",
"cache": {
"use": false,
"max-age": 60
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started-local.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ it is also best/fastest when wanting to contribute with new tests, translations
- Download and install Node.js (version 20.x)
- Download and install Google Chrome browser
* Download and install Mozilla Firefox
- Install required npm packages by typing following and hit Enter: `npm install --production`
- Install required npm packages by typing following and hit Enter: `npm install --omit=dev`
- Validate that core functionality is working by typing following and hit Enter `python default.py -h`
- If the output looks something like example in [options and arguments](getting-started.md#options-and-arguments) you have successfully setup the general parts of webperf-core.
- Please look at/return to the [specific test](tests/README.md) you want to run to make sure it doesn't require more steps.
Expand Down
2 changes: 1 addition & 1 deletion docs/tests/css.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Read more on the [general page for github actions](../getting-started-github-act

* Download and install Node.js (version 20.x)
* Download and install Google Chrome browser
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )
* Set `sitespeed_use_docker = False` in your `config.py`

##### Windows Specific
Expand Down
2 changes: 1 addition & 1 deletion docs/tests/google-lighthouse-based.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Follow the instructions below depending on what you choose.
Benefit of this option is that you can use it to test pre production urls like your AcceptanceTest environment.

* Download and install Node.js (version 20.x)
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )

## Read more

Expand Down
2 changes: 1 addition & 1 deletion docs/tests/html.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Read more on the [general page for github actions](../getting-started-github-act

* Download and install Node.js (version 20.x)
* Download and install Google Chrome browser
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )
* Set `sitespeed_use_docker = False` in your `config.py`

##### Windows Specific
Expand Down
2 changes: 1 addition & 1 deletion docs/tests/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Read more on the [general page for github actions](../getting-started-github-act
* Download and install Node.js (version 20.x)
* Download and install Google Chrome browser
* Download and install Mozilla Firefox browser
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )
* Set `sitespeed_use_docker = False` in your `config.py`

##### Windows Specific
Expand Down
2 changes: 1 addition & 1 deletion docs/tests/pa11y.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Read more on the [general page for github actions](../getting-started-github-act
* Follow [general local setup steps for this repository](../getting-started-local.md)
* Download and install Node.js (version 20.x)
* Download and install Google Chrome browser
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )

## FAQ

Expand Down
4 changes: 2 additions & 2 deletions docs/tests/sitespeed.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Read more on the [general page for github actions](../getting-started-github-act
* Install ffmpeg `sudo apt install ffmpeg`
* Download and install Node.js (version 20.x)
* Download and install Google Chrome browser
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )
* Set `sitespeed_use_docker = False` in your `config.py`

(You can always see [GitHub Actions SiteSpeed](../../.github/workflows/regression-test-sitespeed.yml) for all steps required line by line)
Expand All @@ -86,7 +86,7 @@ Read more on the [general page for github actions](../getting-started-github-act
* Download and Install ffmpeg `https://ffmpeg.org/download.html#build-windows`
* Download and install Node.js (version 20.x)
* Download and install Google Chrome browser
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )
* Set `sitespeed_use_docker = False` in your `config.py`

#### Using Docker image
Expand Down
2 changes: 1 addition & 1 deletion docs/tests/software.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ TODO: Add links to blogs and articles showing how to remove info regarding what

* Download and install Node.js (version 20.x)
* Download and install Google Chrome browser
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )
* Set `sitespeed_use_docker = False` in your `config.py`

##### Windows Specific
Expand Down
2 changes: 1 addition & 1 deletion docs/tests/tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ This section has not been written yet.
* Download and install Node.js (version 20.x)
* Download and install Google Chrome browser
* Download and install Mozilla Firefox
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )
* Set `sitespeed_use_docker = False` in your `config.py`

##### Windows Specific
Expand Down
4 changes: 2 additions & 2 deletions docs/tests/yellowlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ Read more on the [general page for github actions](../getting-started-github-act
* Download and install Node.js (version 20.x)
* Download and install node-gyp `npm install -g node-gyp`
* Setup libjpeg and fontconfig `sudo apt-get install libjpeg-dev libfontconfig`
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )

##### On Windows:
* Download and install Node.js (version 20.x)
* Install NPM packages ( `npm install --production` )
* Install NPM packages ( `npm install --omit=dev` )

## FAQ

Expand Down
1 change: 1 addition & 0 deletions helpers/csp_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@ def append_csp_data(req_url, req_domain, res, org_domain, result):
bool: True if there is a match in the CSP findings, False otherwise.
"""
csp_findings_match = False
# TODO: Remove text empty check when sitespeed has fixed https://github.com/sitespeedio/sitespeed.io/issues/4295
if 'content' in res and 'text' in res['content'] and res['content']['text'] != '':
if 'mimeType' in res['content'] and 'text/html' in res['content']['mimeType']:
csp_findings_match = csp_findings_match or append_csp_data_for_html(
Expand Down
51 changes: 38 additions & 13 deletions helpers/sri_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def rate_sri(result_dict, global_translation, local_translation,
'TEXT_REVIEW_SRI_WITH_ERRORS_DETAILS'
).format(domain))

rating.standards_review = rating.standards_review +\
sub_rating.standards_review = sub_rating.standards_review +\
errors_str_list
else:
sub_rating.set_standards(3.0,
Expand All @@ -77,8 +77,8 @@ def rate_sri(result_dict, global_translation, local_translation,
elif 'HTML-FOUND' in result_dict[domain]['features'] and\
(domain in (org_domain, org_www_domain)):

rating = Rating(global_translation, get_config('general.review.improve-only'))
rating.set_overall(1.0)
sub_rating = Rating(global_translation, get_config('general.review.improve-only'))
sub_rating.set_overall(1.0)

if get_config('general.review.details') and \
has_domain_entry(domain, 'sri-findings', 'sri-candidates', result_dict):
Expand All @@ -87,15 +87,22 @@ def rate_sri(result_dict, global_translation, local_translation,
for candidate in candidates:
candidates_str_list += f" - `{candidate}`\r\n"

rating.set_integrity_and_security(1.0,
sub_rating.set_standards(1.0,
local_translation(
'TEXT_REVIEW_SRI_NONE_COMPLIANT'
).format(domain))
sub_rating.set_integrity_and_security(1.0,
local_translation(
'TEXT_REVIEW_SRI_NONE_COMPLIANT_DETAILS'
).format(domain))
rating.integrity_and_security_review = rating.integrity_and_security_review +\
sub_rating.integrity_and_security_review = sub_rating.integrity_and_security_review +\
candidates_str_list
else:
rating.set_integrity_and_security(1.0,
sub_rating.set_standards(1.0,
local_translation('TEXT_REVIEW_SRI_NONE_COMPLIANT').format(domain))
sub_rating.set_integrity_and_security(1.0,
local_translation('TEXT_REVIEW_SRI_NONE_COMPLIANT').format(domain))
rating += sub_rating

return rating

Expand All @@ -111,7 +118,9 @@ def append_sri_data(req_domain, res, result):
res (dict): The response dictionary containing the content.
result (dict): The result dictionary where the CSP data will be appended.
"""
if 'content' in res and 'text' in res['content']:

# TODO: Remove text empty check when sitespeed has fixed https://github.com/sitespeedio/sitespeed.io/issues/4295
if 'content' in res and 'text' in res['content'] and res['content']['text'] != '':
if 'mimeType' in res['content'] and 'text/html' in res['content']['mimeType']:
append_sri_data_for_html(
req_domain,
Expand Down Expand Up @@ -154,7 +163,13 @@ def append_sri_data_for_html(req_domain, res, result):
if found_candidate is not None:
candidates.remove(found_candidate)

is_sri_compliant = not has_domain_entry(req_domain,
'features',
'SRI-NONE-COMPLIANT',
result)

if len(sri_errors) > 0:
is_sri_compliant = False
append_domain_entry(
req_domain,
'features',
Expand All @@ -167,14 +182,10 @@ def append_sri_data_for_html(req_domain, res, result):
'sri-errors',
sri_error,
result)

elif len(candidates) == 0:
append_domain_entry(
req_domain,
'features',
'SRI-COMPLIANT',
result)
is_sri_compliant = is_sri_compliant and True
else:
is_sri_compliant = False
for candidate in candidates:
append_domain_entry_with_key(
req_domain,
Expand All @@ -183,6 +194,20 @@ def append_sri_data_for_html(req_domain, res, result):
candidate['raw'],
result)

if is_sri_compliant:
append_domain_entry(
req_domain,
'features',
'SRI-COMPLIANT',
result)
else:
append_domain_entry(
req_domain,
'features',
'SRI-NONE-COMPLIANT',
result)


def get_sris(req_domain, content):
"""
Extracts Subresource Integrity (SRI) information from HTML content.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webperf_core",
"version": "2024.10.2",
"version": "2024.10.3",
"description": "You probably want to read the documentation available at homepage.",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -12,7 +12,7 @@
"dependencies": {
"lighthouse": "12.2.1",
"pa11y": "8.0.0",
"sitespeed.io": "35.0.0",
"sitespeed.io": "35.2.0",
"vnu-jar": "23.4.11",
"yellowlabtools": "3.0.1"
},
Expand Down
Loading

0 comments on commit d0c2e03

Please sign in to comment.