|
34 | 34 | run: | |
35 | 35 | pip install toml |
36 | 36 |
|
| 37 | + - name: Validate and sanitize user inputs |
| 38 | + id: sanitize |
| 39 | + run: | |
| 40 | + # Sanitize PR title - remove dangerous characters, limit length |
| 41 | + SAFE_PR_TITLE=$(printf '%s' '${{ github.event.pull_request.title }}' | \ |
| 42 | + sed 's/[`$();|&<>]//g' | \ |
| 43 | + sed 's/[[:cntrl:]]//g' | \ |
| 44 | + cut -c1-100) |
| 45 | + |
| 46 | + # Validate PR title is not empty after sanitization |
| 47 | + if [ -z "$SAFE_PR_TITLE" ]; then |
| 48 | + SAFE_PR_TITLE="Untitled PR" |
| 49 | + fi |
| 50 | + |
| 51 | + # Log sanitization results |
| 52 | + echo "🔒 Input validation results:" |
| 53 | + echo "Original PR title: ${{ github.event.pull_request.title }}" |
| 54 | + echo "Sanitized PR title: $SAFE_PR_TITLE" |
| 55 | + echo "" |
| 56 | + |
| 57 | + # Set outputs |
| 58 | + echo "pr_title=$SAFE_PR_TITLE" >> $GITHUB_OUTPUT |
| 59 | +
|
37 | 60 | - name: Detect changed services and extract versions |
38 | 61 | id: detect-changes |
39 | 62 | run: | |
@@ -155,13 +178,17 @@ jobs: |
155 | 178 | |
156 | 179 | echo "✅ Creating tag: $TAG_NAME" |
157 | 180 | |
158 | | - # Create tag with PR information |
| 181 | + # Create tag with sanitized PR information |
| 182 | + PR_TITLE="${{ steps.sanitize.outputs.pr_title }}" |
| 183 | + MERGED_BY="${{ github.event.pull_request.merged_by.login }}" |
| 184 | + |
| 185 | + # Create tag message with sanitized inputs |
159 | 186 | git tag -a "$TAG_NAME" -m "${service} v${version} |
160 | 187 |
|
161 | | - Auto-generated from merged PR #${{ github.event.pull_request.number }} |
162 | | - PR Title: ${{ github.event.pull_request.title }} |
163 | | - Merged by: ${{ github.event.pull_request.merged_by.login }} |
164 | | - Commit: ${{ github.sha }}" |
| 188 | + Auto-generated from merged PR #${{ github.event.pull_request.number }} |
| 189 | + PR Title: ${PR_TITLE} |
| 190 | + Merged by: ${MERGED_BY} |
| 191 | + Commit: ${{ github.sha }}" |
165 | 192 | |
166 | 193 | # Push tag with error handling |
167 | 194 | if git push origin "$TAG_NAME"; then |
@@ -217,14 +244,17 @@ jobs: |
217 | 244 | *) DISPLAY_NAME="$service" ;; |
218 | 245 | esac |
219 | 246 | |
220 | | - # Create release notes |
| 247 | + # Create release notes with sanitized inputs |
| 248 | + PR_TITLE="${{ steps.sanitize.outputs.pr_title }}" |
| 249 | + MERGED_BY="${{ github.event.pull_request.merged_by.login }}" |
| 250 | + |
221 | 251 | RELEASE_NOTES="## 🚀 $DISPLAY_NAME MCP Server v$version |
222 | 252 |
|
223 | 253 | ### 📋 What's Changed |
224 | 254 | This release was automatically generated from merged PR #${{ github.event.pull_request.number }}. |
225 | 255 |
|
226 | | - **PR Title**: ${{ github.event.pull_request.title }} |
227 | | - **Merged by**: @${{ github.event.pull_request.merged_by.login }} |
| 256 | + **PR Title**: ${PR_TITLE} |
| 257 | + **Merged by**: @${MERGED_BY} |
228 | 258 |
|
229 | 259 | ### 📦 Installation |
230 | 260 | \`\`\`bash |
@@ -302,36 +332,42 @@ jobs: |
302 | 332 | else |
303 | 333 | echo "✅ Creating umbrella tag: $UMBRELLA_TAG" |
304 | 334 | |
305 | | - # Create umbrella tag |
| 335 | + # Create umbrella tag with sanitized inputs |
| 336 | + PR_TITLE="${{ steps.sanitize.outputs.pr_title }}" |
| 337 | + MERGED_BY="${{ github.event.pull_request.merged_by.login }}" |
| 338 | + |
306 | 339 | git tag -a "$UMBRELLA_TAG" -m "HPE GreenLake MCP v${FIRST_SERVICE_VERSION} - All Services Release |
307 | 340 |
|
308 | | - Auto-generated from merged PR #${{ github.event.pull_request.number }} |
309 | | - PR Title: ${{ github.event.pull_request.title }} |
310 | | - Merged by: ${{ github.event.pull_request.merged_by.login }} |
311 | | - |
312 | | - Services with new tags: |
313 | | - $(for tag in $CREATED_TAGS; do echo "- $tag"; done) |
314 | | - |
315 | | - $(if [ -n "$SKIPPED_TAGS" ]; then |
316 | | - echo "Services with existing tags (skipped):" |
317 | | - for tag in $SKIPPED_TAGS; do echo "- $tag"; done |
318 | | - fi) |
319 | | - |
320 | | - Commit: ${{ github.sha }}" |
| 341 | + Auto-generated from merged PR #${{ github.event.pull_request.number }} |
| 342 | + PR Title: ${PR_TITLE} |
| 343 | + Merged by: ${MERGED_BY} |
| 344 | + |
| 345 | + Services with new tags: |
| 346 | + $(for tag in $CREATED_TAGS; do echo "- $tag"; done) |
| 347 | + |
| 348 | + $(if [ -n "$SKIPPED_TAGS" ]; then |
| 349 | + echo "Services with existing tags (skipped):" |
| 350 | + for tag in $SKIPPED_TAGS; do echo "- $tag"; done |
| 351 | + fi) |
| 352 | + |
| 353 | + Commit: ${{ github.sha }}" |
321 | 354 | |
322 | 355 | git push origin "$UMBRELLA_TAG" |
323 | 356 | fi |
324 | 357 | |
325 | 358 | # Only create release if we have some new tags |
326 | 359 | if [ -n "$CREATED_TAGS" ]; then |
327 | | - # Create release notes for all services |
| 360 | + # Create release notes for all services with sanitized inputs |
| 361 | + PR_TITLE="${{ steps.sanitize.outputs.pr_title }}" |
| 362 | + MERGED_BY="${{ github.event.pull_request.merged_by.login }}" |
| 363 | + |
328 | 364 | ALL_SERVICES_NOTES="## 🚀 HPE GreenLake MCP v${FIRST_SERVICE_VERSION} - All Services Release |
329 | 365 |
|
330 | 366 | ### 📋 What's Changed |
331 | 367 | This is a comprehensive release updating HPE GreenLake MCP servers. |
332 | 368 | |
333 | | - **PR Title**: ${{ github.event.pull_request.title }} |
334 | | - **Merged by**: @${{ github.event.pull_request.merged_by.login }} |
| 369 | + **PR Title**: ${PR_TITLE} |
| 370 | + **Merged by**: @${MERGED_BY} |
335 | 371 | **PR Number**: #${{ github.event.pull_request.number }} |
336 | 372 |
|
337 | 373 | ### 🏷️ New Service Tags |
@@ -443,9 +479,11 @@ jobs: |
443 | 479 | - name: Create workflow summary |
444 | 480 | if: always() |
445 | 481 | run: | |
| 482 | + PR_TITLE="${{ steps.sanitize.outputs.pr_title }}" |
| 483 | + |
446 | 484 | echo "## 🎉 Auto Release Summary" >> $GITHUB_STEP_SUMMARY |
447 | 485 | echo "" >> $GITHUB_STEP_SUMMARY |
448 | | - echo "**PR**: #${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}" >> $GITHUB_STEP_SUMMARY |
| 486 | + echo "**PR**: #${{ github.event.pull_request.number }} - ${PR_TITLE}" >> $GITHUB_STEP_SUMMARY |
449 | 487 | echo "**Merged by**: @${{ github.event.pull_request.merged_by.login }}" >> $GITHUB_STEP_SUMMARY |
450 | 488 | echo "**Commit**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY |
451 | 489 | echo "" >> $GITHUB_STEP_SUMMARY |
|
0 commit comments