Skip to content

Commit

Permalink
lets play
Browse files Browse the repository at this point in the history
  • Loading branch information
cockroacher committed May 11, 2024
1 parent d51a69f commit d8defb8
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
#on: [ push, pull_request ]
jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-404.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-a11y-statement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-css.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-email.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
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 @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
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 @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
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 @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
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 @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-standard-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
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 @@ -11,7 +11,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression-test-webbkoll.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
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 @@ -7,7 +7,7 @@ on:
- 'software-full.json'
- 'software-sources.json'
- '**update-software.yml'
- '**update_software.py'
- 'update_software.py'
- '**software-rules.json'
- 'Dockerfile'
- '**regression-test-docker-image.yml'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-software.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
# - 'software-sources.json'
# - '**update-software.yml'
# - '**verify_result.py'
# - '**update_software.py'
# - 'update_software.py'
# - '**software-rules.json'
jobs:
build:
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
sparse-checkout: |
advisories
- name: Verifing Software(s)
run: python tools\update_software.py
run: python update_software.py
- name: Create pull request
uses: peter-evans/create-pull-request@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion docs/tests/software.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ Fork https://github.com/github/advisory-database and set `software_github_adadvi

Make sure you add a valid GitHub API key in your `config.py`.

run `tools/update_software.py`
run `update_software.py`
71 changes: 6 additions & 65 deletions tools/update_software.py → update_software.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,10 @@
import re
import os
import packaging.version
from tests.utils import get_config_or_default, get_http_content

CONFIG_WARNINGS = {}

def get_config_or_default(name):
"""
Retrieves the configuration value for a given name from the configuration file.
If the name does not exist in the configuration file,
it attempts to retrieve it from the defaults.config.py file.
Parameters:
name (str): The name of the configuration value to retrieve.
Returns:
The configuration value associated with the given name.
Raises:
ValueError: If the name does not exist in both the configuration file and
the defaults.config.py file.
Notes:
- If the name exists in the defaults.config.py file but not in the configuration file,
a warning message is printed.
- If the name does not exist in both files,
a fatal error message is printed and a ValueError is raised.
"""
# Try get config from our configuration file
value = get_config_from_module(name, 'config')
if value is not None:
return value

name = name.upper()
value = get_config_from_module(name, 'config')
if value is not None:
return value

# do we have fallback value we can use in our defaults/config.py file?
value = get_config_from_module(name, 'defaults.config')
if value is not None:
if name not in CONFIG_WARNINGS:
CONFIG_WARNINGS[name] = True
return value

return None

def get_config_from_module(config_name, module_name):
"""
Retrieves the configuration value for a given name from the specified module file.
Parameters:
config_name (str): The name of the configuration value to retrieve.
module_name (str): The name of the module the values should be retrieved from.
Returns:
The configuration value associated with the given config_name and module_name.
"""
# do we have fallback value we can use in our defaults/config.py file?
try:
from importlib import import_module # pylint: disable=import-outside-toplevel
tmp_config = import_module(module_name) # pylint: disable=invalid-name
if hasattr(tmp_config, config_name):
return getattr(tmp_config, config_name)
except ModuleNotFoundError:
_ = 1

return None

try:
github_adadvisory_database_path = get_config_or_default(
'SOFTWARE_GITHUB_ADADVISORY_DATABASE_PATH')
Expand Down Expand Up @@ -306,9 +244,12 @@ def extend_versions_for_nginx(versions):

lversion_specificity = len(lversion.release)

if lversion_specificity == 3 and lversion_specificity == len(lsafe_version.release):
if lversion_specificity == 3 and\
lversion_specificity == len(lsafe_version.release):
# is same branch and is equal or greater then safe (fixed) version?
if lversion.release[0] == lsafe_version.release[0] and lversion.release[1] == lsafe_version.release[1] and lversion.release[2] >= lsafe_version.release[2]:
if lversion.release[0] == lsafe_version.release[0] and\
lversion.release[1] == lsafe_version.release[1] and\
lversion.release[2] >= lsafe_version.release[2]:
is_match = False

if is_match:
Expand Down

0 comments on commit d8defb8

Please sign in to comment.