Add protected Terraform provisioning workflows #85

Merged
gitchegumi merged 4 commits from kiyi/terraform-delivery into main 2026-10-11 20:48:58 -05:00
Member

Add protected Terraform provisioning for external-service prerequisites, with Gitchistry dev as the first independently constrained stack. The owning callers are in terraform-modules#2.

The workflow supports public OIDC claim inspection, private/versioned/SSE-S3 state-bucket bootstrap with encrypted probe readback, and separate OpenBao plan/apply identities. Apply requires the reviewed source commit and semantic plan fingerprint, rejects deletion/replacement and unexpected resources, and verifies convergence, dev object access and runtime secret consistency. Raw state, plans and provider diagnostics stay private; emergency backend state is preserved in OpenBao where possible.

CLI downloads use a TLS-verifying HTTPS-only handler chain for the fixed HashiCorp origin, strict numeric versions, no redirects, bounded archives and checksum verification before extraction. S3 XML uses hash-locked defusedxml with DTDs/entities/external references rejected. The protected workflow installs its small pinned Python runtime in a job-local environment. No scan suppressions or mitigations were added.

Release dependency: publish proposed immutable v1.33.0 after review and merge. Published v1.32.0 contains dev delivery/cleanup and does not contain Terraform provisioning. This branch includes that released main baseline. All three companion shared callers (source security, state bootstrap and dev provisioning) pin v1.33.0 with matching uses/library_ref; their security/provisioning operations must wait for publication.

Validation: 58 local Terraform, credential and Forgejo contract tests passed, including TLS/checksum verification, URL injection, redirect refusal and malicious XML rejection for every parsed S3 field. Across the library and companion repository, all 24 workflow YAML files and 67 shell bodies passed checks, and all three shared caller pins match. Hosted security checks must verify the new head. No live credentials, resource APIs, real plan/apply or local container builds were used.

First use remains blocked on key-manager/state setup, exact OIDC roles/scoped credentials and verified bounded own-parent AIStor key authorization. The owner confirmed state storage and KMS are not set up. This PR does not activate shared-service encryption or deploy Harbor. Tracking: terraform-modules#1.

