check / check (push) Canceled after 0s
`mfer version`, `mfer --version` and the banner print the revision the build stamps into main.Gitrev or, when it stamped none (as after `go install` of a tag), the main module's version from runtime/debug.ReadBuildInfo. The banner no longer shows a release date. mfer.Version and mfer.ReleaseDate go, with main.Version and the version field and parameter in internal/cli that nothing read. A program using the library reads the module version from its own build information. The README says where the version comes from. Judgement call: a binary with no build information, or none holding a module version, prints "unknown", the word script/build already uses when git describe gives nothing. Model: opus-5-5
46 lines
1.8 KiB
Go
46 lines
1.8 KiB
Go
package mfer
|
|
|
|
const (
|
|
// MaxDecompressedSize is the maximum allowed size of decompressed manifest
|
|
// data (256 MiB). This prevents decompression bombs from consuming excessive
|
|
// memory.
|
|
MaxDecompressedSize int64 = 256 * 1024 * 1024
|
|
|
|
// MaxManifestSize is the largest manifest file mfer reads (258 MiB).
|
|
// zstd's worst case grows data it cannot compress by 1/256, so an inner
|
|
// message of MaxDecompressedSize compresses to at most 257 MiB; the
|
|
// last MiB is room for the signature, the signing key and the other
|
|
// outer fields.
|
|
MaxManifestSize = MaxDecompressedSize + MaxDecompressedSize/256 + 1<<20
|
|
|
|
// zstdWindowSize is the zstd window zstd.SpeedBestCompression gives mfer's writer.
|
|
zstdWindowSize = 8 << 20
|
|
|
|
// uuidLength is the length in bytes of a binary UUID.
|
|
uuidLength = 16
|
|
|
|
// Numbers in mf.proto of MFFile.files and of the MFFilePath fields
|
|
// that decoding sets aside a fixed amount of memory for.
|
|
filesFieldNumber = 101
|
|
hashesFieldNumber = 3
|
|
mimeTypeFieldNumber = 301
|
|
mtimeFieldNumber = 302
|
|
ctimeFieldNumber = 303
|
|
|
|
// Bytes decoding sets aside for each file entry, hash, timestamp and
|
|
// MIME type, however short its encoding. checkDecodedSize refuses an
|
|
// inner message for which these add up to more than maxDecodedGrowth
|
|
// times its size. The mode is held in the file entry itself.
|
|
decodedFileEntrySize = 176
|
|
decodedHashSize = 112
|
|
decodedTimestampSize = 64
|
|
decodedMIMETypeSize = 16
|
|
|
|
// Each file entry mfer writes holds a path of at least one byte, a
|
|
// multihash at least as long as SHA-256's 34 bytes (AddFileWithHash
|
|
// refuses shorter ones) and a modification time: at least 47 bytes,
|
|
// counted at 352. So its manifests add up to at most about 7.49 times
|
|
// their size, and this limit is about 7% above that.
|
|
maxDecodedGrowth = 8
|
|
)
|