Repository navigation
Expand file tree
/
Copy pathCHANGES
More file actions
292 lines (278 loc) · 17.2 KB
/
Copy pathCHANGES
File metadata and controls
292 lines (278 loc) · 17.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
Unreleased
==========
* New command minideb mcp: a local Model Context Protocol server for AI agents
on stdin/stdout (JSON-RPC 2.0, standard library only, Linux and macOS, never
as root). Tools: repository_overview, search_packages, package_versions,
package_info, source_info, find_file, appstream_components, download_package,
inspect_deb and inspect_dsc. Downloads go only to --download-dir (default:
the current directory) and a private per-session temporary directory, never
overwrite, never follow symlinks, and are verified against a SHA256 or
stronger hash from the repository metadata. Options: --download-dir,
--no-download, --allow-host, --allow-link-local, --max-response-bytes,
--max-download-bytes, --call-timeout and --download-timeout. Repositories
come from --url and --sources only (the system sources are not read); the
agent may also name a repository URL in each call. See "Using minideb with AI
agents" in README.md, the MCP SERVER section of the man page and the new
example examples/12_mcp_client.py.
* RepoClient.fetch_dsc() takes an optional keyword-only verify argument that
overrides the client's setting for that one fetch.
* verify_file() takes an optional keyword-only progress callback that is called
before every read, so callers can stop a long verification (cancellation,
deadlines).
* DebPackage.read() takes an optional max_size: a larger member raises
DebMemberTooLargeError (a DebSizeLimitError) before it is read, and
DebPackage.files() takes an optional max_entries (DebEntryLimitError, a
DebSizeLimitError, when the data archive has more entries).
* The Fetcher refuses link-local addresses (169.254.0.0/16, fe80::/10), the
metadata service addresses fd00:ec2::254 and 100.100.100.200 and the cloud
metadata host names metadata, metadata.google.internal and instance-data,
for requested URLs and redirect targets alike (HostNotAllowed, a
FetchError). Host names are also checked when connecting: a name that
resolves to such an address is refused, and the connection goes to the
checked address. Host names are compared in their IDNA form. Pass
block_link_local=False to allow all of these. Loopback and private
addresses are still allowed. Through a proxy (http_proxy/https_proxy)
the proxy resolves the names, so only the URL text is checked; the proxy
is trusted configuration. IPv6 addresses embedding an IPv4 address
(IPv4-mapped, NAT64 64:ff9b::/96, IPv4-compatible) are judged by that
address. The connected peer address is checked again before anything
is sent.
* Fetcher(allowed_hosts=...) restricts http(s) requests and redirects to the
given hosts (exact names or *.suffix wildcards; file: URLs are not
affected). A bare string, an entry with a path or a port, and an entry that
is neither an IP address nor a host name of letters, digits, "-" and "_"
labels (after an optional "*.") are rejected. minideb mcp refuses to start
when a --url or --sources repository is outside --allow-host.
* Fetcher.check_host(url) applies the host policy to a URL without making a
request (HostNotAllowed when refused), and minideblib.repo.release gains
is_not_found(err): whether a FetchError means HTTP 404 or a missing
file:// file.
* Fetcher.get() and Fetcher.exists() take an optional per-call CancelToken
(token=) and a time.monotonic() deadline (deadline=), and the new
Fetcher.scope(token=, deadline=) context manager applies them to every
request inside it, including those of RepoClient (suite probing too).
They are checked before every attempt and between body chunks, end
backoff waits early and bound each socket wait (DNS resolution is not
bounded by the deadline); cancellation raises
FetchCancelled, an expired deadline the new FetchTimeout. get() and
exists() gained keyword-only parameters: subclasses that override them
should accept them (for example with **kw) and pass them on.
* Fetcher.download(url, out, max_bytes=..., expected_size=, expected_hashes=,
token=, deadline=) streams a body into a binary file object in chunks,
hashing it on the way (a failed write raises FetchError; out is not
flushed or closed), and returns a DownloadResult (size and hex
digests: every requested algorithm plus sha256). Nothing is written
before the status and headers are checked; max_bytes is enforced through
Content-Length and while streaming; a size or digest mismatch raises
HashMismatch (after writing: the caller discards the output). Retries
happen only before the first byte is written. Token, deadline, scope,
cancel() and the host policy apply as for get(); file: URLs work too.
* Fetcher refuses file: URLs that do not name a regular file (a FIFO or
device could block beyond any deadline); symlinks are followed.
* RepoClient.plan_binary() and RepoClient.plan_source() resolve a binary or
source package to a DownloadPlan of FileSpec items (name, URL, size and
the strongest listed hash) without downloading anything but indices: one
plan per architecture for architecture-specific packages, one plan for an
Architecture: all package listed in several per-arch indices (included
for any architecture filter; binary-all is read where Release offers
it), the newest version per target architecture, the .dsc first for
sources. RepoClient.group_packages() groups records into
PackageGroup items (one per suite, name, version and component, with
their architectures, Multi-Arch and per-architecture variants).
* RepoClient.search() gained keyword-only components=, architectures= and
kind= ("binary" or "source", which returns SourceRecord items) filters;
the old call form is unchanged.
* RepoClient.problems keeps the newest 1000 messages (problems_dropped
counts the others); problems_mark() and problems_since(mark) give the
messages one call added (problems is read-only for callers). The caches
and the problem list are safe to use from several threads. RepoClient(cache_budget_bytes=...) (default 512
MiB) bounds the cached parsed indices by an estimate (8 times their
decompressed size, 4 for Contents), dropping the least recently used ones; they are
downloaded again when needed.
* minideb -vv prints the traceback of an error after its one-line message,
and the warnings about malformed one-line sources.list entries have URL
credentials removed.
* Control data is split at LF only, like apt: one CR before an LF is
dropped, and a lone CR is no longer a line break (it stays in the value),
so a value cannot smuggle extra fields or paragraphs past apt's reading.
The same rule applies to checksum blocks, .dsc Package-List, deb md5sums,
one-line sources.list files and changelogs (form feeds, U+2028 and other
separators no longer end a line there). RepoClient records a malformed
index as a problem and goes on without it instead of raising ControlError.
* A malformed http_proxy/https_proxy setting is reported as "invalid proxy
setting (http_proxy/https_proxy)" instead of quoting it (with its
password), and the errors and warnings for malformed sources files have
URL credentials removed.
* RepoClient records a problem (once) for a malformed checksum field of a
Sources stanza, which SourceRecord.files then ignores, instead of only
logging a warning.
* RepoClient(max_index_bytes=...) bounds one decompressed index (default
1 GiB, as before), and fetch_index() with verification refuses an index
that Release lists as larger than the Fetcher's max_bytes before
requesting it. minideb mcp downloads at most 256 MiB per index and
accepts at most 512 MiB decompressed; one find_file call reads at most
an estimated 1 GiB of parsed Contents.
minideblib 0.7.0 (2026-11-01)
=============================
A rewrite for current Python and Debian archives. This release breaks
compatibility with 0.6.x.
Breaking changes
----------------
* Python 3.11 or later is required. Python 2 and older Python 3 versions are
no longer supported.
* Modules were renamed to snake_case under the minideblib package:
DpkgControl -> control, DpkgChangelog -> changelog, and so on. DpkgDatalist,
DpkgVarlist, OrderedDict and LoggableObject are gone; the standard
logging module and dict types are used instead.
* AptRepoClient is replaced by minideblib.repo.client.RepoClient, and
DpkgDebPackage by minideblib.deb.DebPackage. Both have new interfaces and
raise typed exceptions (FetchError, DebError, DscError, ...).
* DpkgVersion was reimplemented from the Debian Policy rules as
minideblib.version.Version (comparison with epochs, tildes and revisions).
VersionError messages quote at most 40 characters of an invalid version.
Parsing is permissive like dpkg (an upstream version may start with a
letter); Version(..., strict=True) and compare(..., strict=True) reject
an upstream version that does not start with a digit.
* signed.py (SignedFile, DebianSigVerifier, GPGSigVerifier) was removed.
Signature verification is not provided.
* The modules gpg, safewrite and utils and the ChangeFile class (with
FileEntry and ChangeFileError) were removed as unused. The .dsc and
checksum file verification moved to the new minideblib.checksums module
(parse_multiline_hashes, verify_file, ChecksumError).
* control and checksums are independent implementations. Malformed control
data raises control.ControlError (a ValueError) whose message starts with
"line N:"; one leading byte order mark is ignored, and CR, LF and CRLF end
lines for every kind of input, streams included.
* Checksum handling is stricter. The size column of a checksum block is an
optional "-" followed by 1 to 20 ASCII digits: "+5", "1_000", non-ASCII
digits and longer numbers are malformed. A backslash is no longer allowed
in a .dsc file name. verify_file() raises ChecksumError for an empty or
unknown algorithm list, reports OS errors during verification as the
caller's error type (DscError for Dsc.verify), and never follows a
symlink or blocks on a FIFO or device, even one swapped in after the
first check.
* Packaging moved from setup.py to pyproject.toml (hatchling); setup.py,
setup.cfg and the Python 2 files were removed.
New
---
* minideb command line tool: suites, components, archs, list, show, versions,
search, files, appstream, icons, source, dsc and deb commands, short aliases,
--json output, -v/-vv logging, --probe, global -c/-a scoping, and a
self-contained minideb.pyz. Exit status 1 means nothing found (show,
files, versions, source, suites, appstream --id/--package, deb field);
list and search exit with 0 on an empty result. Index records with an
invalid Version are skipped with a warning.
The pyz build honours SOURCE_DATE_EPOCH within the zip timestamp range
(1980-01-01 to 2107-12-31); other values stop the build with a one-line
error.
* -c/-a narrow the configured sources entries: with --sources, "list -c X"
for a suite whose entries do not list component X now gives an empty
result and a warning (previously X was queried anyway); use
"--url URL list -c X" to query a component that is not configured. A
scoped architecture that Release does not list is reported as "not listed
in Release" rather than as scoped away.
* Sources entries for the same URI and suite are merged; an entry without
components (or without an architecture restriction) keeps the merged
entry unrestricted, so "deb URI suite" plus "deb URI suite main" queries
every component listed in Release.
* Release-driven repository discovery: no directory listings are needed,
suites containing "/" work, and file hashes from Release are verified.
SHA256 or stronger is required: indices or .dsc files listed only with
MD5/SHA-1 are rejected unless verification is turned off (--no-verify).
* Fetching refuses https -> http redirects, credentials in URLs (also in
redirect targets) and ".." components in file:// URLs (also
percent-encoded).
* Repository paths from Release, Packages (Filename) and Sources
(Directory, file names) and suite names are checked before a URL is
built: a ".." segment, a leading "/", a backslash or NUL is refused also
when percent-encoded (repeatedly decoded, e.g. %2e%2e or %252e%252e), and
so are encoded separators (%2f, %5c, %00). Other escapes such as %2B or
%3a stay valid. An unsafe or empty suite raises ReleaseError (naming at
most 40 characters of it) without any request; sources entries are
checked when used, not when parsed.
* deb822 .sources files and one-line sources.list entries. One-line
entries may separate their fields with any mix of spaces and tabs (also
around the [options] block).
* Acquire-By-Hash and flat repositories.
* Packages, Sources and Contents indices; DEP-11 AppStream metadata and icons
(optional PyYAML).
A Contents line is split into path and location on spaces and tabs
only; other whitespace (U+00A0, form feed, ...) belongs to the path.
* Source packages: .dsc parsing, hash-checked download and verification.
SourceRecord.files lists each file with the strongest hash the Sources
stanza gives for it (Checksums-Sha512, -Sha256, -Sha1, then Files), the
same order fetch_dsc verifies in.
* Compression: gzip, bzip2, xz, lzma and zstd (native on Python 3.14+,
otherwise the optional zstandard).
The output size limit (max_size) also applies to uncompressed data.
gzip input must contain at least one complete member: empty or zero-only
data and a truncated first member raise DecompressError; zero padding
after a complete member is still ignored.
The xz/lzma decoder runs with a memory limit (max_size clamped to
128 MiB .. 1 GiB): a stream whose header asks for a larger dictionary
raises DecompressionLimitError instead of allocating it.
* Safe .deb extraction (path, link and size checks) and a dpkg-deb style
subset: -I, -e, -c, -x, -f.
An ar archive whose odd-sized last member lacks its padding byte is
rejected as truncated (ArError).
The debian-binary member must hold format 2.x (any minor version);
other formats and malformed content raise DebError.
"minideb deb ctrl", "minideb deb extract" and DebPackage.extract() refuse
a destination directory that is a symlink; "deb ctrl" does not follow
symlinks below it (a symlinked file or directory is refused) and replaces
existing regular files instead of writing into them. Only the last
component of the destination is checked: symlinks in the directories
leading to it are followed (they are the caller's choice).
DebPackage.extract() resolves relative symlink targets up front, following
the archive's own symlinks, and rejects a link that would point outside
the destination before anything is written.
* minideblib.MinidebError, the common base class of the exceptions the
library raises for bad data: malformed control data, indices, Release,
changelogs (changelog.ChangelogError), sources files
(sources.SourcesError, also for a file that is not valid UTF-8), .deb and
.dsc files, versions, compressed data and DEP-11 YAML, unusable index
records (repo.client.RepoError), failed downloads and hash checks. The
concrete classes keep their other bases such as ValueError;
DebPackage.read() raises deb.MissingMemberError, a DebError and KeyError.
Not covered: programmer errors (wrong argument types, an unknown probe
set or index kind), OSError from local file access, KeyError for a
missing Paragraph field and errors raised by caller-supplied objects.
* Type annotations and py.typed; runnable examples in examples/.
* Native Debian packaging, an RPM spec for Fedora and openSUSE, a man page, CI
and tag-driven releases. The workflows pin every action to a commit SHA;
Dependabot proposes weekly pin updates.
Fixed
-----
Issues of the old GitHub tracker:
* #1 DpkgSourceControl choked on DOS newlines: control files with CRLF line
endings are parsed (regression test).
* #2 DpkgParagraph.load() truncated the last character of every line: fixed
(regression test).
* #3 multi-line fields such as Binary are now available as folded text or
lists via Paragraph.get_folded() / get_list(); covered by the .dsc
wrapped-Binary tests.
* #4 network errors are retried: Fetcher retries transient failures
(timeouts, 5xx, 429, truncated bodies) with backoff and keeps the last
status in FetchError (regression tests). Fetcher.cancel() stops the
retries of the requests in progress (they raise FetchCancelled, a
FetchError); the backoff waits are interruptible.
* Backoff waits are controlled with Fetcher(sleep=...) and Fetcher.cancel();
patching time.sleep no longer has an effect.
* Ctrl-C while RepoClient.suites() probes suites returns at once: probes run
on daemon threads, queued probes are dropped and in-flight retries are
cancelled, so neither the call nor interpreter exit waits for them.
Known limitations
-----------------
* The Release/InRelease signature is not verified; only the hashes listed in
Release are checked. See TODO.md.
* DebPackage.extract() and "minideb deb extract" refuse symlinks with an
absolute target (fail closed), so many real packages are refused by
default. skip_absolute_symlinks=True / --skip-absolute-symlinks leaves
such links out (one warning each) and extracts the rest; other unsafe
members, and hard links to a skipped symlink, are still refused. Hard
links must point to an earlier regular member and member mtimes must be
finite and in [0, 2**37); DebPackage.files() and "minideb deb ls" list an
invalid mtime as 0.
Older releases
--------------
See debian/changelog for the history of the 0.6.x series.