Skip to content

Commit ce68449

Browse files
committed
Fixes
1 parent 4a1a0c1 commit ce68449

5 files changed

Lines changed: 79 additions & 52 deletions

File tree

.github/workflows/branch-cleanup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
token: ${{ secrets.GITHUB_TOKEN }}
2424

2525
- name: Delete merged branch
26-
if: github.event.pull_request.merged == true
26+
if: github.event.pull_request.merged == true && github.event.pull_request.head.repo.full_name == github.repository
2727
env:
2828
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2929
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
@@ -44,4 +44,4 @@ jobs:
4444
else
4545
echo "::error::Failed to delete branch: $BRANCH_NAME"
4646
exit 1
47-
fi
47+
fi

.github/workflows/issue-management.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
types: [opened, reopened]
1212

1313
permissions:
14-
contents: write
14+
contents: read
1515
pull-requests: write
1616
issues: write
1717

@@ -20,6 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/labeler@v6
23+
if: github.event_name == 'pull_request'
2324
with:
2425
repo-token: ${{ secrets.GITHUB_TOKEN }}
2526
configuration-path: .github/labeler.yml
@@ -29,4 +30,4 @@ jobs:
2930
days-before-stale: 30
3031
days-before-close: 7
3132
stale-issue-message: 'This issue is stale due to inactivity'
32-
stale-pr-message: 'This PR is stale due to inactivity'
33+
stale-pr-message: 'This PR is stale due to inactivity'

.github/workflows/release.yml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,40 @@ jobs:
3838
echo "Release v${{ steps.get_version.outputs.version }} does not exist yet"
3939
fi
4040
41+
- name: Update README version
42+
if: steps.check_release.outputs.exists == 'false'
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
VERSION: ${{ steps.get_version.outputs.version }}
46+
run: |
47+
README_FILE="README.md"
48+
TMP_FILE=$(mktemp)
49+
50+
# Update the version badge with the new version and logo
51+
sed -E 's#\[!\[Version\]\(https://img\.shields\.io/badge/Version-[0-9]+\.[0-9]+\.[0-9]+-orange\.svg\?logo=github\)\]\(https://github\.com/EngineScript/enginescript-site-optimizer/releases/download/v[0-9]+\.[0-9]+\.[0-9]+/enginescript-site-optimizer-[0-9]+\.[0-9]+\.[0-9]+\.zip\)#[![Version](https://img.shields.io/badge/Version-'"$VERSION"'-orange.svg?logo=github)](https://github.com/EngineScript/enginescript-site-optimizer/releases/download/v'"$VERSION"'/enginescript-site-optimizer-'"$VERSION"'.zip)#g' "$README_FILE" > "$TMP_FILE"
52+
53+
# Replace file if changes were made
54+
if ! cmp -s "$README_FILE" "$TMP_FILE"; then
55+
cp "$TMP_FILE" "$README_FILE"
56+
echo "Updated README.md with version $VERSION"
57+
58+
# Configure git
59+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
60+
git config --local user.name "github-actions[bot]"
61+
62+
# Commit and push the changes
63+
git add "$README_FILE"
64+
git commit -m "docs: update README.md version to $VERSION [skip ci]"
65+
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
66+
67+
echo "::notice::README.md updated with latest version $VERSION"
68+
else
69+
echo "::notice::README.md already has the correct version"
70+
fi
71+
72+
# Clean up temporary file
73+
rm "$TMP_FILE"
74+
4175
- name: Create zip file
4276
if: steps.check_release.outputs.exists == 'false'
4377
run: |
@@ -83,37 +117,3 @@ jobs:
83117
draft: false
84118
prerelease: false
85119
generate_release_notes: false
86-
87-
- name: Update README version
88-
if: steps.check_release.outputs.exists == 'false'
89-
env:
90-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91-
VERSION: ${{ steps.get_version.outputs.version }}
92-
run: |
93-
README_FILE="README.md"
94-
TMP_FILE=$(mktemp)
95-
96-
# Update the version badge with the new version and logo
97-
sed -E 's#\[!\[Version\]\(https://img\.shields\.io/badge/Version-[0-9]+\.[0-9]+\.[0-9]+-orange\.svg\?logo=github\)\]\(https://github\.com/EngineScript/enginescript-site-optimizer/releases/download/v[0-9]+\.[0-9]+\.[0-9]+/enginescript-site-optimizer-[0-9]+\.[0-9]+\.[0-9]+\.zip\)#[![Version](https://img.shields.io/badge/Version-'"$VERSION"'-orange.svg?logo=github)](https://github.com/EngineScript/enginescript-site-optimizer/releases/download/v'"$VERSION"'/enginescript-site-optimizer-'"$VERSION"'.zip)#g' "$README_FILE" > "$TMP_FILE"
98-
99-
# Replace file if changes were made
100-
if ! cmp -s "$README_FILE" "$TMP_FILE"; then
101-
cp "$TMP_FILE" "$README_FILE"
102-
echo "Updated README.md with version $VERSION"
103-
104-
# Configure git
105-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
106-
git config --local user.name "github-actions[bot]"
107-
108-
# Commit and push the changes
109-
git add "$README_FILE"
110-
git commit -m "docs: update README.md version to $VERSION [skip ci]"
111-
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
112-
113-
echo "::notice::README.md updated with latest version $VERSION"
114-
else
115-
echo "::notice::README.md already has the correct version"
116-
fi
117-
118-
# Clean up temporary file
119-
rm "$TMP_FILE"

