Allow beakerlib libraries with clashing repo and name#4503
Allow beakerlib libraries with clashing repo and name#4503LecrisUT wants to merge 12 commits intoteemtee:mainfrom
Conversation
|
Seems there are some failing tests: |
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. |
|
/gemini review |
There was a problem hiding this comment.
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.
| local_repo_path = self.parent.workdir / self.dest / self.repo | ||
| local_library_path = local_repo_path / self.fmf_node_path |
There was a problem hiding this comment.
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_pathSigned-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>
|
/packit retest-failed |
| @@ -0,0 +1,10 @@ | |||
| /git_clone: | |||
There was a problem hiding this comment.
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]` |
There was a problem hiding this comment.
It'd be nice to share why they aren't...
There was a problem hiding this comment.
This is partly due to the covariant/invariant type-definitions. We could probably detangle it, but would be more complicated patch
There was a problem hiding this comment.
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.
tmt/libraries/beakerlib.py
Outdated
|
|
||
| # TODO: Move these inside the identifier | ||
| @abc.abstractmethod | ||
| def _show_ref(self) -> str: |
There was a problem hiding this comment.
Doesn't really show anything, IIUIC. Maybe ref_formatted or something similar? Plus, it could be a property`, seems to take no input.
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
The original code should already have allowed for libraries with different
namepart but same repo, but as shown in practice that did not happen. This is because the string construction in ofstr(Beakerlib)only took the last part of thename, disallowing/foo/common,/bar/common. But beakerlib does not seem to actually have that restriction.Summary of changes:
non-existing-urlhandling to thegit_cloneutility(repo)/(name)as it would be used inrlImportPull Request Checklist
(Better repository for testing needed: Add a beakerlib test case for tmt#4440 tests#23)
Depends on #4499
Closes #4440