-
Notifications
You must be signed in to change notification settings - Fork 276
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
Remove global state from repository_tool #1207
Comments
Thanks for the detailed and reproducible issue report, @davidstrauss!
I fear this is not a workaround but the intended use. To provide some context: Part of the global state you mention is kept in So what happens in your example is that "repo2" replaces "repo" in
I agree! |
A mildly related FYI in case you work on the |
I suspected this as well. I'm concerned about the risk of leaky context between fixtures I'm generating, which could make any given fixture dependent on state created by prior fixtures if the namespacing in components isn't comprehensive. Would it be possible to leverage an aspect of the instantiated object's identity (or create an aspect) that auto-namespaces to avoid these effects? I can't think of why you would want to instantiate two repository objects that share an undefined subset of state. Also, thanks for the info about the updated parameter order. |
This, or maybe offer the interface as procedural and namespace-only (to go the other way)? There's a note in Slack about "an unfortunate legacy of considering OOP bad practice for security." I feel like consumers of the library being able to reason about the behavior (and have actual behavior meet those expectations) is also important for security. A mixed OO/namespace model for state is hard to reason about. |
Yes, that would be possible. But I'm a bit reluctant to spend any efforts on repository_tool that aren't strictly necessary for current operations. I'd rather push forward the planned refactor (most notably in this context: #1136). Until then, would your use case allow to just pass unique names to
Me neither. |
Closing this issue as it was filed against (what is now known as) the legacy codebase: issue seems to not be relevant anymore. Please re-open or file a new issue if you feel that the issue is revelant to current python-tuf. The current code base does not seem to suffer from the issue described but note that we don't currently have a replacement for repository_tool: examples/repo_example/ shows how to use the lower level Metadata API for repository purposes. More detailsCurrent source code (and upcoming 1.0 release) only contains the modern components
Legacy components (e.g. |
Description of issue or feature request:
As part of my PHP-TUF work, I'm developing a range of fixtures for our conformance testing. (I would also love to get this work upstream.) Unfortunately,
tuf.repository_tool
seems to maintain some in-memory state that interferes with generating multiple repositories from the same script. The code below demonstrates the issue, and the second repository object is largely broken.While it's not shown here, it also seems to hold onto targets and then get confused when they're no longer available from the expected relative path in the newly initialized repo.
I've noticed a workaround is to instantiate each repository with a unique second argument (third if you count the implied
self
) forrepository_tool.create_new_repository()
, but it seems like this should be unnecessary if they're separate objects with their own directories already.Code to reproduce:
Current behavior:
Output:
Expected behavior:
Output (altered from above). Please note the
'root' role contains
and missing "already been used" lines.The text was updated successfully, but these errors were encountered: