Security fixes, API compliance, and dependency check - #21
Open
k2sobot wants to merge 5 commits into
Open
Conversation
Critical fixes: - Use hash_equals() for webhook signature validation (prevents timing attacks) - Initialize $action as array() in callback() to prevent undefined variable errors - Sanitize entry_id from webhook metadata using absint() - Sanitize reference strings using sanitize_text_field() API compliance fixes: - Remove unsupported billing intervals (hourly, biannually) - Add quarterly billing interval per Paystack API spec - Change send_invoices from string to boolean type WordPress coding standards: - Use array() syntax instead of [] (WordPress coding standards) - Add proper docblocks with @throws annotations
- Add GF_PAYSTACK_MIN_GF_VERSION constant for minimum version requirement - Add admin_notice() to show error if Gravity Forms is not installed - Add safety check in class-gf-paystack.php to return early if GF not loaded - Update gf_paystack() helper to return false if class doesn't exist - Add proper file docblocks to all PHP files (WordPress coding standards) - Only show admin notice on plugins page or dashboard Prevents fatal errors when plugin is activated without Gravity Forms.
Paystack supports all these intervals: - hourly - daily - weekly - monthly - quarterly - biannually (every 6 months) - annually Previous commit incorrectly removed hourly and biannually.
Author
Correction: Billing IntervalsI made an error in my original assessment. After reviewing the Paystack API documentation more carefully, Paystack does support all these billing intervals:
I've corrected the code to include all supported intervals. The Updated in commit: 3a4bf16 What's Fixed (Still Applies)
|
- Remove ThickBox popup (tb_show) that wasn't working - Display instructions directly inline on settings page - Add proper styling for webhook URL display - Add rel='noopener noreferrer' for security - Escape webhook URL output with esc_url()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses critical security vulnerabilities, bug fixes, UI improvements, and adds proper dependency checking to prevent fatal errors when Gravity Forms is not installed.
🔴 Critical Security Fix
Webhook Signature Validation (Timing Attack)
Severity: High
The webhook signature validation was vulnerable to timing attacks using direct string comparison.
🐛 Bug Fixes
1. Undefined Variable in
callback()The
$actionarray was used conditionally but not initialized, causing PHP warnings:2. Input Sanitization
All webhook input data is now properly sanitized:
entry_id: Usesabsint()reference: Usessanitize_text_field()🎨 UI Improvement
Webhook Instructions Inline
The webhook instructions popup (ThickBox) wasn't working properly. Now displays inline:
Before: Click "View Instructions" → popup (often blocked or failed to load)
After: Instructions visible directly on the settings page
📋 API Compliance
Billing Intervals
All Paystack-supported intervals are now available:
hourlydailyweeklymonthlyquarterlybiannuallyannuallyBoolean Type Fix
🛡️ Dependency Check
Plugin now fails gracefully when Gravity Forms is not installed:
falseinstead of fatal error📝 WordPress Coding Standards
array()syntax (not[])rel="noopener noreferrer"to external linksesc_url()Files Changed
paystack.phpclass-gf-paystack.php$actioninit, input sanitization, billing intervals, inline instructionsclass-gf-paystack-api.phphash_equals()validation, docblocks.gitignoreTesting