|
| 1 | +# VIOLATION: Missing proper header comment block (no purpose, triggers, behaviors, limitations) |
| 2 | + |
| 3 | +name: Bad Workflow |
| 4 | + |
| 5 | +# VIOLATION: No explicit event types specified |
| 6 | +on: [push, pull_request] |
| 7 | + |
| 8 | +# VIOLATION: Permissions not documented with comments explaining why needed |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + issues: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + # VIOLATION: Job name not in kebab-case (should be bad-workflow-job) |
| 16 | + BadWorkflowJob: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + # VIOLATION: Missing conditional execution (no if: conditions) |
| 20 | + |
| 21 | + steps: |
| 22 | + # VIOLATION: Step name not descriptive/action-oriented |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + # VIOLATION: No step name at all |
| 27 | + - uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: '20' |
| 30 | + |
| 31 | + - name: Run script |
| 32 | + # VIOLATION: No env: section to pass GitHub Actions values safely |
| 33 | + run: | |
| 34 | + echo "Processing files..." |
| 35 | + |
| 36 | + # VIOLATION: Missing set -e for error handling |
| 37 | + |
| 38 | + # VIOLATION: Variables not initialized before use |
| 39 | + FILES=${{ github.event.pull_request.changed_files }} |
| 40 | + |
| 41 | + # VIOLATION: Unquoted variable expansion (word-splitting risk) |
| 42 | + echo "Files: $FILES" |
| 43 | + |
| 44 | + # VIOLATION: Direct interpolation of GitHub Actions expression (shell injection risk) |
| 45 | + BRANCH_NAME="${{ github.head_ref }}" |
| 46 | + |
| 47 | + # VIOLATION: No error handling or exit codes |
| 48 | + npm install |
| 49 | + npm test |
| 50 | + |
| 51 | + # VIOLATION: Hardcoded sensitive value (should use secrets) |
| 52 | + API_KEY="sk-1234567890abcdef" |
| 53 | + curl -H "Authorization: Bearer $API_KEY" https://api.example.com/data |
| 54 | + |
| 55 | + # VIOLATION: No ANSI color codes for logging |
| 56 | + echo "Success" |
| 57 | + |
| 58 | + # VIOLATION: No descriptive comments for complex logic |
| 59 | + for file in $FILES; do |
| 60 | + if [[ $file == *.sol ]]; then |
| 61 | + cat $file | grep "pragma" >> output.txt |
| 62 | + fi |
| 63 | + done |
| 64 | + |
| 65 | + # VIOLATION: Writing to GITHUB_ENV without quotes |
| 66 | + echo "RESULT=success" >> $GITHUB_ENV |
| 67 | + |
| 68 | + - name: Comment |
| 69 | + # VIOLATION: No unique marker for comment identification |
| 70 | + # VIOLATION: No check for existing comments before creating new ones |
| 71 | + run: | |
| 72 | + # VIOLATION: Missing set -e |
| 73 | + |
| 74 | + COMMENT="Build completed" |
| 75 | + |
| 76 | + # VIOLATION: Using GITHUB_TOKEN directly without unsetting it first |
| 77 | + curl -X POST \ |
| 78 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 79 | + -H "Accept: application/vnd.github.v3+json" \ |
| 80 | + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ |
| 81 | + -d "{\"body\": \"$COMMENT\"}" |
| 82 | + |
| 83 | + - name: Upload artifact |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + # VIOLATION: Not descriptive artifact name |
| 87 | + name: output |
| 88 | + path: output.txt |
| 89 | + |
| 90 | + # VIOLATION: No cleanup of temporary files |
| 91 | + |
| 92 | + # VIOLATION: No job dependencies (needs:) when they should exist |
| 93 | + another_job: |
| 94 | + runs-on: ubuntu-latest |
| 95 | + # VIOLATION: No concurrency group to prevent duplicate runs |
| 96 | + |
| 97 | + steps: |
| 98 | + - name: Step without proper error handling |
| 99 | + run: | |
| 100 | + # VIOLATION: No set -e |
| 101 | + # VIOLATION: No error messages with context |
| 102 | + # VIOLATION: Command that might fail silently |
| 103 | + rm -rf /tmp/cache || echo "failed" |
| 104 | + |
| 105 | + # VIOLATION: No transparency/logging of decisions |
| 106 | + if [ -f "package.json" ]; then |
| 107 | + npm install |
| 108 | + fi |
0 commit comments