forge
Explore
Log in

Don't you dare go Hollow

iz

Clone
★ 0

0 watching0 forksRustAGPL-3.0567.3 KiB3950aceTahinli27 days ago34 commits

limits.rs84 lines, 5.8 KiBHistoryRawDownload
1//! Every text and size limit in iz, as named constants. Length limits count characters (Unicode
2//! scalar values) and are enforced on the server, never only in the HTML form.
3
4/// Longest task title, in characters. Reason: a title is a card heading; longer text is a description.
5pub const TITLE_MAX: usize = 200;
6/// Longest task description, in characters. Reason: keeps one row and one page render bounded.
7pub const DESCRIPTION_MAX: usize = 20_000;
8/// Longest comment body, in characters. Reason: comments are conversation, not documents.
9pub const COMMENT_MAX: usize = 10_000;
10/// Longest tag (project) name, in characters. Reason: tags are shown as chips on every card.
11pub const TAG_NAME_MAX: usize = 60;
12/// Longest column name, in characters. Reason: column headings must fit the board width.
13pub const COLUMN_NAME_MAX: usize = 60;
14/// Longest mail rule name or subject template, in characters. Reason: mail subjects stay short.
15pub const RULE_SUBJECT_MAX: usize = 120;
16/// Longest mail subject for notices and reminders, in characters. Reason: the mail client truncates later.
17pub const MESSAGE_SUBJECT_MAX: usize = 200;
18/// Longest mail body for notices, in characters. Reason: bounds the outbox row size.
19pub const MESSAGE_BODY_MAX: usize = 20_000;
20/// Longest display name, in characters. Reason: names are shown in assignee lists and mail greetings.
21pub const DISPLAY_NAME_MAX: usize = 100;
22/// Longest attachment file name, in bytes. Reason: matches the common filesystem limit.
23pub const FILE_NAME_MAX: usize = 255;
24/// Smallest per-file attachment limit an admin may set, in MiB. Reason: zero would refuse every upload.
25pub const ATTACHMENT_LIMIT_MIB_MIN: u32 = 1;
26/// Largest per-file attachment limit an admin may set, in MiB. Reason: bounds disk use per upload.
27pub const ATTACHMENT_LIMIT_MIB_MAX: u32 = 500;
28/// Largest reminder lead time, in minutes (one day). Reason: a reminder further ahead is not a reminder.
29pub const REMINDER_MINUTES_MAX: u32 = 1440;
30/// Largest mail batching window, in minutes. Reason: longer quiet windows delay mail past usefulness.
31pub const BATCH_MINUTES_MAX: u32 = 120;
32/// Default per-file attachment limit, in MiB. Reason: the starting value of the setting; an admin raises it.
33pub const ATTACHMENT_DEFAULT_MIB: u32 = 100;
34/// Total size of the attachments of one board when the setting was never saved, in bytes. Reason: the
35/// disk is shared with the database and the backups; an admin raises it deliberately.
36pub const ATTACHMENT_TOTAL_DEFAULT_BYTES: u64 = 20 * 1024 * 1024 * 1024;
37/// Most file parts one upload request may carry. Reason: bounds the work one form can cause.
38pub const UPLOAD_FILES_MAX: usize = 10;
39/// Leading bytes of an upload that the sniffer reads. Reason: enough for every signature it knows.
40pub const SNIFF_BYTES: usize = 8192;
41/// Bytes of a text file the text viewer shows. Reason: a preview, not a reader; the rest is one download away.
42pub const TEXT_PREVIEW_BYTES: u64 = 256 * 1024;
43/// Largest compressed spreadsheet or CSV the viewer parses, in bytes. Reason: bounds the work of one preview.
44pub const SHEET_INPUT_MAX_BYTES: u64 = 5 * 1024 * 1024;
45/// Most cells one `.xlsx` sheet preview visits, kept or not. Reason: bounds the work on a sheet with a huge
46/// used range, whatever the caps keep.
47pub const SHEET_VISITS_MAX: usize = 200_000;
48/// Largest compressed slide deck the viewer parses, in bytes. Reason: decks carry pictures, so the cap is higher.
49pub const SLIDES_INPUT_MAX_BYTES: u64 = 20 * 1024 * 1024;
50/// Largest total uncompressed size of a zip container the viewers read, in bytes. Reason: a zip bomb is
51/// refused before parsing; real workbooks and decks are far below this.
52pub const ARCHIVE_UNCOMPRESSED_MAX_BYTES: u64 = 50 * 1024 * 1024;
53/// Largest uncompressed-to-compressed ratio of a zip container. Reason: zip bombs compress to almost nothing.
54pub const ARCHIVE_RATIO_MAX: u64 = 100;
55/// Uncompressed size below which the ratio is not judged, in bytes. Reason: small parts compress badly
56/// without being hostile, and the total size limit still applies to them.
57pub const ARCHIVE_RATIO_FLOOR_BYTES: u64 = 1024 * 1024;
58/// Most sheets a workbook preview shows. Reason: a preview of every tab of a large workbook is a document dump.
59pub const SHEETS_MAX: usize = 20;
60/// Most rows a sheet preview shows. Reason: keeps one page render bounded.
61pub const SHEET_ROWS_MAX: usize = 1000;
62/// Most columns a sheet preview shows. Reason: wider tables do not fit the viewer width anyway.
63pub const SHEET_COLS_MAX: usize = 100;
64/// Longest cell text a sheet preview shows, in characters. Reason: one cell must not fill the page.
65pub const CELL_TEXT_MAX: usize = 1000;
66/// Most slides a deck preview lists. Reason: bounds the XML parsed from one request.
67pub const SLIDES_MAX: usize = 200;
68/// Longest text of one slide shown, in characters. Reason: a slide's text is a summary, not a transcript.
69pub const SLIDE_TEXT_MAX: usize = 4000;
70/// Largest XML part of a deck that is read, in bytes. Reason: a single slide is far below this.
71pub const DECK_PART_MAX_BYTES: u64 = 4 * 1024 * 1024;
72
73/// Longest mail subject after rendering, in characters. Reason: header lines stay short and readable.
74pub const MAIL_SUBJECT_MAX: usize = 200;
75/// Longest sender display name, in characters. Reason: a mail client shows only the start of it.
76pub const SENDER_NAME_MAX: usize = 100;
77/// Longest host name of the mail server, in characters (DNS limit).
78pub const SENDER_HOST_MAX: usize = 253;
79/// Longest SMTP user name, in characters. Reason: long enough for an address, short enough to store.
80pub const SMTP_USERNAME_MAX: usize = 254;
81/// Longest SMTP password, in characters. Reason: a generous bound for a stored secret.
82pub const SMTP_PASSWORD_MAX: usize = 512;
83/// Highest reminder cap a member can be given, in mails per hour. Reason: above this the cap is no guard.
84pub const REMINDER_CAP_MAX: u32 = 500;