F-002 fix: Remove secrets and externalize config

This commit is contained in:
rikrdo
2026-05-25 08:00:05 +02:00
parent d3a558352d
commit 3d41579ad3
58 changed files with 1192807 additions and 52 deletions

View File

@@ -0,0 +1,28 @@
# Architect Artefact — Feature: F-002
## SDD Changes
- Added `spec/sdd/components/legacy-config-loader.md`
- Added `spec/sdd/decisions/002-use-local-config-loader-for-legacy-module.md`
- Extended product, tech, and acceptance specs for F-002
## BDD Coverage
- Added `spec/bdd/features/config/legacy-config.feature`
- Coverage target:
- no tracked secrets in PHP files
- one shared config helper
- documented local config setup
## Technical decisions
- Use module-root `bootstrap.php` as one config entry point.
- Use ignored `config/local.php` for real local values.
- Use versioned `config/local.example.php` for safe shape and defaults.
- Share one mysqli helper across web pages and worker.
## Risks found
- Example config will not make app fully runnable until maintainer fills local values.
- Legacy logs remain under web tree for now.
## Next step
- Implement bootstrap and config files.
- Replace inline secrets and URLs in tracked PHP files.
- Run verify and secret scan.

View File

@@ -0,0 +1,27 @@
# Documenter Artefact — Feature: F-002
## What changed
- Added one shared config loader at `project/web/index/new/bootstrap.php`.
- Added versioned config template at `project/web/index/new/config/local.example.php`.
- Added local setup notes at `project/web/index/new/config/README.md`.
- Ignored real local config file `project/web/index/new/config/local.php`.
- Updated legacy PHP entry points to use shared config lookups.
## Important files
- `project/web/index/new/bootstrap.php`
- `project/web/index/new/config/local.example.php`
- `project/web/index/new/config/README.md`
- `project/web/index/new/db/conn.php`
- `project/web/index/new/inc/header.php`
- `project/web/index/new/index.php`
- `project/web/index/new/describe.php`
- `project/web/index/new/productos_bulk_update.php`
- `project/web/index/new/productos_modificados.php`
- `project/web/index/new/worker_bulk.php`
## Local setup note
Copy or edit `project/web/index/new/config/local.php` with real local values before running the module.
## Follow-up
- Review the SQL dump for sensitive data and retention policy.
- Consider moving runtime logs out of the web tree.

View File

@@ -0,0 +1,35 @@
# Implementer Artefact — Feature: F-002
## Summary
Added one shared config loader for the legacy PHP module.
Moved DB, OpenAI, and route values out of tracked PHP source files.
Added versioned config template and ignored local config file path.
Updated docs and specs for local setup.
## Code changes
- added `project/web/index/new/bootstrap.php`
- added `project/web/index/new/config/local.example.php`
- added `project/web/index/new/config/README.md`
- added `project/web/index/new/README.md`
- updated `.gitignore` to ignore `project/web/index/new/config/local.php`
- updated PHP entry points to use `legacy_config()` and `legacy_new_mysqli()`
- removed inline DB and OpenAI secrets from tracked PHP files
- replaced inline production URLs in tracked PHP files with config keys
## Evidence
- `./scripts/verify.sh` -> OK
- secret scan on tracked PHP files -> no hard-coded DB or OpenAI secrets found
- route scan on tracked PHP files -> no hard-coded production URLs found
- ignore check -> `project/web/index/new/config/local.php` is ignored by git
- local config docs exist -> `project/web/index/new/config/README.md`
- config template exists -> `project/web/index/new/config/local.example.php`
## Checks run
- `./scripts/verify.sh`
- `rg -n "(sk-proj-|admin_natural|oo6478022A)" project/web/index/new --glob '!logs/*' --glob '!config/local.php' --glob '!config/local.example.php' --glob '*.php'`
- `rg -n "https://mercadodevida\.es|https://www\.mercadodevida\.es" project/web/index/new --glob '!logs/*' --glob '!config/local.php' --glob '!config/local.example.php' --glob '*.php'`
- `git check-ignore -v project/web/index/new/config/local.php`
## Notes
- Real local values must be filled in `config/local.php`.
- Existing SQL dump remains in repo and should be handled by separate data-security work.

View File

@@ -0,0 +1,14 @@
{
"feature_id": "F-002",
"agent": "leader",
"verdict": "APPROVED",
"summary": "All required non-leader gates are approved for F-002. Feature is accepted for final publish with shared config loader, tracked secret removal, and green harness verification.",
"evidence": [
"Reviewed work/artifacts/F-002/reviewer.json -> APPROVED",
"Reviewed work/artifacts/F-002/security.json -> APPROVED",
"Reviewed work/artifacts/F-002/qa.json -> APPROVED",
"Reviewed work/artifacts/F-002/documenter.md",
"Ran ./scripts/verify.sh -> OK"
],
"timestamp": "2026-05-25T06:00:00Z"
}

View File

@@ -0,0 +1,11 @@
{
"agent": "leader",
"verdict": "PUBLISHED",
"feature_id": "F-002",
"branch": "main",
"remote": "origin",
"message": "F-002 fix: Remove secrets and externalize config",
"pushed": true,
"published_at": "2026-05-25T06:00:01Z",
"note": "This artifact is committed inside the publish commit for this ticket."
}

View File

@@ -0,0 +1,21 @@
{
"feature_id": "F-002",
"agent": "qa",
"verdict": "APPROVED",
"summary": "Acceptance for config externalization is satisfied by shared loader, config docs, scans, and green harness verification.",
"traceability": [
"AC: No hard-coded API or DB secrets stay in versioned PHP files -> tracked PHP secret scan returned no matches",
"AC: Config values load from one local config source -> bootstrap.php reads config/local.php with fallback example shape",
"AC: Prod URLs and external endpoints are configurable -> index.php and inc/header.php now use config keys; product and image URLs use config keys",
"AC: Legacy pages still point to valid local config keys after change -> entry points call legacy_config() and legacy_new_mysqli()",
"AC: verify.sh is green -> ./scripts/verify.sh passed after changes"
],
"evidence": [
"Reviewed spec/bdd/features/config/legacy-config.feature",
"Reviewed bootstrap.php and config docs",
"Reviewed work/artifacts/F-002/implementer.md",
"Checked .gitignore entry for config/local.php",
"Checked verify output is OK"
],
"timestamp": "2026-05-25T05:55:00Z"
}

View File

@@ -0,0 +1,13 @@
{
"feature_id": "F-002",
"agent": "reviewer",
"verdict": "APPROVED",
"summary": "Shared config loader is consistent across the legacy module. Tracked PHP files now read DB, OpenAI, and route values through helpers instead of inline literals.",
"evidence": [
"Reviewed project/web/index/new/bootstrap.php",
"Reviewed updated entry points: index.php, describe.php, productos_bulk_update.php, productos_modificados.php, worker_bulk.php, inc/header.php, db/conn.php",
"Reviewed config template and setup docs under project/web/index/new/config/",
"Reviewed work/artifacts/F-002/implementer.md"
],
"timestamp": "2026-05-25T05:55:00Z"
}

View File

@@ -0,0 +1,28 @@
{
"feature_id": "F-002",
"agent": "security",
"verdict": "APPROVED",
"summary": "Tracked PHP files no longer contain hard-coded DB or OpenAI secrets. Production URLs in tracked PHP source were replaced by config lookups. Real local values now live in ignored local config.",
"checks": [
"secret scan on tracked PHP files",
"route scan on tracked PHP files",
"git ignore check for local config"
],
"findings": [
{
"severity": "medium",
"title": "SQL dump may still contain production-like data and should be handled in separate work",
"status": "accepted-risk",
"paths": [
"project/sql/db-25052026.sql"
]
}
],
"evidence": [
"Ran rg scan for sk-proj/admin_natural/oo6478022A on tracked PHP files and found no matches",
"Ran rg scan for hard-coded mercadodevida production URLs on tracked PHP files and found no matches",
"Confirmed project/web/index/new/config/local.php is ignored by git",
"Reviewed config loader, template, and local setup docs"
],
"timestamp": "2026-05-25T05:55:00Z"
}