diff --git a/github_app_geo_project/module/audit/__init__.py b/github_app_geo_project/module/audit/__init__.py index 7d606ffd88..36e76863dc 100644 --- a/github_app_geo_project/module/audit/__init__.py +++ b/github_app_geo_project/module/audit/__init__.py @@ -199,7 +199,9 @@ async def _process_snyk_dpkg( if context.module_event_data.type == "dpkg": body_md = "Update dpkg packages" - if os.path.exists("ci/dpkg-versions.yaml"): + if os.path.exists("ci/dpkg-versions.yaml") or os.path.exists( + ".github/dpkg-versions.yaml" + ): await audit_utils.dpkg( context.module_config.get("dpkg", {}), local_config.get("dpkg", {}) ) @@ -422,10 +424,16 @@ async def process( dpkg_version = None try: - dpkg_version = repo.get_contents("ci/dpkg-versions.yaml") + dpkg_version = repo.get_contents(".github/dpkg-versions.yaml") except github.GithubException as exception: if exception.status == 404: - _LOGGER.debug("No dpkg-versions.yaml file in the repository") + try: + dpkg_version = repo.get_contents("ci/dpkg-versions.yaml") + except github.GithubException as exception2: + if exception2.status == 404: + _LOGGER.debug("No dpkg-versions.yaml file in the repository") + else: + raise else: raise if ( diff --git a/github_app_geo_project/module/audit/utils.py b/github_app_geo_project/module/audit/utils.py index 500ce22479..3a1d10e414 100644 --- a/github_app_geo_project/module/audit/utils.py +++ b/github_app_geo_project/module/audit/utils.py @@ -697,11 +697,16 @@ async def _get_packages_version( async def dpkg( config: configuration.DpkgConfiguration, local_config: configuration.DpkgConfiguration ) -> None: - """Update the version of packages in the file ci/dpkg-versions.yaml.""" - if not os.path.exists("ci/dpkg-versions.yaml"): - _LOGGER.warning("The file ci/dpkg-versions.yaml does not exist") - - with open("ci/dpkg-versions.yaml", encoding="utf-8") as versions_file: + """Update the version of packages in the file .github/dpkg-versions.yaml or ci/dpkg-versions.yaml.""" + if not os.path.exists("ci/dpkg-versions.yaml") and not os.path.exists(".github/dpkg-versions.yaml"): + _LOGGER.warning("The file .github/dpkg-versions.yaml or ci/dpkg-versions.yaml does not exist") + + dpkg_versions_filename = ( + ".github/dpkg-versions.yaml" + if os.path.exists(".github/dpkg-versions.yaml") + else "ci/dpkg-versions.yaml" + ) + 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(): @@ -734,5 +739,5 @@ async def dpkg( exception, ) - with open("ci/dpkg-versions.yaml", "w", encoding="utf-8") as versions_file: + with open(dpkg_versions_filename, "w", encoding="utf-8") as versions_file: yaml.dump(versions_config, versions_file, Dumper=yaml.SafeDumper)