Skip to content

Allow beakerlib libraries with clashing repo and name#4503

Open
LecrisUT wants to merge 12 commits intoteemtee:mainfrom
LecrisUT:fix/4440
Open

Allow beakerlib libraries with clashing repo and name#4503
LecrisUT wants to merge 12 commits intoteemtee:mainfrom
LecrisUT:fix/4440

Conversation

@LecrisUT
Copy link
Contributor

@LecrisUT LecrisUT commented Jan 16, 2026

The original code should already have allowed for libraries with different name part but same repo, but as shown in practice that did not happen. This is because the string construction in of str(Beakerlib) only took the last part of the name, disallowing /foo/common, /bar/common. But beakerlib does not seem to actually have that restriction.

Summary of changes:

  • Reworked how the library's repo are cloned allowing for a big degree of collision
  • Allow for whole libraries to collide and take the first definition
  • Adjust the order of library fetching to account for the relaxed condition above
  • Moved the non-existing-url handling to the git_clone utility
  • Adjusted the display of the beakerlib library to display the full (repo)/(name) as it would be used in rlImport

Pull Request Checklist

Depends on #4499
Closes #4440

@LecrisUT LecrisUT added this to the 1.66 milestone Jan 16, 2026
@LecrisUT LecrisUT added area | libraries Issues related to beakerlib libraries support status | blocked The merging of PR is blocked on some other issue ci | full test Pull request is ready for the full test execution labels Jan 16, 2026
@github-project-automation github-project-automation bot moved this to backlog in planning Jan 16, 2026
@LecrisUT LecrisUT moved this from backlog to review in planning Jan 16, 2026
@LecrisUT LecrisUT mentioned this pull request Jan 22, 2026
1 task
@LecrisUT LecrisUT changed the title Allow beakerlib libraries with clashing repo (and name) parts Allow beakerlib libraries with clashing repo or name parts Jan 26, 2026
@LecrisUT LecrisUT changed the title Allow beakerlib libraries with clashing repo or name parts Allow beakerlib libraries with partially clashing repo and name Jan 26, 2026
@LecrisUT LecrisUT removed the status | blocked The merging of PR is blocked on some other issue label Jan 26, 2026
@psss
Copy link
Contributor

psss commented Jan 26, 2026

Seems there are some failing tests:

Library 'openssl/certgen (https://github.com/beakerlib/openssl)' conflicts with previously fetched 'openssl/certgen (https://github.com/beakerlib/openssl#master)'.
:: [ 13:55:37 ] :: [   FAIL   ] :: Command 'tmt run -arvvvddd plan --name 'rpm|fmf|nick|duplicate'' (Expected 0, got 2)

@LecrisUT
Copy link
Contributor Author

Seems there are some failing tests:

Library 'openssl/certgen (https://github.com/beakerlib/openssl)' conflicts with previously fetched 'openssl/certgen (https://github.com/beakerlib/openssl#master)'.
:: [ 13:55:37 ] :: [   FAIL   ] :: Command 'tmt run -arvvvddd plan --name 'rpm|fmf|nick|duplicate'' (Expected 0, got 2)

Let's postpone this one. The test failures are related to the feature that I was planning to address later one, but it seems I cannot fix the tests without that feature.

  • Allow for whole libraries to collide and take the first definition Postponed

  • Adjust the order of library fetching to account for the relaxed condition above Postponed

@LecrisUT LecrisUT moved this from review to implement in planning Jan 27, 2026
@LecrisUT LecrisUT self-assigned this Jan 27, 2026
@psss
Copy link
Contributor

psss commented Jan 27, 2026

Let's postpone this one. The test failures are related to the feature that I was planning to address later one, but it seems I cannot fix the tests without that feature.

Ack, makes sense.

@psss psss added the status | postponed Let's postpone for the next sprint label Jan 27, 2026
@psss psss moved this from implement to backlog in planning Jan 27, 2026
@happz happz removed this from the 1.66 milestone Jan 28, 2026
@psss psss added this to the 1.67 milestone Jan 29, 2026
@skycastlelily
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the beakerlib library fetching logic, addressing clashing library names and centralizing non-existent URL handling. However, it introduces path traversal vulnerabilities where untrusted input from library identifiers (repo, path, name) is used to construct filesystem paths without proper validation, potentially allowing arbitrary file reads or writes. There is also a potential Python compatibility issue and a bug in the new caching logic that needs to be addressed.

Comment on lines +181 to +182
local_repo_path = self.parent.workdir / self.dest / self.repo
local_library_path = local_repo_path / self.fmf_node_path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

This code block is susceptible to a path traversal vulnerability. The self.repo and self.fmf_node_path attributes, derived from untrusted library identifiers, can be manipulated by an attacker using absolute paths or directory traversal sequences (..). This could cause local_repo_path or local_library_path to point to arbitrary locations on the system. Furthermore, the calculation of local_library_path as the cache key is inconsistent with the destination path calculation. For BeakerLibFromPath, self.fmf_node_path can be an absolute path, leading to a cache key outside the intended workdir. The cache key should consistently represent the destination path within the workdir to mitigate this security risk and ensure correct caching.

        if isinstance(self, BeakerLibFromPath):
            # BeakerLibFromPath copies to a directory named after the library name
            relative_library_path = Path(self.name.strip('/'))
        else:
            # BeakerLibFromUrl uses the fmf_node_path
            relative_library_path = self.fmf_node_path.unrooted()

        local_library_path = local_repo_path / relative_library_path

@LecrisUT LecrisUT changed the title Allow beakerlib libraries with partially clashing repo and name Allow beakerlib libraries with clashing repo and name Feb 6, 2026
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
@psss psss moved this from backlog to implement in planning Feb 9, 2026
@LecrisUT LecrisUT moved this from implement to review in planning Feb 9, 2026
@LecrisUT LecrisUT removed their assignment Feb 9, 2026
@LecrisUT
Copy link
Contributor Author

LecrisUT commented Feb 9, 2026

/packit retest-failed

@@ -0,0 +1,10 @@
/git_clone:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filename probably can be renamed now.

to_fetch = original_require + original_recommend
for dependency in filter(already_fetched, to_fetch):
# Library require/recommend
# TODO: These should actually be `set[DependencySimple]`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to share why they aren't...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is partly due to the covariant/invariant type-definitions. We could probably detangle it, but would be more complicated patch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guessed it might be related. Would you mind mentioning the reason in the comment? I doubt I would be able to guess it in six months.


# TODO: Move these inside the identifier
@abc.abstractmethod
def _show_ref(self) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really show anything, IIUIC. Maybe ref_formatted or something similar? Plus, it could be a property`, seems to take no input.

@psss psss self-assigned this Feb 10, 2026
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
@psss psss requested a review from happz February 11, 2026 12:09
@psss psss modified the milestones: 1.67, 1.68 Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area | libraries Issues related to beakerlib libraries support ci | full test Pull request is ready for the full test execution status | postponed Let's postpone for the next sprint

Projects

Status: review

Development

Successfully merging this pull request may close these issues.

Library conflicts with different url

4 participants