Repository navigation
apt: unknown architectures and uploads past the component cap are refused - #897
Merged
Merged
Conversation
A writer could take a hosted apt repository's index past the 10,000 files it may hold with packages of many components and made-up architectures, after which InRelease, Packages and key.asc answered 500 for every reader. - A package's Architecture (and an imported entry's) must be `all` or one of dpkg's architectures (`dpkg-architecture -L`, dpkg 1.22.6). - A hosted repository holds at most 8 components: 8 x 207 architectures x 6 files stay under the host's limit. A plugin declares such a cap on a field of its stored summaries (`FormatPlugin::summary_caps`); the hosted publish path refuses a publish or an import that would add a value past it with 400 naming the cap, counting new values under a `FOR NO KEY UPDATE` lock on the repository row so that concurrent uploads cannot both take the last place. Fixes #761 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJc6XYdgQSLMWWdx7fb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #761
A writer could push a hosted apt repository's index past the 10,000 files the host allows. Packages with many
Section: cN/…components and made-up architectures did it. After that,InRelease,Packagesandkey.ascanswered 500 for every reader. Now neither can grow without bound, and an upload that would break the index is refused with 400.What changed
crates/formats/apt/src/control.rs).ARCHITECTURESis a sorted table of the 206 namesdpkg-architecture -Llists (dpkg 1.22.6).known_architectureaccepts these plusall. A package's control file (Control::parse) is checked against it, and so is an imported index entry (Entry::problem). The syntacticvalid_architecturestays for reading paths and ids, so packages already stored keep being served.control::MAX_COMPONENTS). In the worst case, 8 components × 207 architectures × 6 files + 5 = 9,941 files, which is underMAX_INDEX_FILES. A unit test asserts this.FormatPlugin::summary_capsreturns a list ofSummaryCap { field, max, what }, and the default has none. apt capscomponent.crates/core/src/repo/hosted.rs) refuses a version whose summary would add a value past a cap. It answers400naming the cap:the repository holds 8 components, the most it may hold (8): "c8" would be one more.FOR NO KEY UPDATElock on the repository row, so two concurrent uploads can't both take the last place. That lock does not conflict with theFOR KEY SHAREevery component insert takes, so ordinary uploads don't wait on it.docs/apt.md(hosted repositories and limitations) anddocs/format-plugins.md(summary_caps).Tests
crates/formats/apt:architectures_are_dpkgs: the table is sorted, and known and unknown names are told apart.the_worst_case_index_fits_the_hosts_limit.a_control_file_needs_its_identitynow coversArchitecture: a1andlinux-amd64.the_component_is_capped: the capped field is the one in the stored summary.crates/server/tests/apt.rs→architectures_and_components_are_bounded:Architecture: a1gets 400. dpkg architectures, includingmusl-linux-riscv64andall, are taken.mainplus 7 more components fill the repository, and a ninth answers 400 naming the cap.InReleaseverifies and lists the 8 components.Packagesandkey.ascserve.Architecture: a1parses.a1upload (201).cargo fmt --all --check;cargo clippywith-D warningsand all targets on forge-plugin-api, forge-plugin, forge-core, forge-db, forge-format-apt and forge-server; tests of forge-format-apt, forge-plugin, forge-plugin-api and forge-db; forge-core's lib andhosted_write; forge-server'saptandapt_import;cargo xtask changelog --check.Changelog
docs/changes/2.2.0/761.fixed.mdNot fixed here
crates/server/src/indexes/mod.rs.Generated by Claude Code