@@ -727,23 +727,58 @@ jobs:
727727
728728 # Attempt automatic fixes
729729 CHANGES_MADE=false
730+ FIXES_APPLIED=""
730731
732+ # Fix Node.js packages
731733 if [ -f "package.json" ]; then
732734 echo "Applying npm audit fix..." >> $GITHUB_STEP_SUMMARY
733735 npm audit fix --package-lock-only || true
734736
735737 if ! git diff --quiet package*.json; then
736738 git add package*.json
737- git commit -m "fix: Apply automatic CVE fixes from npm audit
738-
739- Co-Authored-By: CVE Fix Workflow <noreply@github.com>"
739+ NPM_FIXES=$(git diff --cached --stat | head -1)
740+ FIXES_APPLIED="${FIXES_APPLIED}Node.js (npm): $NPM_FIXES\n"
740741 CHANGES_MADE=true
741742 echo "✅ Applied npm fixes" >> $GITHUB_STEP_SUMMARY
742743 fi
743744 fi
744745
746+ # Fix Python packages
747+ if [ -f "requirements.txt" ]; then
748+ echo "Checking Python package updates..." >> $GITHUB_STEP_SUMMARY
749+
750+ # Try pip-compile if available, otherwise create manual list
751+ if [ -f "artifacts/fix-cve/review/safe-fixes-$DATE.md" ]; then
752+ # Extract safe Python fixes and update requirements.txt
753+ SAFE_PY_PACKAGES=$(grep -A 100 "Python Package Review" artifacts/fix-cve/review/safe-fixes-$DATE.md 2>/dev/null | grep "✅" | grep -o "\`[^:]*\`" | tr -d '`' || echo "")
754+
755+ if [ -n "$SAFE_PY_PACKAGES" ]; then
756+ # Create backup
757+ cp requirements.txt requirements.txt.backup
758+
759+ # Update versions in requirements.txt for safe packages
760+ # Note: This is a basic implementation - in production you'd use pip-compile or similar
761+ echo "ℹ️ Python fixes available but require manual update" >> $GITHUB_STEP_SUMMARY
762+ FIXES_APPLIED="${FIXES_APPLIED}Python (pip): Manual update required - see safe-fixes report\n"
763+ fi
764+ fi
765+ fi
766+
767+ # Commit all changes
768+ if [ "$CHANGES_MADE" = true ]; then
769+ git commit -m "fix: Apply automatic CVE fixes
770+
771+ Automated fixes applied :
772+ $FIXES_APPLIED
773+
774+ Co-Authored-By : CVE Fix Workflow <noreply@github.com>"
775+ fi
776+
745777 echo "changes_made=$CHANGES_MADE" >> $GITHUB_ENV
746778 echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
779+ echo "fixes_applied<<EOF" >> $GITHUB_ENV
780+ echo -e "$FIXES_APPLIED" >> $GITHUB_ENV
781+ echo "EOF" >> $GITHUB_ENV
747782
748783 # Create remediation log
749784 cat > artifacts/fix-cve/remediation/remediation-log-$DATE.md << EOF
@@ -847,16 +882,78 @@ jobs:
847882 **Workflow:** CVE Fix Workflow (Reusable)
848883 **Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
849884
850- ## Findings
885+ ## Findings Summary
851886
852887 - **Total CVEs Found:** ${{ steps.identify.outputs.cves_found }}
853- - **Changes Made:** ${{ env.changes_made }}
888+ - **Automatic Fixes Applied:** ${{ env.changes_made == 'true' && 'Yes' || 'No' }}
889+ - **Safe Fixes Available:** ${safe_fixes:-0}
890+ - **Manual Review Required:** ${risky_fixes:-0}
891+ - **Packages with Missing Documentation:** ${missing_docs:-0}
892+
893+ ## Automatic Fixes Applied
894+
895+ EOF
896+
897+ if [ "${{ env.changes_made }}" = "true" ]; then
898+ cat >> artifacts/fix-cve/docs/executive-summary-$DATE.md << EOF
899+ ✅ **Automatic fixes were applied and committed to this branch:**
900+
901+ ${{ env.fixes_applied }}
902+
903+ **What was fixed:**
904+ - Security patches for patch/minor version updates
905+ - Low-risk dependency updates
906+ - Fixes that don't require code changes
907+
908+ EOF
909+ else
910+ cat >> artifacts/fix-cve/docs/executive-summary-$DATE.md << EOF
911+ ℹ️ **No automatic fixes were applied because:**
912+ - All available fixes require manual review (major version changes)
913+ - Or no fixable vulnerabilities were detected
914+ - Or fixes require code modifications
915+
916+ EOF
917+ fi
918+
919+ cat >> artifacts/fix-cve/docs/executive-summary-$DATE.md << EOF
920+
921+ ## Manual Review Required
922+
923+ EOF
924+
925+ if [ "${risky_fixes:-0}" -gt 0 ]; then
926+ cat >> artifacts/fix-cve/docs/executive-summary-$DATE.md << EOF
927+ ⚠️ **${risky_fixes} packages require manual review:**
928+
929+ These are major version updates that may contain breaking changes. Manual intervention is required.
930+
931+ **See detailed list:** \`artifacts/fix-cve/review/risky-fixes-$DATE.md\`
932+
933+ **Common reasons for manual review:**
934+ - Major version changes (e.g., 1.x → 2.0)
935+ - Breaking API changes
936+ - New dependencies introduced
937+ - Configuration changes required
938+ - Code modifications needed
939+
940+ EOF
941+ else
942+ cat >> artifacts/fix-cve/docs/executive-summary-$DATE.md << EOF
943+ ✅ **No manual review required** - all fixes are safe patch/minor updates or were applied automatically.
944+
945+ EOF
946+ fi
947+
948+ cat >> artifacts/fix-cve/docs/executive-summary-$DATE.md << EOF
854949
855950 ## Release Review Summary
856951
857- - **Safe Fixes (Patch/Minor Updates):** ${safe_fixes:-0}
858- - **Risky Fixes (Major Version Changes):** ${risky_fixes:-0}
859- - **Packages with Missing Documentation:** ${missing_docs:-0}
952+ | Category | Count | Status |
953+ |----------|-------|--------|
954+ | ✅ Safe Fixes (Patch/Minor) | ${safe_fixes:-0} | Ready to apply |
955+ | ⚠️ Risky Fixes (Major versions) | ${risky_fixes:-0} | Manual review needed |
956+ | ❓ Missing Documentation | ${missing_docs:-0} | Research required |
860957
861958 ### Alarming Findings
862959
@@ -962,22 +1059,43 @@ jobs:
9621059
9631060 - name : Create Pull Request
9641061 id : create_pr
965- if : env.changes_made == ' true' && inputs.create_pr == true
1062+ if : inputs.create_pr == true && steps.identify.outputs.cves_found != '0'
9661063 env :
9671064 GH_TOKEN : ${{ github.token }}
9681065 run : |
9691066 DATE=$(date +%Y-%m-%d)
9701067
971- # Push branch
1068+ # Determine PR title and labels based on whether fixes were applied
1069+ if [ "${{ env.changes_made }}" = "true" ]; then
1070+ PR_TITLE="Security: CVE Fixes Applied - $(date +%B\ %Y)"
1071+ PR_LABELS="security,cve-fix,automated,has-fixes"
1072+ else
1073+ PR_TITLE="Security: CVE Scan Results - Manual Review Required - $(date +%B\ %Y)"
1074+ PR_LABELS="security,cve-fix,automated,manual-review"
1075+ fi
1076+
1077+ # Push branch (even if no changes, to preserve artifacts)
1078+ # If no changes, commit the artifacts
1079+ if [ "${{ env.changes_made }}" != "true" ]; then
1080+ git add artifacts/
1081+ git commit -m "docs: Add CVE scan results and review reports
1082+
1083+ This scan found vulnerabilities that require manual review.
1084+
1085+ See executive summary for details.
1086+
1087+ Co-Authored-By : CVE Fix Workflow <noreply@github.com>" || true
1088+ fi
1089+
9721090 git push origin ${{ env.branch_name }}
9731091
9741092 # Create PR
9751093 PR_BODY=$(cat artifacts/fix-cve/docs/executive-summary-$DATE.md)
9761094
9771095 PR_URL=$(gh pr create \
978- --title "Security: CVE Fixes - $(date +%B\ %Y) " \
1096+ --title "$PR_TITLE " \
9791097 --body "$PR_BODY" \
980- --label "security,cve-fix,automated " \
1098+ --label "$PR_LABELS " \
9811099 --base ${{ inputs.target_branch }} \
9821100 --head ${{ env.branch_name }})
9831101
0 commit comments