|
certbotbot
Reference documentation for a modular Bash project
|
Applies ADR-034 retention only to fully proven managed S3 copies. More...
Functions | |
| int | certbotbot_retention_error (String status, String message) |
| Emit a fixed retention-stage diagnostic. | |
| int | certbotbot_retention_date_valid (String date) |
| Validate a candidate eight-digit Gregorian UTC date without clock IO. | |
| int | certbotbot_retention_preflight () |
| Validate destructive scope and AWS CLI capabilities before S3 IO. | |
| int | certbotbot_retention_apply (String workspace, String bucket, String current) |
| Validate complete listing, HEAD all matches, then conditionally prune. | |
Applies ADR-034 retention only to fully proven managed S3 copies.
This implementation has no scheduled or automatic deletion authority. A positive, separately validated count opts into conditional deletion only following an acknowledged current PUT and a confirmed dated-backup PUT. Enumerating an entire S3 bucket, adopting an old template, deleting the current key, and deleting version IDs are explicitly forbidden.
ListObjectsV2 uses fixed JMESPath to encode one page into a bounded scalar line with explicit fields. URL-encoded keys containing any percent-escape are rejected instead of decoded, preventing unsafe delimiters in Bash. Every listed candidate is structurally checked, then independently HEAD verified before a single deletion is issued. Metadata and S3 ETags do not authenticate a writer; externally coordinated IAM permissions remain a required boundary. This module never logs raw S3 output or object keys.
| int certbotbot_retention_apply | ( | String | workspace, |
| String | bucket, | ||
| String | current | ||
| ) |
Validate complete listing, HEAD all matches, then conditionally prune.
The existing AWS CLI renders one JMESPath scalar with five separators: truncated | token | page key count | encoding | prefix | comma keys. Requesting URL encoding ensures troublesome delimiter characters inside S3 keys are percent-encoded. Such keys fail the entire preflight, rather than being unescaped, split or accidentally adopted. A fixed query, explicit –no-paginate, strict schema, token-cycle detection and byte limits prevent incomplete or ambiguous pages from leading to deletion.
After the entire listing is checked, verify every exact date-shaped key through an independent managed v1 HeadObject, retaining its ETag. Sort verified copies by name-encoded UTC date, preserve newest N and this invocation's confirmed backup, and delete provisional old keys oldest first using the captured ETag as an S3 IfMatch precondition. An accepted DeleteObject must subsequently be confirmed absent by exact-key HEAD. Any uncertain result stops further mutation with no rollback.
| workspace | Caller-owned absolute private mode-0700 workspace. |
| bucket | Existing selected S3 bucket; never list globally. |
| current | Frozen exact authoritative key, protected from deletion. |
| 0 | No retention requested, or full guarded cleanup succeeded. |
| 74 | After current/backup confirmed, cleanup failed or is uncertain. |
| int certbotbot_retention_date_valid | ( | String | date | ) |
Validate a candidate eight-digit Gregorian UTC date without clock IO.
| date | Eight byte YYYYMMDD string from an untrusted S3 key. |
| 0 | The date is Gregorian-valid, including leap years. |
| 1 | The date is incomplete, nondecimal or impossible. |
| int certbotbot_retention_error | ( | String | status, |
| String | message | ||
| ) |
Emit a fixed retention-stage diagnostic.
| status | Defined nonzero exit status, 64 or 74. |
| message | Static error description without untrusted object data. |
| 64 | Invalid retention configuration before remote work. |
| 74 | Current/backup confirmed but retention failed or is uncertain. |
| int certbotbot_retention_preflight | ( | ) |
Validate destructive scope and AWS CLI capabilities before S3 IO.
A count of zero does nothing. Positive retention requires a single contiguous {YEAR}{MONTH}{DOM}, a >=4 byte anchored literal prefix ending in - or _, and a single literal safe tar.gz suffix. Filename publication under ADR-032 intentionally permits a wider template set; that freedom does not grant the right to enumerate or delete old objects. The exact selected date/name must match this namespace and be different from the authoritative current key. AWS skeleton feature probes are local: unsupported conditional deletion fails before any S3 read or write.
| 0 | A zero count or bounded eligible namespace. |
| 64 | Invalid count, template, backend or CLI capabilities. |