Skip to content
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

[Bug]: Incorrect usage of strip method in nuget_dependency.py #760

Closed
NishanthSanjeevi opened this issue Feb 24, 2024 · 0 comments · Fixed by #761
Closed

[Bug]: Incorrect usage of strip method in nuget_dependency.py #760

NishanthSanjeevi opened this issue Feb 24, 2024 · 0 comments · Fixed by #761
Labels
bug Something isn't working new Issue not yet reviewed

Comments

@NishanthSanjeevi
Copy link
Contributor

Contact Details

sanjeevinishanth@gmail.com

Describe the Bug

edk2toolext\environment\extdeptypes\nuget_dependency.py
line number: 172
self.nuget_cache_path = return_string.strip().strip("global-packages: ")

This is an incorrect usage of the strip method. This will cause failures if the nuget dependency path ends with "e"
For example if the NuGet cache path is: "C:\nuget_cache", the second strip method will return an invalid path.

The second strip("global-packages: ") call is intended to remove the characters in the set "global-packages: " from both ends of the string. This set includes each individual character: 'g', 'l', 'o', 'b', 'a', 'l', '-', 'p', 'a', 'c', 'k', 'a', 'g', 'e', 's', ':', and ' ' (space). It does not treat "global-packages: " as a single substring to remove.

This method then removes these characters from the beginning and the end of the string until it encounters a character not in the set. Since the string "C:\nuget_cache" does not start with any of those characters, the beginning of the string remains unchanged. However, the end of the string "C:\nuget_cache" ends with "e", which is in the set of characters to remove. Therefore, it removes "e" from the end, resulting in "C:\nuget_cach".

What Python version are you using?

Python 3.10, Python 3.11

Reproduction steps

When I modified the default NUGET cache path.

Expected behavior

For the right NuGet cache path to be found

Execution Environment

Windows

ENV_VARIABLE:
NUGET_PACKAGES="C:\nuget_cache"

Pip packages

edk2-pytool-library~=0.20.0
edk2-pytool-extensions~=0.27.2

Additional context

No response

@NishanthSanjeevi NishanthSanjeevi added bug Something isn't working new Issue not yet reviewed labels Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new Issue not yet reviewed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant