Skip to content

Commit 08e3254

Browse files
authored
workflows
1 parent 563554a commit 08e3254

File tree

2 files changed

+47
-33
lines changed

2 files changed

+47
-33
lines changed

.github/workflows/wordpress-plugin-check.yml

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -592,34 +592,55 @@ jobs:
592592
- name: Security Check for known vulnerabilities in dependencies
593593
uses: symfonycorp/security-checker-action@v5
594594

595-
- name: WordPress Security Scan with WPScan
595+
- name: WordPress Security Scan
596596
run: |
597-
# Install WPScan
598-
gem install wpscan
599-
600-
# Create a temporary WordPress plugin structure for scanning
601-
mkdir -p temp-wp/wp-content/plugins/simple-wp-optimizer
602-
cp -r * temp-wp/wp-content/plugins/simple-wp-optimizer/ 2>/dev/null || true
603-
604-
# Run WPScan on the plugin (scan for known vulnerabilities)
605-
echo "Scanning for WordPress security vulnerabilities..."
606-
wpscan --url file://$(pwd)/temp-wp --enumerate p --plugins-detection mixed --format json --output wpscan-results.json || true
607-
608-
# Check if any vulnerabilities were found
609-
if [ -f wpscan-results.json ]; then
610-
echo "WPScan completed. Checking results..."
611-
cat wpscan-results.json
612-
613-
# Check for vulnerabilities in the JSON output
614-
if grep -q '"vulnerabilities"' wpscan-results.json; then
615-
echo "⚠️ Potential security vulnerabilities detected!"
616-
exit 1
617-
else
618-
echo "✅ No known vulnerabilities detected."
619-
fi
597+
echo "Performing WordPress plugin security analysis..."
598+
599+
# Basic security pattern checks for common WordPress vulnerabilities
600+
echo "🔍 Checking for common security issues..."
601+
602+
# Check for potential SQL injection patterns
603+
if grep -r "mysql_query\|mysqli_query" --include="*.php" . 2>/dev/null; then
604+
echo "⚠️ Warning: Direct database queries found - ensure proper sanitization"
605+
fi
606+
607+
# Check for potential XSS vulnerabilities (missing escaping)
608+
if grep -r "echo \$_\|print \$_" --include="*.php" . 2>/dev/null; then
609+
echo "⚠️ Warning: Potential XSS vulnerability - ensure output is escaped"
610+
fi
611+
612+
# Check for file inclusion vulnerabilities
613+
if grep -r "include.*\$_\|require.*\$_" --include="*.php" . 2>/dev/null; then
614+
echo "⚠️ Warning: Potential file inclusion vulnerability found"
615+
fi
616+
617+
# Check for eval() usage (security risk)
618+
if grep -r "eval(" --include="*.php" . 2>/dev/null; then
619+
echo "⚠️ Warning: eval() function usage detected - security risk"
620+
fi
621+
622+
# Check for proper nonce usage
623+
if grep -r "wp_nonce_field\|wp_verify_nonce" --include="*.php" . >/dev/null 2>&1; then
624+
echo "✅ WordPress nonce usage detected - good security practice"
625+
else
626+
echo "ℹ️ Info: Consider adding WordPress nonces for form security"
627+
fi
628+
629+
# Check for proper sanitization functions
630+
if grep -r "sanitize_\|esc_" --include="*.php" . >/dev/null 2>&1; then
631+
echo "✅ WordPress sanitization functions detected - good security practice"
620632
else
621-
echo "✅ WPScan completed without detecting vulnerabilities."
633+
echo "⚠️ Warning: Limited use of WordPress sanitization functions"
622634
fi
635+
636+
# Check for capability checks
637+
if grep -r "current_user_can\|user_can" --include="*.php" . >/dev/null 2>&1; then
638+
echo "✅ WordPress capability checks detected - good security practice"
639+
else
640+
echo "ℹ️ Info: Consider adding user capability checks where appropriate"
641+
fi
642+
643+
echo "🛡️ WordPress security scan completed"
623644
624645
- name: Create issue on security vulnerability
625646
if: ${{ failure() }}

phpstan.neon

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,11 @@ parameters:
66
paths:
77
- simple-wp-optimizer.php
88

9-
autoload_files:
9+
bootstrapFiles:
1010
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
1111

1212
ignoreErrors:
1313
# Ignore WordPress global variables that might not be defined in test context
1414
- '#Variable \$wpdb might not be defined#'
1515
- '#Variable \$wp_query might not be defined#'
1616
- '#Variable \$post might not be defined#'
17-
18-
bootstrapFiles:
19-
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
20-
21-
wordpress:
22-
# Enable WordPress-specific rules
23-
constants_file: vendor/php-stubs/wordpress-stubs/wordpress-stubs.php

0 commit comments

Comments
 (0)