iz
Clone
https://git.tahinli.com/Tahinli/iz.git
0 watching0 forksRustAGPL-3.0567.3 KiB3950aceTahinli27 days ago34 commits
| 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. |
| 5 | pub const TITLE_MAX: usize = 200; |
| 6 | /// Longest task description, in characters. Reason: keeps one row and one page render bounded. |
| 7 | pub const DESCRIPTION_MAX: usize = 20_000; |
| 8 | /// Longest comment body, in characters. Reason: comments are conversation, not documents. |
| 9 | pub const COMMENT_MAX: usize = 10_000; |
| 10 | /// Longest tag (project) name, in characters. Reason: tags are shown as chips on every card. |
| 11 | pub const TAG_NAME_MAX: usize = 60; |
| 12 | /// Longest column name, in characters. Reason: column headings must fit the board width. |
| 13 | pub const COLUMN_NAME_MAX: usize = 60; |
| 14 | /// Longest mail rule name or subject template, in characters. Reason: mail subjects stay short. |
| 15 | pub const RULE_SUBJECT_MAX: usize = 120; |
| 16 | /// Longest mail subject for notices and reminders, in characters. Reason: the mail client truncates later. |
| 17 | pub const MESSAGE_SUBJECT_MAX: usize = 200; |
| 18 | /// Longest mail body for notices, in characters. Reason: bounds the outbox row size. |
| 19 | pub const MESSAGE_BODY_MAX: usize = 20_000; |
| 20 | /// Longest display name, in characters. Reason: names are shown in assignee lists and mail greetings. |
| 21 | pub const DISPLAY_NAME_MAX: usize = 100; |
| 22 | /// Longest attachment file name, in bytes. Reason: matches the common filesystem limit. |
| 23 | pub const FILE_NAME_MAX: usize = 255; |
| 24 | /// Smallest per-file attachment limit an admin may set, in MiB. Reason: zero would refuse every upload. |
| 25 | pub 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. |
| 27 | pub 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. |
| 29 | pub const REMINDER_MINUTES_MAX: u32 = 1440; |
| 30 | /// Largest mail batching window, in minutes. Reason: longer quiet windows delay mail past usefulness. |
| 31 | pub 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. |
| 33 | pub 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. |
| 36 | pub 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. |
| 38 | pub const UPLOAD_FILES_MAX: usize = 10; |
| 39 | /// Leading bytes of an upload that the sniffer reads. Reason: enough for every signature it knows. |
| 40 | pub 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. |
| 42 | pub 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. |
| 44 | pub 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. |
| 47 | pub 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. |
| 49 | pub 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. |
| 52 | pub 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. |
| 54 | pub 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. |
| 57 | pub 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. |
| 59 | pub const SHEETS_MAX: usize = 20; |
| 60 | /// Most rows a sheet preview shows. Reason: keeps one page render bounded. |
| 61 | pub const SHEET_ROWS_MAX: usize = 1000; |
| 62 | /// Most columns a sheet preview shows. Reason: wider tables do not fit the viewer width anyway. |
| 63 | pub const SHEET_COLS_MAX: usize = 100; |
| 64 | /// Longest cell text a sheet preview shows, in characters. Reason: one cell must not fill the page. |
| 65 | pub const CELL_TEXT_MAX: usize = 1000; |
| 66 | /// Most slides a deck preview lists. Reason: bounds the XML parsed from one request. |
| 67 | pub 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. |
| 69 | pub 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. |
| 71 | pub 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. |
| 74 | pub const MAIL_SUBJECT_MAX: usize = 200; |
| 75 | /// Longest sender display name, in characters. Reason: a mail client shows only the start of it. |
| 76 | pub const SENDER_NAME_MAX: usize = 100; |
| 77 | /// Longest host name of the mail server, in characters (DNS limit). |
| 78 | pub const SENDER_HOST_MAX: usize = 253; |
| 79 | /// Longest SMTP user name, in characters. Reason: long enough for an address, short enough to store. |
| 80 | pub const SMTP_USERNAME_MAX: usize = 254; |
| 81 | /// Longest SMTP password, in characters. Reason: a generous bound for a stored secret. |
| 82 | pub 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. |
| 84 | pub const REMINDER_CAP_MAX: u32 = 500; |