|
| 1 | + |
| 2 | +# static analysis |
| 3 | + |
| 4 | +After you've confirmed that the script is functional, perform a thorough static analysis of the provided shell script without executing it. Focus on identifying potential issues in the following categories: |
| 5 | + |
| 6 | +1. Resource Dependencies and Sequencing: |
| 7 | + - Identify operations that create dependencies between resources |
| 8 | + - Verify that resources are created in the correct order |
| 9 | + - Check for operations that modify the same resource multiple times |
| 10 | + - Flag any attempts to associate resources that might already have existing associations |
| 11 | + |
| 12 | +2. Error Handling and Resilience: |
| 13 | + - Evaluate error handling mechanisms |
| 14 | + - Check for proper exit strategies when commands fail |
| 15 | + - Identify sections that might leave resources in an inconsistent state |
| 16 | + - Verify cleanup procedures are comprehensive and properly sequenced |
| 17 | + |
| 18 | +3. Security and Best Practices: |
| 19 | + - Identify overly permissive security configurations |
| 20 | + - Flag hardcoded credentials or sensitive information |
| 21 | + - Check for adherence to infrastructure-as-code best practices |
| 22 | + - Verify proper resource tagging and naming conventions |
| 23 | + |
| 24 | +4. Resource Limitations: |
| 25 | + - Identify potential service quotas or limits that might be exceeded |
| 26 | + - Check for resource creation without corresponding cleanup |
| 27 | + - Flag operations that might incur unexpected costs |
| 28 | + |
| 29 | +5. Logic and Control Flow: |
| 30 | + - Analyze conditional logic for potential flaws |
| 31 | + - Verify loop constructs for proper termination conditions |
| 32 | + - Check for race conditions or timing issues |
| 33 | + - Identify potential infinite loops or deadlocks |
| 34 | + |
| 35 | +6. AWS-Specific Concerns (for AWS scripts): |
| 36 | + - Verify proper handling of AWS region settings |
| 37 | + - Check for proper IAM permissions and least privilege principles |
| 38 | + - Identify potential cross-region or cross-account issues |
| 39 | + - Verify proper handling of AWS resource identifiers |
| 40 | + |
| 41 | +## Output Files and Response Format |
| 42 | + |
| 43 | +When validating a script, create the following output files: |
| 44 | + |
| 45 | +1. Validation Report File: |
| 46 | + - Name: `[original-script-name]-validation-report.md` |
| 47 | + - Content: Detailed analysis of issues found in the script |
| 48 | + - Location: Save in the validation-tools directory |
| 49 | + |
| 50 | +2. Fixed Script File (ONLY if HIGH severity issues are found): |
| 51 | + - Name: `[original-script-name]-fixed.sh` |
| 52 | + - Content: Complete fixed version of the script with comments explaining changes |
| 53 | + - Location: Save in the validation-tools directory |
| 54 | + |
| 55 | +3. Response to User: |
| 56 | + - Provide a brief summary of the validation results |
| 57 | + - Include the number and types of issues found (High/Medium/Low) |
| 58 | + - Clearly state which issues will be fixed (HIGH severity) and which won't be fixed (MEDIUM and LOW severity) |
| 59 | + - Mention that the detailed report and fixed script (if applicable) have been saved as files |
| 60 | + - DO NOT include the entire fixed script in your response to the user |
| 61 | + |
| 62 | +The validation report should include: |
| 63 | +- A summary of potential issues categorized by severity (High, Medium, Low) |
| 64 | +- Clear distinction between issues that will be fixed in the fixed script (HIGH severity) and those that won't be fixed (MEDIUM and LOW severity) |
| 65 | +- Line numbers or code snippets where issues were found |
| 66 | +- Specific recommendations for addressing each issue |
| 67 | +- Suggestions for improving the overall script quality and reliability |
| 68 | + |
| 69 | +In the fixed script: |
| 70 | +- Add comments before each fixed section explaining what HIGH severity issue is being addressed |
| 71 | +- Include a header comment summarizing all HIGH severity issues that were fixed |
| 72 | +- Optionally include comments about MEDIUM and LOW severity issues that weren't fixed but could be improved in the future |
| 73 | + |
| 74 | +## File Organization |
| 75 | + |
| 76 | +- If validation reports and fixed scripts already exist for the script being validated, move the existing files to the `archive` directory before creating new ones |
| 77 | +- This ensures that the main directory contains only the most recent validation results while preserving previous work |
| 78 | + |
| 79 | +This naming convention ensures clear association between original scripts, validation reports, and fixed versions. |
0 commit comments