question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conflicting file path assertions in `delegate()` and `add_paths()`

See original GitHub issue

Description of issue or feature request:

Related to #957

The Targets.delegate()method fails if one of the file paths or patterns passed via the paths argument is absolute, i.e. starts with a directory separator. At the same time it warns if it the path does not have self._targets_directory as prefix, which very well may be an absolute path.

https://github.com/theupdateframework/tuf/blob/409eef1a4872a88b610e81b375f36b07a8e0f996/tuf/repository_tool.py#L2286-L2294

The Targets.add_paths() methods emits a similar message (with debug level). Note that the method does not check whether the passed paths have a leading directory separator, although it should, in order to be consistent with above function.

https://github.com/theupdateframework/tuf/blob/409eef1a4872a88b610e81b375f36b07a8e0f996/tuf/repository_tool.py#L1868-L1872

Current behavior:

  • Targets.delegate() and Targets.add_paths() emit warning/debug message if a passed path or path pattern is not prefixed with the targets directory base path, i.e. self._targets_directory.
  • Targets.add_paths does not check if the passed paths are indeed relative.

Expected behavior:

Either,

  • Targets.delegate() and Targets.add_paths() should not care about the prefix of the passed paths or path patterns.
  • Targets.add_paths should probably assert that the passed paths are relative, to be consistent with the sibling the corresponding functionality of delegate().

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lukpuehcommented, Mar 6, 2020

I also just saw that I didn’t suggest an expected behavior for the other issue, i.e. the warning/debug messages on not path.startswith(targets_directory).

I strongly suggest to remove them, because if a PATHPATTERN does indeed start with a targets directory, I think, it won’t even match TARGETPATHs, as they explicitly leftstrip the targets directory, see e.g. add_target: https://github.com/theupdateframework/tuf/blob/409eef1a4872a88b610e81b375f36b07a8e0f996/tuf/repository_tool.py#L1962

1reaction
lukpuehcommented, Mar 9, 2020

To make sure we are on the same page, we are not talking about TARGETPATH but PATHPATTERN here. But the specification states something similar:

To avoid surprising behavior when matching targets with PATHPATTERN, it is RECOMMENDED that PATHPATTERN uses the forward slash (/) as directory separator and does not start with a directory separator, akin to TARGETSPATH.

Also, just to double check, do others think raising an exception is reasonable? The spec only recommends relative paths, but IIRC we agreed (theupdateframework/specification#63, theupdateframework/specification#67) that an implementation can be more assertive than the spec in this regard. So I think leaving the strict behavior in delegate and adding it to add_paths is indeed reasonable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

conflicting files on the build path - java - Stack Overflow
t seems to me that the two slf4j*.jar files cause the conflict. I tried to remove one jar file from the built path....
Read more >
Diff - 63fab7f6fe..c092e144b5 - chromium/src - Git at Google
The user selects this to verify their identity on a web site (i.e. sign in) using a Security Key (an external physcial device...
Read more >
pytest Documentation - Read the Docs
The first test passed and the second failed. You can easily see the intermediate values in the assertion to help you under-.
Read more >
BuildXL/SandboxedProcessPipExecutor.cs at main - GitHub
Path.Combine(SpecialFolderUtilities.GetFolderPath(Environment. ... Combine(GetStandardDirectory(), file. ... Assert(ShouldSandboxedProcessExecuteInVm);.
Read more >
Solved: Resolve conflicts - Missing file problem - NI Community
Solved: Any ideas on how to resolve the conflicts below? I've tried: Unloading the broken VI and reloading it with the correct path....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found