Skip to content

feat(parser): Support Swift Package.resolved schema 2+ #5193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions cve_bin_tool/parsers/swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,22 @@ def run_checker(self, filename):
except JSONDecodeError as e:
self.logger.debug(f"Error occurred while parsing {filename}: {e}")
return
for package in content["object"]["pins"]:
product = package["package"]

# Check the schema version
if content["version"] == 1:
pins_object = content["object"]
pins = pins_object["pins"]
package_key = "package"
repo_key = "repositoryURL"
else:
pins = content["pins"]
package_key = "identity"
repo_key = "location"

for package in pins:
product = package[package_key]
version = package["state"]["version"]
repository_url = package.get("repositoryURL", None)
repository_url = package.get(repo_key, None)
domain = None
if repository_url:
parse = urlparse(repository_url)
Expand Down