Skip to content

Commit 9e3cd9b

Browse files
committed
fix: Add permissionsPolicy to Headers::secure() and Report 4 findings
Bug Fix: - Headers::secure() now includes permissionsPolicy() and removeInsecureHeaders() - Disables geolocation, camera, microphone, payment by default Report 4 (sinople-theme) Integration Findings: For sanctify-php: - UnsafeRedirect false positive when exit; on next line - MissingTextDomain may flag WP core functions - PHP 8.1+ syntax verification needed (nullsafe, match, first-class callable) - Guix package export documentation incomplete For php-aegis: - TurtleEscaper proved unique value (RDF/Turtle feed endpoint) - Clarified php-aegis-compat is planned, not yet implemented - WordPress mu-plugin adapter is Phase 7 roadmap item Integration success: Full WordPress theme integration with graceful fallback
1 parent 121ba67 commit 9e3cd9b

3 files changed

Lines changed: 121 additions & 5 deletions

File tree

COMPATIBILITY.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# php-aegis Compatibility Strategy
22

3+
> **Note**: This document describes the planned compatibility strategy. The `php-aegis-compat` package is not yet implemented. See the [roadmap](ROADMAP_PRIORITY.md) for status.
4+
35
## The Problem
46

57
php-aegis requires PHP 8.1+, but WordPress officially supports PHP 7.4+. This limits adoption in the WordPress ecosystem where many hosts still run PHP 7.4 or 8.0.
68

79
## Strategy: Dual-Package Approach
810

9-
Instead of downgrading the main library, we provide a separate compatibility package.
11+
Instead of downgrading the main library, we will provide a separate compatibility package.
1012

1113
```
12-
hyperpolymath/php-aegis # PHP 8.1+ (main, recommended)
13-
hyperpolymath/php-aegis-compat # PHP 7.4+ (polyfill, limited)
14+
hyperpolymath/php-aegis # PHP 8.1+ (main, recommended) ✅ Available
15+
hyperpolymath/php-aegis-compat # PHP 7.4+ (polyfill, limited) 📋 Planned
1416
```
1517

1618
### Why Not Downgrade?

HANDOVER_SANCTIFY.md

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,120 @@ exit;
486486

487487
---
488488

489+
## Additional Findings (Report 4: sinople-theme Full Integration)
490+
491+
### 14. Successful Integration Pattern
492+
493+
**What Worked**: Full integration with WordPress theme including:
494+
- Function wrappers: `sinople_aegis_html()`, `sinople_aegis_attr()`, `sinople_aegis_json()`
495+
- Validation wrappers: `sinople_aegis_validate_*()` functions
496+
- RDF/Turtle feed endpoint using `TurtleEscaper` (unique value!)
497+
- Graceful fallback to WordPress functions when php-aegis unavailable
498+
- Unit tests for the integration
499+
500+
**Key Success**: TurtleEscaper proved its unique value by enabling a `/feed/turtle/` endpoint.
501+
502+
### 15. sanctify-php False Positives Identified
503+
504+
**Issues to address**:
505+
506+
1. **UnsafeRedirect false positive**: When `exit;` is on the next line
507+
```php
508+
// This triggers false positive:
509+
wp_redirect($url);
510+
exit;
511+
512+
// sanctify-php expects:
513+
wp_redirect($url); exit;
514+
```
515+
516+
2. **MissingTextDomain false positive**: Flags WordPress core functions
517+
```php
518+
// This may be flagged incorrectly:
519+
__('Text', 'theme-domain'); // OK
520+
_e('Text', 'theme-domain'); // OK
521+
esc_html__('Text'); // May flag - but sometimes domain is optional
522+
```
523+
524+
**Recommendation**: Add configuration options:
525+
```yaml
526+
# sanctify.yml
527+
rules:
528+
UnsafeRedirect:
529+
allow_next_line_exit: true
530+
MissingTextDomain:
531+
ignore_core_functions: true
532+
```
533+
534+
### 16. PHP 8.1+ Syntax Verification Needed
535+
536+
**Concern**: Parser may not handle modern PHP syntax.
537+
538+
**Test cases to verify**:
539+
```php
540+
// Nullsafe operator (PHP 8.0+)
541+
$value = $object?->property?->method();
542+
543+
// Match expression (PHP 8.0+)
544+
$result = match($type) {
545+
'html' => Sanitizer::html($input),
546+
'js' => Sanitizer::js($input),
547+
default => $input,
548+
};
549+
550+
// Constructor property promotion (PHP 8.0+)
551+
public function __construct(
552+
private readonly string $name,
553+
) {}
554+
555+
// First-class callable syntax (PHP 8.1+)
556+
$fn = Sanitizer::html(...);
557+
```
558+
559+
### 17. Guix Export Documentation
560+
561+
**Issue**: Guix package export documentation is incomplete.
562+
563+
**Recommendation**: Add to sanctify-php docs:
564+
```scheme
565+
;; guix.scm
566+
(use-modules (guix packages)
567+
(guix git-download)
568+
(guix build-system haskell))
569+
570+
(package
571+
(name "sanctify-php")
572+
(version "0.1.0")
573+
(source (git-reference
574+
(url "https://github.com/hyperpolymath/sanctify-php")
575+
(commit (string-append "v" version))))
576+
(build-system haskell-build-system)
577+
(synopsis "PHP security static analyzer")
578+
(license license:agpl3+))
579+
```
580+
581+
---
582+
583+
## php-aegis Self-Identified Issues (Report 4)
584+
585+
These issues were discovered during sinople-theme integration:
586+
587+
| Issue | Status | Resolution |
588+
|-------|--------|------------|
589+
| `Headers::secure()` missing `permissionsPolicy()` | ✅ Fixed | Added in this PR |
590+
| `php-aegis-compat` package doesn't exist | 📋 Planned | Create separate repo |
591+
| Not published on Packagist | 📋 Planned | Publish after v0.2.0 |
592+
| WordPress mu-plugin adapter not implemented | 📋 Planned | Phase 7 roadmap |
593+
594+
---
595+
489596
## Contact
490597

491598
For questions about this integration or to coordinate between repos:
492599
- php-aegis: https://github.com/hyperpolymath/php-aegis
493600
- sanctify-php: https://github.com/hyperpolymath/sanctify-php
494-
- Integration tested in: wp-sinople-theme, Zotpress
601+
- Integration tested in: wp-sinople-theme, Zotpress, sinople-theme
495602

496603
---
497604

498-
*Generated from real-world WordPress integration experience (Reports 1, 2 & 3).*
605+
*Generated from real-world WordPress integration experience (Reports 1, 2, 3 & 4).*

src/Headers.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public static function secure(): void
3333
self::contentSecurityPolicy([
3434
'default-src' => ["'self'"],
3535
]);
36+
self::permissionsPolicy([
37+
'geolocation' => [],
38+
'camera' => [],
39+
'microphone' => [],
40+
'payment' => [],
41+
]);
42+
self::removeInsecureHeaders();
3643
}
3744

3845
/**

0 commit comments

Comments
 (0)