Skip to content

Commit fbe4972

Browse files
authored
Merge pull request #81 from Hypercart-Dev-Tools/rules/issue-63
Rules/issue 63 to Development
2 parents 87f9442 + ce9f544 commit fbe4972

20 files changed

Lines changed: 1065 additions & 44 deletions

CHANGELOG.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,78 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.3.10] - 2026-01-14
11+
12+
### Fixed
13+
- **PHP Security Rules**
14+
- `php-user-controlled-file-write`: Fixed a shell variable interpolation bug in the inline grep patterns that prevented detection when the file path was derived from PHP superglobals (e.g., `$_GET`, `$_POST`). The rule now reliably flags direct file writes with user-controlled paths.
15+
- `spo-003-insecure-deserialization`: Hardened the pattern definitions to avoid accidental expansion of shell special variables while scanning for insecure deserialization of superglobal input.
16+
17+
### Internal
18+
- Added an opt-in `DEBUG_PATTERN=1` environment flag for `dist/bin/check-performance.sh` that prints the resolved grep include arguments, patterns, and paths for pattern-based rules to aid future debugging.
19+
20+
### Documentation
21+
- Updated `PROJECT/1-INBOX/RULES-2026-01-14.md` to:
22+
- Reflect that `php-user-controlled-file-write` is hardened as of v1.3.10.
23+
- Promote `spo-003-insecure-deserialization` to a Tier 1 PHP rule with clear rationale and examples.
24+
- Document the `DEBUG_PATTERN=1` flag as a supported internal tool for auditing Tier 1 pattern behavior.
25+
26+
## [1.3.9] - 2026-01-14
27+
28+
### Added
29+
- **Tier 1 Security Rules (PHP)** - Direct file writes and hardcoded credentials
30+
- New rule: `php-user-controlled-file-write` (**CRITICAL**, security)
31+
- Detects `file_put_contents()`, `fopen()`, and `move_uploaded_file()` calls where the target path is derived directly from PHP superglobals (e.g., `$_GET`, `$_POST`)
32+
- Pattern JSON: `dist/patterns/php-user-controlled-file-write.json`
33+
- Scanner integration: new `run_check` block in `dist/bin/check-performance.sh`
34+
- New fixture: `dist/tests/fixtures/php-user-controlled-file-write.php` with direct file write anti-patterns
35+
- New rule: `php-hardcoded-credentials` (**CRITICAL**, security)
36+
- Detects hardcoded API keys, secrets, tokens, and passwords in PHP variables, constants, and Authorization headers
37+
- Pattern JSON: `dist/patterns/php-hardcoded-credentials.json`
38+
- Scanner integration: new `run_check` block in `dist/bin/check-performance.sh`
39+
- New fixture: `dist/tests/fixtures/php-hardcoded-credentials.php` with representative hardcoded credential patterns
40+
41+
### Changed
42+
- **Severity Configuration** - Updated `dist/config/severity-levels.json`
43+
- Incremented `total_checks` from 36 to 38
44+
- Added severity entries for `php-user-controlled-file-write` and `php-hardcoded-credentials` (both CRITICAL, category: security)
45+
46+
## [1.3.8] - 2026-01-14
47+
48+
### Added
49+
- **Tier 1 Security Rules (PHP)** - Shell command execution detection
50+
- New rule: `php-shell-exec-functions` (**CRITICAL**, security)
51+
- Detects usage of `shell_exec()`, `exec()`, `system()`, and `passthru()` in PHP code
52+
- Pattern JSON: `dist/patterns/php-shell-exec-functions.json`
53+
- Scanner integration: new `run_check` block in `dist/bin/check-performance.sh`
54+
- New fixture: `dist/tests/fixtures/shell-exec-antipatterns.php` with shell command execution anti-patterns
55+
56+
### Changed
57+
- **Severity Configuration** - Updated `dist/config/severity-levels.json`
58+
- Incremented `total_checks` from 35 to 36
59+
- Added severity entry for `php-shell-exec-functions` (CRITICAL, category: security)
60+
61+
## [1.3.7] - 2026-01-14
62+
63+
### Added
64+
- **Tier 1 Security Rules (PHP)** - Dangerous eval() and dynamic include/require detection
65+
- New rule: `php-eval-injection` (**CRITICAL**, security)
66+
- Detects `eval()` calls in PHP files
67+
- Pattern JSON: `dist/patterns/php-eval-injection.json`
68+
- Scanner integration: new `run_check` block in `dist/bin/check-performance.sh`
69+
- New rule: `php-dynamic-include` (**CRITICAL**, security)
70+
- Detects `include`/`require` statements whose path expressions contain variables (dynamic includes)
71+
- Pattern JSON: `dist/patterns/php-dynamic-include.json`
72+
- Scanner integration: new `run_check` block in `dist/bin/check-performance.sh`
73+
- New fixture: `dist/tests/fixtures/eval-and-include-antipatterns.php` with eval() and dynamic include/require anti-patterns
74+
75+
### Changed
76+
- **Severity Configuration** - Updated `dist/config/severity-levels.json`
77+
- Incremented `total_checks` from 33 to 35
78+
- Added severity entries for `php-eval-injection` and `php-dynamic-include` (both CRITICAL, category: security)
79+
- **Pattern Library Registry** - Pattern library auto-regenerated to include new PHP security rules
80+
- `dist/PATTERN-LIBRARY.json` and `dist/PATTERN-LIBRARY.md` refreshed by scanner run
81+
1082
## [1.3.6] - 2026-01-14
1183

1284
### Fixed

PROJECT/1-INBOX/BACKLOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# Backlog - Issues to Investigate
22

3+
### Checklist - 2025-01-14
4+
- [ ] Continue with Tier 1 rules - First 5 completed
5+
- [ ] Fix tty output for HTML reports (The commit added great new features (init, update, tab completion) with proper TTY detection. However, the original HTML generation code (lines 5848-5863) still writes to /dev/tty unconditionally)
6+
- [ ] Make a comment in main script to make rules in external files going forward
7+
- [ ] Breakout check-performance.sh into multiple files and external rule files
8+
39
## Mini Project Plan: Enhanced Context Detection (False Positive Reduction)
410

511
Goal: Improve context/scope accuracy (especially “same function”) to reduce false positives and severity inflation, while keeping the scanner fast and zero-dependency.
612

713
Notes:
814
- This is **not a new standalone script**. `dist/bin/check-performance.sh` already has limited “same function” scoping (used in caching mitigation); this mini-project extends/centralizes that approach.
915

10-
### Checklist
1116
- [ ] Audit where we rely on context windows today (±N lines) and where “same function” scoping would reduce false positives.
1217
- [x] Add/centralize a helper to compute function/method scope boundaries (support `function foo()`, `public/protected/private static function foo()`, and common formatting).
1318
- [x] Use the helper in mitigation detection (so caching/ids-only/admin-only/parent-scoped all share the same scoping rules).

0 commit comments

Comments
 (0)