Skip to content

Commit

Permalink
Merge pull request #366 from camptocamp/fix
Browse files Browse the repository at this point in the history
Audit: Add debug messages
  • Loading branch information
sbrunner authored Jun 14, 2024
2 parents fe0c0f5 + b6b2dc5 commit ec26e13
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion github_app_geo_project/module/audit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ async def _npm_audit_fix(
for package_lock_file_name, file_messages in fixable_files_npm.items():
directory = os.path.dirname(os.path.abspath(package_lock_file_name))
messages.update(file_messages)
_LOGGER.debug("Fixing vulnerabilities in %s with npm audit fix --force", package_lock_file_name)
command = ["npm", "audit", "fix", "--force"]
_, success = await _run_timeout(
command,
Expand All @@ -499,16 +500,17 @@ async def _npm_audit_fix(
result,
directory,
)
_LOGGER.debug("Fixing version in %s", package_lock_file_name)
# Remove the add '~' in the version in the package.json
with open(os.path.join(directory, "package.json"), encoding="utf-8") as package_file:
package_json = json.load(package_file)
for dependencies_type in ("dependencies", "devDependencies"):
for package, version in package_json.get(dependencies_type, {}).items():
print(dependencies_type, package, version)
if version.startswith("^"):
package_json[dependencies_type][package] = version[1:]
with open(os.path.join(directory, "package.json"), "w", encoding="utf-8") as package_file:
json.dump(package_json, package_file, indent=2)
_LOGGER.debug("Succeeded fix %s", package_lock_file_name)

fix_success &= success
return "\n".join(messages), fix_success
Expand Down

0 comments on commit ec26e13

Please sign in to comment.