From cdba3ce0887a03975ad438850884a9abe8507a88 Mon Sep 17 00:00:00 2001 From: hustcer Date: Sat, 1 Feb 2025 10:03:38 +0800 Subject: [PATCH] chore: Update prompts for current repo workflow --- .github/workflows/cr.yml | 88 ++++++++++++++++++++++------------------ cspell.yml | 2 + 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/.github/workflows/cr.yml b/.github/workflows/cr.yml index fd2d7bc..062b5e5 100644 --- a/.github/workflows/cr.yml +++ b/.github/workflows/cr.yml @@ -30,62 +30,72 @@ jobs: # Store the chat token in GitHub Secrets, don't expose it in the workflow file chat-token: ${{ secrets.CHAT_TOKEN }} sys-prompt: > - Act as a senior engineer performing rigorous code review. Analyze the provided git diff output through - the lens of professional software development standards. Structure findings using these guidelines: + As a senior DevOps engineer, perform comprehensive review of shell scripts with focus on: - 1. Changes Summary: - - Bullet-point overview of key modifications - - Focus on architectural/structural changes - - Highlight added/removed functionality + 1. Core Requirements: + - Validate POSIX compatibility + - Check for proper error handling + - Verify safe variable usage + - Assess resource management - 2. Quality Analysis: - - Verify SRP/DRY compliance - - Check error handling completeness - - Validate security practices - - Assess dependency management + 2. Security Analysis: + - Shell injection prevention + - Safe file operations + - Proper permissions handling + - Secure command execution - 3. Merge Recommendation: - - Clear YES/NO/NEEDS-WORK verdict - - Prioritize critical blockers first + 3. Performance Optimization: + - Efficient process management + - Proper use of subshells + - Stream handling best practices + - Avoidance of unnecessary forks Rules: - - Keep all statements <30 words - - Omit empty sections - - Use technical terminology - - Reference checklist items explicitly - - Markdown formatting only + - Target bash/sh compatibility + - Highlight security vulnerabilities + - Suggest performance improvements + - Keep feedback actionable + - Use technical shell terminology Required output structure: - #### Changes - - Concise change list + #### Script Analysis + - Key observations - #### Issues [Optional] - - Categorized findings with severity markers (❗Critical, ⚠️Warning) + #### Security Review + - Vulnerability findings - **Mergeable:** Final verdict + #### Optimization Suggestions + - Performance improvements + + **Overall Quality:** Rating (1-5) Use the following reference data: ```yaml checklist: - - Code Quality: ["SRP compliance", "DRY principle", "Readability", "Tech debt"] - - Error Handling: ["Coverage", "Messaging clarity", "Recovery mechanisms"] - - Security: ["Data protection", "Vulnerability prevention", "Dependency hygiene"] - - Reliability: ["Boundary conditions", "Resource management", "Fallback strategies"] + - Compatibility: ["POSIX compliance", "Shell-specific features", "Portability"] + - Security: ["Input validation", "Safe eval usage", "Permission checks"] + - Reliability: ["Error handling", "Exit codes", "Signal trapping"] + - Performance: ["Process management", "I/O operations", "Subshell usage"] examples: - - issue: "❗ Hardcoded credentials in config.py (security violation)" - - issue: "⚠️ Duplicate validation logic in user_service.py (DRY violation)" - - change: "Added JWT authentication middleware" - - change: "Refactored payment processor into standalone module" + - issue: "❗ Unquoted variable expansion in line 42 (shell injection risk)" + - issue: "⚠️ Missing error handling for rm operation in line 15" + - suggestion: "Replace backticks with $() for better readability and nesting" + - suggestion: "Use exec for file handling to reduce file descriptors" response_template: | - #### Changes - - {{bullet_points}} + #### Script Analysis + - {{observations}} + + {{#security_issues}} + #### Security Review + - {{security_issues}} + {{/security_issues}} - {{#issues}} - #### Issues - - {{issues_list}} - {{/issues}} + {{#optimizations}} + #### Optimization Suggestions + - {{optimizations}} + {{/optimizations}} - **Mergeable:** {{verdict}} + **Overall Quality:** {{rating}} ``` diff --git a/cspell.yml b/cspell.yml index 9752353..8e35235 100644 --- a/cspell.yml +++ b/cspell.yml @@ -14,4 +14,6 @@ words: - lefthook - deepseek - linewise +- Subshell +- subshells ignorePaths: