Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6144bf5
Fix multiple security vulnerabilities across Gyro PHP
claude Mar 5, 2026
9d19d01
Fix command injection, path traversal, and eval vulnerabilities
claude Mar 5, 2026
0fddc46
Fix XSS, weak randomness, and insecure permissions
claude Mar 5, 2026
aa30bfa
Update security analysis memory with complete findings summary
claude Mar 5, 2026
3cbde77
Add CLAUDE.md memory file with comprehensive codebase analysis
claude Mar 5, 2026
6574f88
Phase 1: Fix PHP 8.x compatibility, add bcrypt password hashing, add …
claude Mar 5, 2026
130fbb1
Fix multiple security vulnerabilities across Gyro PHP
onetechgroupll Mar 5, 2026
a38111d
Merge branch 'master' into claude/analyze-repository-7ADOV
onetechgroupll Mar 5, 2026
e971bf7
Update CLAUDE.md: reflect Phase 1 completion in security section and …
claude Mar 5, 2026
d131772
Phase 2: Add Composer/PHPUnit setup, port tests, add prepared statements
claude Mar 5, 2026
c745e95
Phase 3: Harden session security, review CSRF and input validation
claude Mar 5, 2026
25986a9
Phase 4: Add type declarations to interfaces and structured logging
claude Mar 5, 2026
f66ddbb
Phase 5: Quality & Cleanup - remove dead modules, port tests, add PHPDoc
claude Mar 5, 2026
86b47f1
Add modern PHP features analysis to CLAUDE.md
claude Mar 5, 2026
45d3053
Phase 6: Typed properties, DB prepared statement wrappers, Composer c…
claude Mar 5, 2026
c4e9709
Port 30 SimpleTest tests to PHPUnit, expand test coverage from 66 to …
claude Mar 5, 2026
d46eb7a
Expand test coverage: port remaining SimpleTest + write 12 new test c…
claude Mar 5, 2026
f54e18d
Expand test coverage: add 11 new test classes for DB fields, converte…
claude Mar 5, 2026
7050ab1
Phase 7: Add .env support, raise PHPStan to level 2, fix classmap con…
claude Mar 5, 2026
f97f8e0
Fix 3 PHP 8.4 dynamic property deprecation warnings
claude Mar 5, 2026
1d670c1
Add CHANGELOG.md and UPGRADING.md documentation for existing users
claude Mar 5, 2026
6fa4d64
Add documentation update rules to CLAUDE.md
claude Mar 5, 2026
6cd15b5
Phase 8: Add CLI tool (bin/gyro) with model:list, model:show, db:sync
claude Mar 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Gyro-PHP Environment Configuration
# Copy this file to .env and adjust values for your environment.
# All values are optional — defaults from constants.inc.php apply if not set.
# Only APP_* keys are auto-defined as PHP constants.

# =============================================================================
# Application
# =============================================================================
#APP_TITLE="My Application"
#APP_LANG=en
#APP_CHARSET=UTF-8
#APP_TESTMODE=false
#APP_ITEMS_PER_PAGE=10

# =============================================================================
# Database
# =============================================================================
#APP_DB_TYPE=mysql
#APP_DB_HOST=127.0.0.1
#APP_DB_NAME=mydb
#APP_DB_USER=root
#APP_DB_PASSWORD=
#APP_DB_SLOW_QUERY_THRESHOLD=0.0100

# =============================================================================
# URLs & Domain
# =============================================================================
#APP_URL_DOMAIN=www.example.com
#APP_URL_BASEDIR=/
#APP_DEFAULT_SCHEME=http
#APP_ENABLE_HTTPS=true
#APP_FORCE_FULL_DOMAINNAME=true
#APP_VALIDATE_URL=true
#APP_UNICODE_URLS=false

# =============================================================================
# Session
# =============================================================================
#APP_START_SESSION=true
#APP_SESSION_HANDLER=DBSession

# =============================================================================
# Mail
# =============================================================================
#APP_MAIL_SENDER=noreply@example.com
#APP_MAIL_ADMIN=admin@example.com
#APP_MAIL_SUPPORT=support@example.com
#APP_MAIL_SUBJECT="[My App]"
#APP_MAIL_RETURN_PATH=
#APP_MAILER_TYPE=mail
#APP_MAILER_SMTP_HOST=
#APP_MAILER_SMTP_USER=
#APP_MAILER_SMTP_PASSWORD=

# =============================================================================
# Directories
# =============================================================================
#APP_TEMP_DIR=/tmp/myapp/
#APP_OUT_DIR=/tmp/myapp/
#APP_LOG_DIR=/tmp/myapp/log/
#APP_3RDPARTY_DIR=

# =============================================================================
# Logging
# =============================================================================
#APP_LOG_QUERIES=false
#APP_LOG_FAILED_QUERIES=true
#APP_LOG_SLOW_QUERIES=false
#APP_LOG_TRANSLATIONS=false
#APP_LOG_HTML_ERROR_STATUS=false
#APP_LOG_HTTPREQUESTS=false
#APP_LOG_FILE_NAME_PATTERN="%date%_%name%.log"

# =============================================================================
# Debugging
# =============================================================================
#APP_THROW_ON_DB_ERROR=true
#APP_THROW_ON_WARNING=false
#APP_DEBUG_QUERIES=false
#APP_PRINT_DURATION=false
#APP_DISABLE_CACHE=false
#APP_DISABLE_ERROR_CACHE=false

# =============================================================================
# Templates & View
# =============================================================================
#APP_DEFAULT_TEMPLATE_ENGINE=core
#APP_PAGE_TEMPLATE="core::page"

# =============================================================================
# Cache Headers
# =============================================================================
#APP_CACHEHEADER_CLASS_CACHED=PrivateRigid
#APP_CACHEHEADER_CLASS_UNCACHED=NoCache
#APP_PRELOAD_CSS=false

# =============================================================================
# Form Validation
# =============================================================================
#APP_FORMVALIDATION_FIELD_NAME=jfioeudkswefs
#APP_FORMVALIDATION_HANDLER_NAME=uerwudjmdjwu
#APP_FORMVALIDATION_EXPIRATION_TIME=15
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.idea
/vendor/
.phpunit.result.cache
.env
162 changes: 162 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Changelog

Alle wesentlichen Änderungen am Gyro-PHP Framework, chronologisch nach Phasen geordnet.

## [Phase 8] – 2026-03-05

### Hinzugefügt
- **CLI-Tool (`bin/gyro`):** Neues Kommandozeilen-Werkzeug für Gyro-PHP:
- `gyro help` — Verfügbare Kommandos anzeigen
- `gyro model:list` — Alle DAO-Modelle mit Tabellennamen, Feldern und Primary Keys auflisten
- `gyro model:show <table>` — Detailliertes Schema eines Modells anzeigen (Felder, Typen, Defaults, Relations, CREATE TABLE SQL)
- `gyro db:sync` — Model-Schema mit der Datenbank vergleichen und ALTER TABLE SQL generieren
- **CLI-Kernel** (`gyro/core/cli/clikernel.cls.php`): Command-Routing, Argument-Parsing, farbige Ausgabe
- **CLICommand** Basisklasse für eigene Kommandos
- **CLITable** ASCII-Tabellenrenderer für formatierte CLI-Ausgabe
- **CLI-Bootstrap** (`gyro/core/cli/bootstrap.cli.php`): Framework-Initialisierung ohne HTTP-Kontext
- **Model-Discovery:** Automatische Erkennung aller DAO-Klassen in Core, Modules und Contributions
- **Schema-Introspection:** Liest `create_table_object()` und generiert CREATE TABLE / ALTER TABLE SQL
- **33 neue Tests** für CLI-Komponenten (CLITable, CLIKernel, ModelShowCommand)

### Ergebnis
- 287 Tests, 1066 Assertions (alle grün, 0 Deprecations)

---

## [Phase 7] – 2026-03-05

### Hinzugefügt
- **`.env` Konfiguration:** Neuer `Env`-Loader (`gyro/core/lib/helpers/env.cls.php`) ermöglicht
Environment-Konfiguration über `.env`-Dateien. Alle `APP_*` Variablen aus der `.env`-Datei
werden automatisch als PHP-Konstanten definiert — vollständig rückwärtskompatibel.
- **`.env.example`:** Referenzdatei mit allen verfügbaren Konfigurationsvariablen.
- **11 neue Tests** für den Env-Loader (`tests/core/EnvTest.php`).
- **PHPStan Baseline** (`phpstan-baseline.neon`): 1262 bekannte Fehler getracked,
neue Fehler werden sofort gemeldet.

### Geändert
- **PHPStan Level 1 → 2:** Strengere statische Analyse mit Baseline-Strategie.
- **Composer Classmap entfernt:** Die `autoload.classmap` Konfiguration wurde entfernt,
da sie einen Pfadkonflikt mit dem Framework-eigenen `Load::directories()` verursachte
(`include_once` erkannte die gleiche Datei unter verschiedenen Pfaden nicht als identisch).
- **`start.php`:** Lädt jetzt `.env` vor `constants.inc.php` (nur wenn `APP_INCLUDE_ABSPATH` definiert ist).
- **`.gitignore`:** `.env` hinzugefügt.

### Behoben
- **PHP 8.4 Deprecation Warnings:** 3 dynamische Properties gefixt:
- `DAOStudentsTest::$modificationdate` als explizite Property deklariert
- `Url::$url` als explizite Property deklariert (verwendet in `__sleep`/`__wakeup`)

### Ergebnis
- 254 Tests, 985 Assertions (alle grün, 0 Deprecations)
- PHPStan Level 2: keine neuen Fehler

---

## [Phase 6] – 2026-03-05

### Hinzugefügt
- **Typed Properties** in 12 Interface-Implementierungen (16 Properties total):
- `DBResultSet`, `DBResultSetMysql`, `DBResultSetSphinx`, `DBResultSetCountSphinx`
- `CacheDBImpl`, `CacheFileImpl`, `FileCacheItem`, `ACPuCacheItem`, `MemcacheCacheItem`
- `ConverterChain`, `ConverterHtmlTidy`, `ConverterUnidecode`
- **`DB::execute_prepared()`** und **`DB::query_prepared()`** — statische Wrapper für
Prepared Statements auf der DB-Klasse. Vereinfacht die Nutzung gegenüber dem direkten
Driver-Zugriff.
- **PHPStan Level 1** eingerichtet (`phpstan.neon.dist`).

---

## [Phase 5] – 2026-03-05

### Entfernt
- **`cache.xcache`** — XCache ist seit PHP 7.0 nicht mehr verfügbar (8 Dateien).
- **`javascript.cleditor`** — CLEditor ist seit Jahren abandoned (~36 Dateien).
- **`javascript.wymeditor`** — WYMeditor ist seit Jahren abandoned (~79 Dateien).

### Hinzugefügt
- Weitere SimpleTest → PHPUnit Migrationen.
- PHPDoc für ausgewählte public APIs.

---

## [Phase 4] – 2026-03-05

### Hinzugefügt
- **Type Declarations** in 5 Core-Interfaces und allen Implementierungen:
- `IDBResultSet` (3 Impl.), `ISessionHandler` (4 Impl.), `ICachePersister` (5 Impl.),
`IConverter` (12+ Impl.), `IHashAlgorithm` (6 Impl.)
- Union Types: `array|false`, `string|false`, `int|false`, `ICacheItem|false`, `mixed`
- **Structured Logging** (PSR-3 kompatibel) in `Logger`:
- Neue Methoden: `Logger::emergency()`, `::alert()`, `::critical()`, `::error()`,
`::warning()`, `::notice()`, `::info()`, `::debug()`
- Context-Interpolation: `Logger::error('User {user} failed', ['user' => $name])`
- JSON-Ausgabe pro Level (z.B. `error-2026-03-05.log`)
- Exception-Support mit automatischem Stack-Trace
- Konfigurierbares Minimum-Level: `Logger::set_min_level(Logger::WARNING)`

