Skip to content

Commit 5238dda

Browse files
authored
Updates
1 parent 0bfea47 commit 5238dda

3 files changed

Lines changed: 32 additions & 51 deletions

File tree

.github/workflows/ai-pr-comment.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ jobs:
2525
steps:
2626
- name: Download analysis artifacts
2727
uses: actions/github-script@v7
28+
env:
29+
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }}
2830
with:
2931
script: |
32+
const runId = process.env.WORKFLOW_RUN_ID;
3033
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
3134
owner: context.repo.owner,
3235
repo: context.repo.repo,
33-
run_id: ${{ github.event.workflow_run.id }},
36+
run_id: runId,
3437
});
3538
3639
const matchArtifact = artifacts.data.artifacts.find((artifact) => {
@@ -50,7 +53,7 @@ jobs:
5053
});
5154
5255
const fs = require('fs');
53-
fs.writeFileSync('${{ github.workspace }}/pr-analysis.zip', Buffer.from(download.data));
56+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr-analysis.zip`, Buffer.from(download.data));
5457
5558
- name: Extract and validate artifacts
5659
id: extract-data
@@ -80,11 +83,17 @@ jobs:
8083
8184
- name: Post AI review comment
8285
uses: actions/github-script@v7
86+
env:
87+
PR_NUMBER: ${{ steps.extract-data.outputs.pr-number }}
88+
HEAD_SHA: ${{ steps.extract-data.outputs.head-sha }}
89+
AUTHOR: ${{ steps.extract-data.outputs.author }}
90+
WORKFLOW_URL: ${{ github.event.workflow_run.html_url }}
8391
with:
8492
script: |
85-
const prNumber = ${{ steps.extract-data.outputs.pr-number }};
86-
const headSha = "${{ steps.extract-data.outputs.head-sha }}";
87-
const author = "${{ steps.extract-data.outputs.author }}";
93+
const prNumber = process.env.PR_NUMBER;
94+
const headSha = process.env.HEAD_SHA;
95+
const author = process.env.AUTHOR;
96+
const workflowUrl = process.env.WORKFLOW_URL;
8897
8998
// Validate inputs
9099
if (!prNumber || !headSha) {
@@ -132,7 +141,7 @@ jobs:
132141
133142
> 🔄 **Note:** This analysis was performed securely without executing untrusted code
134143
135-
**Analysis Workflow:** [View Details](${{ github.event.workflow_run.html_url }})
144+
**Analysis Workflow:** [View Details](${workflowUrl})
136145
`;
137146
138147
await github.rest.issues.createComment({
@@ -153,13 +162,16 @@ jobs:
153162
- name: Download failure artifacts (if any)
154163
uses: actions/github-script@v7
155164
continue-on-error: true
165+
env:
166+
WORKFLOW_RUN_ID: ${{ github.event.workflow_run.id }}
156167
with:
157168
script: |
158169
try {
170+
const runId = process.env.WORKFLOW_RUN_ID;
159171
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
160172
owner: context.repo.owner,
161173
repo: context.repo.repo,
162-
run_id: ${{ github.event.workflow_run.id }},
174+
run_id: runId,
163175
});
164176
165177
const matchArtifact = artifacts.data.artifacts.find((artifact) => {
@@ -196,9 +208,13 @@ jobs:
196208
197209
- name: Create failure issue
198210
uses: actions/github-script@v7
211+
env:
212+
PR_NUMBER: ${{ steps.extract-pr.outputs.pr-number }}
213+
WORKFLOW_HTML_URL: ${{ github.event.workflow_run.html_url }}
199214
with:
200215
script: |
201-
const prNumber = "${{ steps.extract-pr.outputs.pr-number }}";
216+
const prNumber = process.env.PR_NUMBER;
217+
const workflowUrl = process.env.WORKFLOW_HTML_URL;
202218
203219
const title = `🚨 AI Analysis Failed${prNumber ? ` for PR #${prNumber}` : ''}`;
204220
const body = `
@@ -207,7 +223,7 @@ jobs:
207223
The automated AI code analysis workflow has failed and requires attention.
208224
209225
${prNumber ? `**Pull Request:** #${prNumber}` : '**Pull Request:** Unable to determine'}
210-
**Workflow Run:** ${{ github.event.workflow_run.html_url }}
226+
**Workflow Run:** ${workflowUrl}
211227
**Failure Time:** ${new Date().toISOString()}
212228
213229
### Possible Causes

.github/workflows/gemini-security-scan.yml

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -45,47 +45,8 @@ jobs:
4545
- name: Run Gemini Security Analysis
4646
if: steps.changed-files.outputs.any_changed == 'true'
4747
uses: google-github-actions/run-gemini-cli@v0.1.10
48-
with:
49-
prompt: |
50-
You are a WordPress security expert with deep knowledge of plugin vulnerabilities.
51-
52-
SECURITY SCAN INSTRUCTIONS:
53-
Analyze the following code changes for security vulnerabilities. Focus on:
54-
55-
🔴 CRITICAL SECURITY ISSUES:
56-
- SQL Injection: Check for unsanitized database queries, missing prepared statements
57-
- Cross-Site Scripting (XSS): Look for unescaped output, missing esc_html/esc_attr
58-
- Cross-Site Request Forgery (CSRF): Verify nonce usage in forms and AJAX
59-
- Authentication Bypass: Check user capability validation
60-
- File Upload Vulnerabilities: Verify file type and size validation
61-
- Directory Traversal: Look for path manipulation vulnerabilities
62-
- Code Injection: Check for eval(), exec(), system() usage
63-
64-
🟡 WORDPRESS-SPECIFIC SECURITY:
65-
- Proper use of WordPress sanitization functions
66-
- Correct capability checks (current_user_can)
67-
- WordPress nonce verification
68-
- Proper use of wpdb prepared statements
69-
- Validation of user input and file uploads
70-
- Secure handling of options and meta data
71-
72-
🟢 BEST PRACTICES:
73-
- Input validation and sanitization
74-
- Output escaping and encoding
75-
- Secure API endpoint implementation
76-
- Proper error handling without information disclosure
77-
78-
For each issue found:
79-
1. Specify the exact file and line number
80-
2. Explain the vulnerability type and risk level
81-
3. Provide secure code recommendations
82-
4. Reference WordPress Codex security guidelines
83-
84-
If no vulnerabilities are found, confirm the code follows WordPress security standards.
85-
86-
FILES TO ANALYZE:
87-
${{ steps.changed-files.outputs.all_changed_files }}
8848
env:
49+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
8950
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
9051

9152
- name: Create Security Issue on Critical Findings

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,20 @@ jobs:
107107
- Developer experience
108108
109109
FILES TO ANALYZE:
110-
${{ steps.changed-files.outputs.all_changed_files }}
110+
$CHANGED_FILES
111111
env:
112+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
112113
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
113114

114115
- name: Comment on PR with Findings
115116
if: github.event_name == 'pull_request'
116117
uses: actions/github-script@v7
118+
env:
119+
FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
117120
with:
118121
script: |
119122
const fs = require('fs');
123+
const filesCount = process.env.FILES_COUNT;
120124
121125
// This would be the output from Gemini CLI
122126
const comment = `
@@ -125,7 +129,7 @@ jobs:
125129
Thank you for your contribution! I've analyzed your code changes for WordPress best practices and coding standards.
126130
127131
### 📊 Analysis Summary
128-
- **Files Analyzed:** ${{ steps.changed-files.outputs.all_changed_files_count }}
132+
- **Files Analyzed:** ${filesCount}
129133
- **WordPress Version:** 6.5+ compatible
130134
- **PHP Version:** 7.4+ compatible
131135

0 commit comments

Comments
 (0)