.github/workflows/wp-compatibility-test.yml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -455,48 +455,73 @@ jobs:
455455
456456
# Basic security pattern checks for common WordPress vulnerabilities
457457
echo "Checking for common security issues..."
458+
security_findings=0
459+
460+
grep_php() {
461+
grep -r "$1" \
462+
--include="*.php" \
463+
--exclude-dir=.github \
464+
--exclude-dir=.vscode \
465+
--exclude-dir=build \
466+
--exclude-dir=coverage \
467+
--exclude-dir=plugin-check-build \
468+
--exclude-dir=stubs \
469+
--exclude-dir=tests \
470+
--exclude-dir=vendor \
471+
. 2>/dev/null
472+
}
458473
459474
# Check for potential SQL injection patterns
460-
if grep -r "mysql_query\|mysqli_query" --include="*.php" --exclude-dir=.github --exclude-dir=.vscode . 2>/dev/null; then
461-
echo "Warning: Direct database queries found. Ensure proper sanitization."
475+
if grep_php "mysql_query\|mysqli_query"; then
476+
echo "::error::Direct database queries found. Ensure proper sanitization."
477+
security_findings=1
462478
fi
463479
464480
# Check for potential XSS vulnerabilities (missing escaping)
465-
if grep -r "echo \$_\|print \$_" --include="*.php" --exclude-dir=.github --exclude-dir=.vscode . 2>/dev/null; then
466-
echo "Warning: Potential XSS vulnerability found. Ensure output is escaped."
481+
if grep_php "echo \$_\|print \$_"; then
482+
echo "::error::Potential XSS vulnerability found. Ensure output is escaped."
483+
security_findings=1
467484
fi
468485
469486
# Check for file inclusion vulnerabilities
470-
if grep -r "include.*\$_\|require.*\$_" --include="*.php" --exclude-dir=.github --exclude-dir=.vscode . 2>/dev/null; then
471-
echo "Warning: Potential file inclusion vulnerability found."
487+
if grep_php "include.*\$_\|require.*\$_"; then
488+
echo "::error::Potential file inclusion vulnerability found."
489+
security_findings=1
472490
fi
473491
474492
# Check for eval() usage (security risk)
475-
if grep -r "eval(" --include="*.php" --exclude-dir=.github --exclude-dir=.vscode . 2>/dev/null; then
476-
echo "Warning: eval() function usage detected. This is a security risk."
493+
if grep_php "eval("; then
494+
echo "::error::eval() function usage detected. This is a security risk."
495+
security_findings=1
477496
fi
478497
479498
# Check for proper nonce usage
480-
if grep -r "wp_nonce_field\|wp_verify_nonce\|settings_fields" --include="*.php" --exclude-dir=.github --exclude-dir=.vscode . >/dev/null 2>&1; then
499+
if grep_php "wp_nonce_field\|wp_verify_nonce\|settings_fields" >/dev/null 2>&1; then
481500
echo "WordPress nonce usage detected."
482501
else
483502
echo "Info: Consider adding WordPress nonces for form security."
484503
fi
485504
486505
# Check for proper sanitization functions
487-
if grep -r "sanitize_\|esc_" --include="*.php" --exclude-dir=.github --exclude-dir=.vscode . >/dev/null 2>&1; then
506+
if grep_php "sanitize_\|esc_" >/dev/null 2>&1; then
488507
echo "WordPress sanitization functions detected."
489508
else
490-
echo "Warning: Limited use of WordPress sanitization functions."
509+
echo "::error::Limited use of WordPress sanitization functions."
510+
security_findings=1
491511
fi
492512
493513
# Check for capability checks
494-
if grep -r "current_user_can\|user_can" --include="*.php" --exclude-dir=.github --exclude-dir=.vscode . >/dev/null 2>&1; then
514+
if grep_php "current_user_can\|user_can" >/dev/null 2>&1; then
495515
echo "WordPress capability checks detected."
496516
else
497517
echo "Info: Consider adding user capability checks where appropriate."
498518
fi
499519
520+
if [ "$security_findings" -ne 0 ]; then
521+
echo "::error::WordPress security scan found blocking findings."
522+
exit 1
523+
fi
524+
500525
echo "WordPress security scan completed."
501526
502527
- name: Create issue on security vulnerability

tests/unit/DomainValidationTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ final class DomainValidationTest extends TestCase {
1616
* Reset options between tests.
1717
*/
1818
protected function setUp(): void {
19-
parent::setUp();
20-
2119
$this->resetTestState();
20+
21+
parent::setUp();
2222
}
2323

2424
/**
@@ -207,6 +207,7 @@ public function test_resource_hints_use_wordpress_filter_contract(): void {
207207

208208
$this->assertContains( array( 'href' => 'https://fonts.gstatic.com', 'crossorigin' => 'anonymous' ), $preconnect_hints );
209209
$this->assertIsArray( $cdn_hint );
210+
$this->assertSame( 'https://cdn.example.com', $cdn_hint['href'] );
210211
$this->assertArrayNotHasKey( 'crossorigin', $cdn_hint );
211212
$this->assertContains( 'https://static.example.com', $dns_prefetch_urls );
212213
}

0 commit comments

Comments
 (0)