fix: validate Content-Length + add paste expiry/TTL #3
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
security
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: SheWhoReignsSupreme/forge-paste#3
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/content-length-and-paste-ttl"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes both open issues (#1 and #2) in a single PR.
🔒 Issue #2 — Content-Length validation (security)
Problem:
do_POSTreadsContent-Lengthasint()without validation. A negative value (Content-Length: -1) causesrfile.read(-1)to read until EOF, hanging the server thread indefinitely.Fix:
Content-Lengthvalues with400 Bad RequestValueError)⏰ Issue #1 — Paste expiry / TTL
Problem: Pastes are stored forever with no cleanup mechanism. Database grows indefinitely.
Fix:
expires_atcolumn on thepastestable--max-age DAYSCLI flag orFORGE_PASTE_MAX_AGEenv var)--max-age 0disables expiry entirelyConfiguration
--max-age 7FORGE_PASTE_MAX_AGE=90--max-age 0Changes
forge-paste.py— +68/-8 linesdo_POST: Content-Length validationinit_db: newexpires_atcolumn + migrationcreate_paste: sets expiry, triggers cleanupget_paste: filters out expired pastescleanup_expired(): new function, deletes expired rows + WAL checkpointpage_viewer: shows expiry infomain(): new--max-ageargumentCloses #1
Closes #2