Skip to content

Conversation

Copy link

Copilot AI commented Dec 9, 2025

HTTP error messages currently log full request URLs, potentially exposing sensitive tokens and credentials in query parameters.

Changes

  • Added redact_url_query() helper function that replaces query parameter values with [redacted] while preserving parameter names and URL structure
  • Updated error messages in both synchronous and asynchronous http_request::perform() methods to redact URLs before logging

Example

Before:

Failed to perform http request to https://api.example.com/auth?token=secret123&key=abc456 : CURLcode 6

After:

Failed to perform http request to https://api.example.com/auth?token=[redacted]&key=[redacted] : CURLcode 6

The redaction preserves debugging utility (parameter names, URL structure) while protecting sensitive values.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Problem

Redact sensitive query parameter values from URLs when constructing error messages in lib/playapi/util/http.cpp. The repository currently logs full request URLs in error messages which may include sensitive tokens or credentials in query parameters. Other logs are already disabled by default; only error messages need redaction.

Goal

Add a helper function that redacts query parameter values (keeping parameter names) and update the two error message locations in http.cpp to use it.

Files to change

  • lib/playapi/util/http.cpp

Detailed changes

  1. Add a static helper function redact_url_query(...) after the line "using namespace playapi;". This function should:
    • Return the original URL unchanged if there is no query string ('?').
    • Keep the URL base and '?' character.
    • Replace each query parameter value with the literal string "[redacted]" but keep parameter names and separators.

Add the following function (paste exactly):

static std::string redact_url_query(const std::string& url) {
auto pos = url.find('?');
if (pos == std::string::npos) return url;
std::string base = url.substr(0, pos + 1); // include '?'
std::string query = url.substr(pos + 1);
std::string out;
size_t i = 0;
while (i < query.size()) {
size_t amp = query.find('&', i);
std::string part = (amp == std::string::npos) ? query.substr(i) : query.substr(i, amp - i);
size_t eq = part.find('=');
if (eq == std::string::npos) {
// key without value
out += part;
} else {
// keep key and '=' then redact value
out += part.substr(0, eq + 1);
out += "[redacted]";
}
if (amp == std::string::npos) break;
out += '&';
i = amp + 1;
}
return base + out;
}

  1. Replace the error message construction in the synchronous perform() function (currently around the block that throws a runtime_error near the top-level perform):

Replace this line:
errormsg << "Failed to perform http request to " << url << " : CURLcode " << curlerr << " Details: " << errbuf;

With:
errormsg << "Failed to perform http request to " << redact_url_query(url) << " : CURLcode " << curlerr << " Details: " << errbuf;

  1. Replace the equivalent line in the asynchronous perform(...) lambda (the one referencing req->url) near the end of the file:

Replace this line:
errormsg << "Failed to perform http request to " << req->url << " : CURLcode " << curlerr << " Details: " << errbuf;

With:
errormsg << "Failed to perform http request to " << redact_url_query(req->url) << " : CURLcode " << curlerr << " Details: " << errbuf;

Notes

  • The helper is deliberately simple and only redacts query values. It preserves keys and separators so logs remain useful for debugging without leaking sensitive values.
  • No other logging changes are requested because other logs are already disabled by default.
  • No new headers or external deps are needed.

Please open a pull request that implements the changes above and targets the repository "minecraft-linux/Google-Play-API". Do not set a base branch (leave default) unless instructed otherwise.

This pull request was created as a result of the following prompt from Copilot chat.

Problem

Redact sensitive query parameter values from URLs when constructing error messages in lib/playapi/util/http.cpp. The repository currently logs full request URLs in error messages which may include sensitive tokens or credentials in query parameters. Other logs are already disabled by default; only error messages need redaction.

Goal

Add a helper function that redacts query parameter values (keeping parameter names) and update the two error message locations in http.cpp to use it.

Files to change

  • lib/playapi/util/http.cpp

Detailed changes

  1. Add a static helper function redact_url_query(...) after the line "using namespace playapi;". This function should:
    • Return the original URL unchanged if there is no query string ('?').
    • Keep the URL base and '?' character.
    • Replace each query parameter value with the literal string "[redacted]" but keep parameter names and separators.

Add the following function (paste exactly):

static std::string redact_url_query(const std::string& url) {
auto pos = url.find('?');
if (pos == std::string::npos) return url;
std::string base = url.substr(0, pos + 1); // include '?'
std::string query = url.substr(pos + 1);
std::string out;
size_t i = 0;
while (i < query.size()) {
size_t amp = query.find('&', i);
std::string part = (amp == std::string::npos) ? query.substr(i) : query.substr(i, amp - i);
size_t eq = part.find('=');
if (eq == std::string::npos) {
// key without value
out += part;
} else {
// keep key and '=' then redact value
out += part.substr(0, eq + 1);
out += "[redacted]";
}
if (amp == std::string::npos) break;
out += '&';
i = amp + 1;
}
return base + out;
}

  1. Replace the error message construction in the synchronous perform() function (currently around the block that throws a runtime_error near the top-level perform):

Replace this line:
errormsg << "Failed to perform http request to " << url << " : CURLcode " << curlerr << " Details: " << errbuf;

With:
errormsg << "Failed to perform http request to " << redact_url_query(url) << " : CURLcode " << curlerr << " Details: " << errbuf;

  1. Replace the equivalent line in the asynchronous perform(...) lambda (the one referencing req->url) near the end of the file:

Replace this line:
errormsg << "Failed to perform http request to " << req->url << " : CURLcode " << curlerr << " Details: " << errbuf;

With:
errormsg << "Failed to perform http request to " << redact_url_query(req->url) << " : CURLcode " << curlerr << " Details: " << errbuf;

Notes

  • The helper is deliberately simple and only redacts query values. It preserves keys and separators so logs remain useful for debugging without leaking sensitive values.
  • No other logging changes are requested because other logs are already disabled by default.
  • No new headers or external deps are needed.

Please open a pull request that implements the changes above and targets the repository "minecraft-linux/Google-Play-API". Do not set a base branch (leave default) unless instructed otherwise.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits December 9, 2025 21:54
Co-authored-by: ChristopherHX <44845461+ChristopherHX@users.noreply.github.com>
Co-authored-by: ChristopherHX <44845461+ChristopherHX@users.noreply.github.com>
Co-authored-by: ChristopherHX <44845461+ChristopherHX@users.noreply.github.com>
Co-authored-by: ChristopherHX <44845461+ChristopherHX@users.noreply.github.com>
Copilot AI changed the title [WIP] Add helper function to redact sensitive query parameters Redact query parameter values in HTTP error messages Dec 9, 2025
Copilot AI requested a review from ChristopherHX December 9, 2025 22:01
@ChristopherHX ChristopherHX marked this pull request as ready for review December 9, 2025 22:03
Copy link
Member

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

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

Probably working

@ChristopherHX
Copy link
Member

This didn't made it into v1.5.5, but the translation of the ui should work now after months

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants