Skip to content

Commit

Permalink
add_image_reference: absolute paths are paths too
Browse files Browse the repository at this point in the history
When deciding whether a package is "virtual", treat names that start
with "/" as paths too.

Signed-off-by: Adam Cmiel <[email protected]>
  • Loading branch information
chmeliik committed Jan 13, 2025
1 parent be5248b commit 4a6af5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def is_virtual_root(package: dict) -> bool:
bool: A boolean indicating if the package is a virtual root.
"""
name = package.get("name")
return not name or name.startswith(".")
return not name or name.startswith((".", "/"))


def redirect_current_roots_to_new_root(sbom: dict, new_root: str) -> dict:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def test_is_virtual_root() -> None:
package["name"] = "./some-dir"
assert add_image_reference.is_virtual_root(package) is True

package["name"] = "/some/absolute/path"
assert add_image_reference.is_virtual_root(package) is True

package["name"] = "bar"
assert add_image_reference.is_virtual_root(package) is False

Expand Down

0 comments on commit 4a6af5d

Please sign in to comment.