### Nicht geändert
- `IDBDriver` Type Declarations zurückgestellt (Sphinx-Driver hat fehlende Methoden).
- Namespace-Migration (PSR-4) zurückgestellt (zu großer Breaking Change).

---

## [Phase 3] – 2026-03-05

### Verbessert
- **Session-Security:**
- `session.cookie_secure = 1` wird bei HTTPS automatisch gesetzt
- `session.cookie_httponly = true` fest konfiguriert
- `session.cookie_samesite = Lax` konfiguriert
- Veralteter PHP < 7.3 `setcookie()` Fallback entfernt
- **CSRF-Token Validierung:** Strikter Vergleich `===` statt `==` in
`FormHandler::validate()`.

### Geprüft (keine Änderung nötig)
- CSRF-Token-System: Bereits robust (random_bytes, Session-gebunden, DB-gestützt, Einmal-Tokens).
- Input-Handling: Core nutzt `PageData`/`TracedArray`, kein direkter `$_POST`/`$_GET` Zugriff.

---

## [Phase 2] – 2026-03-05

### Hinzugefügt
- **Composer** (`composer.json`): PHPUnit 10.5 als Dev-Dependency, PHP >=8.0.
- **PHPUnit Setup:** `phpunit.xml.dist`, `tests/bootstrap.php`, Test-Verzeichnisstruktur.
- **Prepared Statements** im MySQL-Driver:
- `$driver->execute_prepared('INSERT INTO t (col) VALUES (?)', ['value'])`
- `$driver->query_prepared('SELECT * FROM t WHERE id = ?', [42])`
- Automatische Typerkennung der Parameter (`detect_param_types()`)
- **IDBDriver Interface:** Um `execute_prepared()` und `query_prepared()` erweitert.
- **SimpleTest → PHPUnit Migration** gestartet: `ArrayTest`, `StringTest`, `ValidationTest`.
- `.gitignore`: `/vendor/` hinzugefügt.

### Nicht geändert
- Bestehende `execute()`/`query()` Methoden bleiben unverändert (Rückwärtskompatibilität).
Sie verwenden weiterhin `mysqli_real_escape_string()`.

---

## [Phase 1] – 2026-03-05

### Behoben (PHP 8.x Kompatibilität)
- **`common.cls.php`:** `preprocess_input()` als No-op implementiert, `transcribe()` entfernt
(Magic Quotes gibt es seit PHP 7.4 nicht mehr).
- **`start.php`:** `E_ALL | E_STRICT` → `E_ALL` (E_STRICT ist seit PHP 8.0 Teil von E_ALL).
PHP 5.3 Kompatibilitäts-Check (`defined('E_DEPRECATED')`) entfernt.
- **`cast.cls.php`:** `isset($value->__toString)` → `method_exists($value, '__toString')`
(PHP 8.0 wirft bei `isset()` auf Magic Methods einen Fehler).

### Verbessert (Sicherheit)
- **Passwort-Hashing:** Default von MD5/PHPass auf **bcrypt** umgestellt:
- `password_hash()` mit `PASSWORD_BCRYPT`, Cost-Factor 12
- Neuer Hash-Algorithmus `bcryp` in `contributions/usermanagement/`
- Automatische Migration: Bestehende Hashes werden beim nächsten Login transparent
auf bcrypt aktualisiert
- **HTTP Security Headers:**
- `X-Content-Type-Options: nosniff`
- `X-Frame-Options: SAMEORIGIN`
- `Referrer-Policy: strict-origin-when-cross-origin`
- `Permissions-Policy` (restriktiv)
- Alle mit `override=false` — Applikationen können sie überschreiben
- **Timing-safe Vergleiche:** `hash_equals()` in MD5 und SHA1 Hash-Klassen.
Loading