feat(cli,registry): verify signed artifacts offline; attach download filenames
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 8s

This commit is contained in:
faumaray committed 2026-12-04 07:59:38 +03:00
1 parent da7e8233ce
commit af735c28ff
5 files changed
+122

No files matched your search

+18
View File
@@ -293,6 +293,20 @@ std::string content_type_for_ext(const std::filesystem::path &p) {
return "application/octet-stream";
}
// Builds a quoted attachment disposition for a download response. Route segments are already
// validated, but only [A-Za-z0-9._-] is kept so the header can never contain quotes, CR/LF or
// path separators.
std::string attachment_disposition(std::string_view filename) {
std::string safe;
safe.reserve(filename.size());
for (const char c : filename) {
const bool keep = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') || c == '.' || c == '_' || c == '-';
safe.push_back(keep ? c : '_');
}
return "attachment; filename=\"" + safe + "\"";
}
} // namespace
RegistryService::RegistryService(RegistryConfig config)
@@ -1379,6 +1393,8 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
HttpResponse resp;
resp.status = 200;
resp.headers["Content-Type"] = "application/x-tar";
resp.headers["Content-Disposition"] =
attachment_disposition(pkg_name + "-" + segs[4] + ".tar");
resp.headers["X-Content-SHA256"] = rit->second.sha256;
resp.headers["ETag"] = "\"" + rit->second.sha256 + "\"";
resp.body = std::move(*bytes);
@@ -1573,6 +1589,8 @@ HttpResponse RegistryService::handle_request(const HttpRequest &req) {
HttpResponse resp;
resp.status = 200;
resp.headers["Content-Type"] = "application/octet-stream";
resp.headers["Content-Disposition"] =
attachment_disposition(pkg_name + "-" + segs[4] + "-" + segs[6] + ".bin");
resp.headers["X-Content-SHA256"] = bit->second.sha256;
resp.headers["ETag"] = "\"" + bit->second.sha256 + "\"";
resp.body = std::move(*bytes);