Add protected Terraform provisioning for external-service prerequisites, with Gitchistry dev as the first independently constrained stack. The owning callers are in [terraform-modules#2](https://git.gitchegumi.com/Homelab/terraform-modules/pulls/2). The workflow supports public OIDC claim inspection, private/versioned/SSE-S3 state-bucket bootstrap with encrypted probe readback, and separate OpenBao plan/apply identities. Apply requires the reviewed source commit and semantic plan fingerprint, rejects deletion/replacement and unexpected resources, and verifies convergence, dev object access and runtime secret consistency. Raw state, plans and provider diagnostics stay private; emergency backend state is preserved in OpenBao where possible. CLI downloads use a TLS-verifying HTTPS-only handler chain for the fixed HashiCorp origin, strict numeric versions, no redirects, bounded archives and checksum verification before extraction. S3 XML uses hash-locked defusedxml with DTDs/entities/external references rejected. The protected workflow installs its small pinned Python runtime in a job-local environment. No scan suppressions or mitigations were added. Release dependency: publish proposed immutable v1.33.0 after review and merge. [Published v1.32.0](https://git.gitchegumi.com/Homelab/workflows/releases/tag/v1.32.0) contains dev delivery/cleanup and does not contain Terraform provisioning. This branch includes that released main baseline. All three companion shared callers (source security, state bootstrap and dev provisioning) pin v1.33.0 with matching uses/library_ref; their security/provisioning operations must wait for publication. Validation: 58 local Terraform, credential and Forgejo contract tests passed, including TLS/checksum verification, URL injection, redirect refusal and malicious XML rejection for every parsed S3 field. Across the library and companion repository, all 24 workflow YAML files and 67 shell bodies passed checks, and all three shared caller pins match. Hosted security checks must verify the new head. No live credentials, resource APIs, real plan/apply or local container builds were used. First use remains blocked on key-manager/state setup, exact OIDC roles/scoped credentials and verified bounded own-parent AIStor key authorization. The owner confirmed state storage and KMS are not set up. This PR does not activate shared-service encryption or deploy Harbor. Tracking: [terraform-modules#1](https://git.gitchegumi.com/Homelab/terraform-modules/issues/1).
Add protected Terraform provisioning workflows
Some checks failed
Workflow acceptance / acceptance (pull_request) Successful in 1m43s
Library checks / tests (pull_request) Failing after 6m48s
Repository security / security-1 (pull_request) Failing after 7m34s
4e0301d7c3
Author
Member

Companion module and owning workflow callers are ready in terraform-modules#2. Those provisioning callers pin the proposed v1.32.0 release and remain blocked until this library change is reviewed, merged and released.

Companion module and owning workflow callers are ready in [terraform-modules#2](https://git.gitchegumi.com/Homelab/terraform-modules/pulls/2). Those provisioning callers pin the proposed v1.32.0 release and remain blocked until this library change is reviewed, merged and released.
Verify encrypted state bootstrap probe readback
Some checks failed
Workflow acceptance / acceptance (pull_request) Successful in 3m15s
Repository security / security-1 (pull_request) Failing after 2m37s
Library checks / tests (pull_request) Failing after 2m20s
0dd9297f89
Author
Member

Commit 0dd9297f89 strengthens initial state bootstrap: after checking encryption/version metadata and conditional writes, it reads the encrypted probe back and requires an exact match. Three new credential-free tests cover a missing bucket, absent KMS and unreadable/corrupt probe data. All 43 Terraform/workflow credential tests pass locally; diff checks pass. The owner confirmed no state bucket or AIStor KMS is configured. Key-manager installation/recovery must be reviewed separately before this bucket workflow runs; the first-time guide records the order and shared-server impact. No live provisioning was dispatched.

Commit 0dd9297f896101c5f59f7d688e998f6bc6b624b5 strengthens initial state bootstrap: after checking encryption/version metadata and conditional writes, it reads the encrypted probe back and requires an exact match. Three new credential-free tests cover a missing bucket, absent KMS and unreadable/corrupt probe data. All 43 Terraform/workflow credential tests pass locally; diff checks pass. The owner confirmed no state bucket or AIStor KMS is configured. Key-manager installation/recovery must be reviewed separately before this bucket workflow runs; [the first-time guide](https://git.gitchegumi.com/Homelab/terraform-modules/src/commit/12f9d0e394c280edd1754a549c8a6b55465e8cde/docs/state-bootstrap.md) records the order and shared-server impact. No live provisioning was dispatched.
Merge workflows v1.32.0 baseline and target Terraform v1.33.0
Some checks failed
Workflow acceptance / acceptance (pull_request) Successful in 1m29s
Repository security / security-1 (pull_request) Failing after 2m12s
Library checks / tests (pull_request) Successful in 3m29s
f58780a9e4
Author
Member

Release collision addressed in f58780a9e4: merged the published v1.32.0 main baseline, changed the proposed Terraform release to v1.33.0 and updated the explicit Terraform runner contract. Companion terraform-modules commit 6e3c2c68ef903ccb629fea1b05db16ffb759d130 updates both uses/library_ref pairs and setup docs in PR #2. Both PR descriptions now distinguish published v1.32.0 from proposed v1.33.0. Validation: 76 local targeted tests passed, all 24 workflow YAML files parse, caller pins match and diff checks pass. No release was republished or provisioning dispatched.

Release collision addressed in f58780a9e4c9b74f4172c18afa3483ea85560798: merged the published v1.32.0 main baseline, changed the proposed Terraform release to v1.33.0 and updated the explicit Terraform runner contract. Companion terraform-modules commit 6e3c2c68ef903ccb629fea1b05db16ffb759d130 updates both uses/library_ref pairs and setup docs in PR #2. Both PR descriptions now distinguish published v1.32.0 from proposed v1.33.0. Validation: 76 local targeted tests passed, all 24 workflow YAML files parse, caller pins match and diff checks pass. No release was republished or provisioning dispatched.
gitchegumi requested changes 2026-10-11 19:56:50 -05:00
Dismissed
gitchegumi left a comment

Resolve semgrep findings.

Resolve semgrep findings.
Harden Terraform downloads and S3 XML parsing
All checks were successful
Workflow acceptance / acceptance (pull_request) Successful in 2m0s
Repository security / security-1 (pull_request) Successful in 4m55s
Library checks / tests (pull_request) Successful in 5m4s
5a8d3df6a8
Author
Member

Addressed the Semgrep change request in 5a8d3df6a8.

  • python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected in pipeline/terraform_delivery.py: the CLI downloader now installs only a TLS-verifying HTTPS handler for the fixed HashiCorp origin, accepts only numeric release versions, refuses redirects/other schemes, bounds the archive and verifies the pinned checksum before extraction.
  • python.lang.security.use-defused-xml.use-defused-xml in pipeline/terraform_s3.py: every S3 XML response now uses hash-locked defusedxml with DTDs, entities and external references forbidden. The protected workflow installs its small pinned runtime in a job-local environment.

Validation: 58 local Terraform/credential/Forgejo contract tests passed. New regressions exercise trusted TLS, checksum rejection before extraction, URL injection, all five redirect statuses to file/HTTP/foreign HTTPS destinations, and malicious XML in every parsed S3 field. All 24 workflow YAML files and 67 shell bodies across the library/caller repositories passed syntax checks. No scan suppressions or mitigations were added. Hosted security checks must confirm the new head; no live provisioning was run.

The companion Terraform PR now pins source security, bootstrap and provisioning uniformly to proposed v1.33.0. That release must be published before its security caller can run.

Addressed [the Semgrep change request](https://git.gitchegumi.com/Homelab/workflows/pulls/85#issuecomment-5592) in 5a8d3df6a8cd2c032bd2ec6044d379269ed0099f. - `python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected` in `pipeline/terraform_delivery.py`: the CLI downloader now installs only a TLS-verifying HTTPS handler for the fixed HashiCorp origin, accepts only numeric release versions, refuses redirects/other schemes, bounds the archive and verifies the pinned checksum before extraction. - `python.lang.security.use-defused-xml.use-defused-xml` in `pipeline/terraform_s3.py`: every S3 XML response now uses hash-locked defusedxml with DTDs, entities and external references forbidden. The protected workflow installs its small pinned runtime in a job-local environment. Validation: 58 local Terraform/credential/Forgejo contract tests passed. New regressions exercise trusted TLS, checksum rejection before extraction, URL injection, all five redirect statuses to file/HTTP/foreign HTTPS destinations, and malicious XML in every parsed S3 field. All 24 workflow YAML files and 67 shell bodies across the library/caller repositories passed syntax checks. No scan suppressions or mitigations were added. Hosted security checks must confirm the new head; no live provisioning was run. The companion Terraform PR now pins source security, bootstrap and provisioning uniformly to proposed v1.33.0. That release must be published before its security caller can run.
gitchegumi approved these changes 2026-10-11 20:48:54 -05:00
gitchegumi deleted branch kiyi/terraform-delivery 2026-10-11 20:48:59 -05:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Homelab/workflows!85
No description provided.