Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion src/macaron/repo_finder/repo_finder_deps_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,16 @@ def get_latest_version(purl: PackageURL) -> tuple[PackageURL | None, RepoFinderI
versions = json_extract(metadata, versions_keys, list)
if not versions:
return None, RepoFinderInfo.DDEV_JSON_INVALID
latest_version = json_extract(versions[-1], ["versionKey", "version"], str)

latest_version = None
for version_result in reversed(versions):
if version_result["isDefault"]:
# Accept the version as the latest if it is marked with the "isDefault" property.
latest_version = json_extract(version_result, ["versionKey", "version"], str)
break

if not latest_version:
logger.debug("No latest version found in version list: %s", len(versions))
return None, RepoFinderInfo.DDEV_JSON_INVALID

namespace = purl.namespace + "/" if purl.namespace else ""
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/cases/google_guava_latest/policy.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved. */
/* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. */

#include "prelude.dl"

Policy("test_policy", component_id, "") :-
check_passed(component_id, "mcn_version_control_system_1"),
is_repo_url(component_id, "https://github.com/google/guava").

apply_policy_to("test_policy", component_id) :-
is_component(component_id, "pkg:maven/com.google.guava/[email protected]?type=jar").
20 changes: 20 additions & 0 deletions tests/integration/cases/google_guava_latest/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.

description: |
Analyzing a PURL that requires fetching the latest version, and the ordering of its versions is atypical

tags:
- macaron-python-package

steps:
- name: Run macaron analyze
kind: analyze
options:
command_args:
- -purl
- pkg:maven/com.google.guava/[email protected]?type=jar
- name: Run macaron verify-policy to verify passed/failed checks
kind: verify
options:
policy: policy.dl
Loading