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

Fix channel in PackageInfo #3681

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libmamba/src/core/package_fetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ namespace mamba
{
caches.clear_query_cache(m_package_info);
// need to download this file
LOG_DEBUG << "Adding '" << name() << "' to download targets from '" << channel()
<< "/" << url_path() << "'";
LOG_DEBUG << "Adding '" << name() << "' to download targets from '"
<< hide_secrets(channel()) << "/" << url_path() << "'";
m_tarball_path = m_cache_path / filename();
m_needs_extract = true;
m_needs_download = true;
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/download/downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ namespace mamba::download
{
Error error;
error.message = std::string("Could not find mirrors for channel ")
+ p_initial_request->mirror_name;
+ hide_secrets(p_initial_request->mirror_name);
m_attempt_results.push_back(tl::unexpected(std::move(error)));
}
}
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/specs/package_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace mamba::specs
{
out.platform = url.platform_name();
url.clear_platform();
out.channel = util::rstrip(url.str(), '/');
out.channel = util::rstrip(url.str(specs::CondaURL::Credentials::Show), '/');
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if doing this will lead to security issues...


// Note that we use `rsplit...` instead of `split...`
// because the package name may contain '-'.
Expand Down
21 changes: 21 additions & 0 deletions libmamba/tests/src/specs/test_package_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ namespace
REQUIRE(pkg.channel == "https://conda.anaconda.org/conda-forge");
}

SECTION("http://localhost:32826/t/1a5eb8d110994feaa53d0d9f8bf13bbb/get/proxy-channel/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81"
)
{
static constexpr std::string_view url = "http://localhost:32826/t/1a5eb8d110994feaa53d0d9f8bf13bbb/get/proxy-channel/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81";

auto pkg = PackageInfo::from_url(url).value();

REQUIRE(pkg.name == "_libgcc_mutex");
REQUIRE(pkg.version == "0.1");
REQUIRE(pkg.build_string == "conda_forge");
REQUIRE(pkg.filename == "_libgcc_mutex-0.1-conda_forge.tar.bz2");
REQUIRE(pkg.package_url == url.substr(0, url.rfind('#')));
REQUIRE(pkg.md5 == url.substr(url.rfind('#') + 1));
REQUIRE(pkg.platform == "linux-64");
// Make sure the token is not censored when setting the channel
REQUIRE(
pkg.channel
== "http://localhost:32826/t/1a5eb8d110994feaa53d0d9f8bf13bbb/get/proxy-channel"
);
}

SECTION("https://conda.anaconda.org/conda-forge/linux-64/pkg.conda")
{
static constexpr std::string_view url = "https://conda.anaconda.org/conda-forge/linux-64/pkg.conda";
Expand Down
Loading