Skip to content

Commit

Permalink
Update dpkg versions list
Browse files Browse the repository at this point in the history
From the artifact of the previous workflow run
  • Loading branch information
geo-ghci-int[bot] committed Nov 15, 2024
1 parent f924614 commit 2e0e969
Show file tree
Hide file tree
Showing 26 changed files with 98 additions and 168 deletions.
4 changes: 1 addition & 3 deletions github_app_geo_project/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@


def apply_profile_inheritance(profile_name: str, profiles: dict[str, Any]) -> None:
"""
Apply the inheritance of the profile.
"""
"""Apply the inheritance of the profile."""
for other_name, other_profile in APPLICATION_CONFIGURATION["profiles"].items():
if other_profile.get("inherits") == profile_name:
_LOGGER.debug("Apply inheritance %s -> %s", profile_name, other_name)
Expand Down
7 changes: 2 additions & 5 deletions github_app_geo_project/module/audit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@ async def _process_snyk_dpkg(
python_version = ".".join(line.split(" ")[1].split(".")[0:2]).strip()
break

if python_version:
env = _use_python_version(python_version)
else:
env = os.environ.copy()
env = _use_python_version(python_version) if python_version else os.environ.copy()

result, body, short_message, new_success = await audit_utils.snyk(
branch,
Expand All @@ -197,7 +194,7 @@ async def _process_snyk_dpkg(
", ".join(short_message),
)
message: module_utils.Message = module_utils.HtmlMessage(
"<a href='%s'>Output</a>" % output_url
f"<a href='{output_url}'>Output</a>"
)
message.title = "Output URL"
_LOGGER.debug(message)
Expand Down
49 changes: 23 additions & 26 deletions github_app_geo_project/module/audit/configuration.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""
Automatically generated file from a JSON schema.
"""

from typing import Any, Dict, List, Literal, TypedDict, Union
"""Automatically generated file from a JSON schema."""

from typing import Any, Literal, TypedDict, Union

# | Audit configuration.
AuditConfiguration = TypedDict(
Expand All @@ -19,7 +16,7 @@
# |
# | default:
# | {}
"version-mapping": Dict[str, str],
"version-mapping": dict[str, str],
},
total=False,
)
Expand Down Expand Up @@ -117,7 +114,7 @@ class DpkgConfiguration(TypedDict, total=False):
default: True
"""

sources: Dict[str, List["_DpkgSourcesAdditionalpropertiesItem"]]
sources: dict[str, list["_DpkgSourcesAdditionalpropertiesItem"]]
"""
Dpkg sources.
Expand Down Expand Up @@ -215,23 +212,23 @@ class DpkgConfiguration(TypedDict, total=False):
""" Default value of the field path 'Snyk configuration enabled' """


FILES_NOT_TO_INSTALL_DEFAULT: List[Any] = []
FILES_NOT_TO_INSTALL_DEFAULT: list[Any] = []
""" Default value of the field path 'Snyk configuration files-no-install' """


JAVA_PATH_BY_GRADLE_VERSION_DEFAULT: Dict[str, Any] = {}
JAVA_PATH_BY_GRADLE_VERSION_DEFAULT: dict[str, Any] = {}
""" Default value of the field path 'Snyk configuration java-path-for-gradle' """


PIPENV_SYNC_ARGUMENTS_DEFAULT: List[Any] = []
PIPENV_SYNC_ARGUMENTS_DEFAULT: list[Any] = []
""" Default value of the field path 'Snyk configuration pipenv-sync-arguments' """


PIP_INSTALL_ARGUMENTS_DEFAULT: List[Any] = []
PIP_INSTALL_ARGUMENTS_DEFAULT: list[Any] = []
""" Default value of the field path 'Snyk configuration pip-install-arguments' """


POETRY_INSTALL_ARGUMENTS_DEFAULT: List[Any] = []
POETRY_INSTALL_ARGUMENTS_DEFAULT: list[Any] = []
""" Default value of the field path 'Snyk configuration poetry-install-arguments' """


Expand Down Expand Up @@ -263,57 +260,57 @@ class DpkgConfiguration(TypedDict, total=False):
# |
# | default:
# | []
"files-no-install": List[str],
"files-no-install": list[str],
# | Pip install arguments.
# |
# | Arguments to pass to pip install
# |
# | default:
# | []
"pip-install-arguments": List[str],
"pip-install-arguments": list[str],
# | Pipenv sync arguments.
# |
# | Arguments to pass to pipenv sync
# |
# | default:
# | []
"pipenv-sync-arguments": List[str],
"pipenv-sync-arguments": list[str],
# | Poetry install arguments.
# |
# | Arguments to pass to pip install
# |
# | default:
# | []
"poetry-install-arguments": List[str],
"poetry-install-arguments": list[str],
# | Java path by Gradle version.
# |
# | Path to the directory that contains Java executable to use for the Gradle minor version
# |
# | default:
# | {}
"java-path-for-gradle": Dict[str, str],
"java-path-for-gradle": dict[str, str],
# | Snyk monitor arguments.
# |
# | Arguments to pass to Snyk monitor
# |
# | default:
# | - --all-projects
"monitor-arguments": List[str],
"monitor-arguments": list[str],
# | Snyk test arguments.
# |
# | Arguments to pass to Snyk test
# |
# | default:
# | - --all-projects
# | - --severity-threshold=medium
"test-arguments": List[str],
"test-arguments": list[str],
# | Snyk fix arguments.
# |
# | Arguments to pass to Snyk fix
# |
# | default:
# | - --all-projects
"fix-arguments": List[str],
"fix-arguments": list[str],
# | Snyk monitor configuration.
"monitor": "SnykMonitorConfiguration",
},
Expand All @@ -329,28 +326,28 @@ class DpkgConfiguration(TypedDict, total=False):
# |
# | Set the project environment project attribute. To clear the project environment set empty array.
# | For more information see Project attributes https://docs.snyk.io/getting-started/introduction-to-snyk-projects/view-project-information/project-attributes
"project-environment": List["_SnykMonitorEnvironmentItem"],
"project-environment": list["_SnykMonitorEnvironmentItem"],
# | Snyk monitor lifecycle.
# |
# | Set the project lifecycle project attribute. To clear the project lifecycle set empty array.
# | For more information see Project attributes https://docs.snyk.io/snyk-admin/snyk-projects/project-tags
"project-lifecycle": List["_SnykMonitorLifecycleItem"],
"project-lifecycle": list["_SnykMonitorLifecycleItem"],
# | Snyk monitor business criticality.
# |
# | Set the project business criticality project attribute. To clear the project business criticality set empty array.
# | For more information see Project attributes https://docs.snyk.io/snyk-admin/snyk-projects/project-tags
"project-business-criticality": List["_SnykMonitorBusinessCriticalityItem"],
"project-business-criticality": list["_SnykMonitorBusinessCriticalityItem"],
# | Snyk monitor tags.
# |
# | Set the project tags to one or more values.
# | To clear the project tags set empty dictionary.
"project-tags": Dict[str, str],
"project-tags": dict[str, str],
},
total=False,
)


VERSION_MAPPING_DEFAULT: Dict[str, Any] = {}
VERSION_MAPPING_DEFAULT: dict[str, Any] = {}
""" Default value of the field path 'Audit configuration version-mapping' """


Expand All @@ -369,7 +366,7 @@ class _DpkgSourcesAdditionalpropertiesItem(TypedDict, total=False):
Distribution of the source
"""

components: List[str]
components: list[str]
"""
Components.
Expand Down
22 changes: 7 additions & 15 deletions github_app_geo_project/module/audit/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
The auditing functions.
"""
"""The auditing functions."""

import asyncio
import datetime
Expand Down Expand Up @@ -623,9 +621,7 @@ async def _npm_audit_fix(
def outdated_versions(
security: security_md.Security,
) -> list[str | models.OutputData]:
"""
Check that the versions from the SECURITY.md are not outdated.
"""
"""Check that the versions from the SECURITY.md are not outdated."""
version_index = security.headers.index("Version")
date_index = security.headers.index("Supported Until")

Expand Down Expand Up @@ -653,9 +649,7 @@ def _get_sources(
config: configuration.DpkgConfiguration,
local_config: configuration.DpkgConfiguration,
) -> apt_repo.APTSources:
"""
Get the sources for the distribution.
"""
"""Get the sources for the distribution."""
if dist not in _SOURCES:
conf = local_config.get("sources", config.get("sources", configuration.DPKG_SOURCES_DEFAULT))
if dist not in conf:
Expand All @@ -675,9 +669,7 @@ def _get_sources(
name = f"{dist}/{package.package}"
try:
version = debian_inspector.version.Version.from_string(package.version)
if name not in _PACKAGE_VERSION:
_PACKAGE_VERSION[name] = version
elif version > _PACKAGE_VERSION[name]:
if name not in _PACKAGE_VERSION or version > _PACKAGE_VERSION[name]:
_PACKAGE_VERSION[name] = version
except ValueError as exception:
_LOGGER.warning(
Expand All @@ -700,9 +692,9 @@ async def _get_packages_version(
) -> str | None:
"""Get the version of the package."""
global _GENERATION_TIME # pylint: disable=global-statement
if _GENERATION_TIME is None or _GENERATION_TIME < datetime.datetime.now() - utils.parse_duration(
if _GENERATION_TIME is None or datetime.datetime.now() - utils.parse_duration(
os.environ.get("GHCI_DPKG_CACHE_DURATION", "3h")
):
) > _GENERATION_TIME:
_PACKAGE_VERSION.clear()
_SOURCES.clear()
_GENERATION_TIME = datetime.datetime.now()
Expand Down Expand Up @@ -730,7 +722,7 @@ async def dpkg(
with open(dpkg_versions_filename, encoding="utf-8") as versions_file:
versions_config = yaml.load(versions_file, Loader=yaml.SafeLoader)
for versions in versions_config.values():
for package_full in versions.keys():
for package_full in versions:
version = await _get_packages_version(package_full, config, local_config)
if version is None:
_LOGGER.warning("No version found for %s", package_full)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
"""
Automatically generated file from a JSON schema.
"""
"""Automatically generated file from a JSON schema."""

from typing import TypedDict

from typing import List, TypedDict
from typing_extensions import Required


class DeleteOldWorkflowRunsConfiguration(TypedDict, total=False):
"""Delete old workflow runs configuration."""

rules: List["Rule"]
rules: list["Rule"]


# | Rule.
Expand Down
4 changes: 1 addition & 3 deletions github_app_geo_project/module/modules.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Module registry.
"""
"""Module registry."""

import logging
from typing import Any
Expand Down
4 changes: 1 addition & 3 deletions github_app_geo_project/module/pull_request/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
"""
The modules related to the pull request.
"""
"""The modules related to the pull request."""
4 changes: 1 addition & 3 deletions github_app_geo_project/module/pull_request/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def _get_code_spell_command(
],
ignore_file: NamedTemporaryFileStr,
) -> list[str]:
"""
Get the codespell command.
"""
"""Get the codespell command."""
config = context.module_config
code_spell_config = config.get("codespell", {})
code_spell_config = code_spell_config if isinstance(code_spell_config, dict) else {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"""
Automatically generated file from a JSON schema.
"""

from typing import List, TypedDict, Union
"""Automatically generated file from a JSON schema."""

from typing import TypedDict, Union

CODESPELL_ARGUMENTS_DEFAULT = ["--quiet-level=2", "--check-filenames", "--ignore-words-list=ro"]
""" Default value of the field path 'Codespell arguments' """
Expand Down Expand Up @@ -34,7 +31,7 @@
# | - code
# | - names
# | - en-GB_to_en-US
"internal-dictionaries": List[str],
"internal-dictionaries": list[str],
# | codespell arguments.
# |
# | List of argument that will be added to the codespell command
Expand All @@ -43,15 +40,15 @@
# | - --quiet-level=2
# | - --check-filenames
# | - --ignore-words-list=ro
"arguments": List[str],
"arguments": list[str],
# | codespell ignore regular expression.
# |
# | List of regular expression that should be ignored
# |
# | default:
# | - (.*/)?poetry\.lock
# | - (.*/)?package-lock\.json
"ignore-re": List[str],
"ignore-re": list[str],
},
total=False,
)
Expand Down
2 changes: 1 addition & 1 deletion github_app_geo_project/module/pull_request/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import github
import github.PullRequest

from github_app_geo_project import configuration, module
from github_app_geo_project import module
from github_app_geo_project.module.pull_request import links_configuration


Expand Down
Loading

0 comments on commit 2e0e969

Please sign in to comment.