fix(ci): harden master auto-repair and protocol gate stability (#48)

Co-authored-by: BrunoGaoSZ <[email protected]>
This commit is contained in:
BrunoGao
2026-03-04 01:08:05 +00:00
committed by GitHub
co-authored by BrunoGaoSZ
parent 2cfc52cc03
commit 0af42ef630
5 changed files with 48 additions and 39 deletions
+12 -12
View File
@@ -144,13 +144,13 @@ jobs:
自动闭环修复未完成,已转人工处理。
- Source workflow: `${{ steps.ctx.outputs.workflow_name }}`
- Source run id: `${{ steps.ctx.outputs.run_id }}`
- Source workflow: ${{ steps.ctx.outputs.workflow_name }}
- Source run id: ${{ steps.ctx.outputs.run_id }}
- Source run URL: ${{ steps.ctx.outputs.run_url }}
- Target branch: `${{ steps.ctx.outputs.branch }}`
- Repair status: `${{ steps.repair.outputs.repair_status }}`
- Exit code: `${{ steps.repair.outputs.exit_code }}`
- Attempt: `${{ steps.repair.outputs.attempt }}/${{ steps.repair.outputs.max_attempts }}`
- Target branch: ${{ steps.ctx.outputs.branch }}
- Repair status: ${{ steps.repair.outputs.repair_status }}
- Exit code: ${{ steps.repair.outputs.exit_code }}
- Attempt: ${{ steps.repair.outputs.attempt }}/${{ steps.repair.outputs.max_attempts }}
请人工定位失败根因后提交修复,再由主分支 workflow 自动回归。
BODY
@@ -185,10 +185,10 @@ jobs:
{
echo "## Main Branch Auto Repair"
echo ""
echo "- branch: `${{ steps.ctx.outputs.branch }}`"
echo "- source workflow: `${{ steps.ctx.outputs.workflow_name }}`"
echo "- source run: `${{ steps.ctx.outputs.run_id }}`"
echo "- repair status: `${{ steps.repair.outputs.repair_status || 'skipped' }}`"
echo "- attempt: `${{ steps.repair.outputs.attempt || '-' }}/${{ steps.repair.outputs.max_attempts || '-' }}`"
echo "- exit code: `${{ steps.repair.outputs.exit_code || '-' }}`"
echo "- branch: ${{ steps.ctx.outputs.branch }}"
echo "- source workflow: ${{ steps.ctx.outputs.workflow_name }}"
echo "- source run: ${{ steps.ctx.outputs.run_id }}"
echo "- repair status: ${{ steps.repair.outputs.repair_status || 'skipped' }}"
echo "- attempt: ${{ steps.repair.outputs.attempt || '-' }}/${{ steps.repair.outputs.max_attempts || '-' }}"
echo "- exit code: ${{ steps.repair.outputs.exit_code || '-' }}"
} >> "$GITHUB_STEP_SUMMARY"
@@ -55,6 +55,7 @@ public class HelpDocController {
* @param path route path
* @return help doc VO
*/
@PreAuthorize("permitAll()")
@GetMapping("/route")
public Result<HelpDocVO> getByRoute(@RequestParam String path) {
HelpDocVO doc = helpDocAppService.getByRoute(path);
@@ -6,13 +6,17 @@ import org.springframework.http.HttpMethod;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ValueConstants;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -51,6 +55,11 @@ public class ProtocolEndpointResolver {
if (!methods.isEmpty() && !methods.contains(RequestMethod.GET)) {
return List.of();
}
if (hasRequiredRequestParam(handler.getMethod())) {
// Protocol security contract sends bare GET requests. Endpoints requiring query params
// would fail with 400 before auth/authorization and produce false negatives.
return List.of();
}
String preAuthorize = preAuthorizeValue(handler.getMethod());
if (preAuthorize.isBlank()) {
@@ -83,6 +92,26 @@ public class ProtocolEndpointResolver {
return expression != null && expression.contains("hasAuthority(");
}
private boolean hasRequiredRequestParam(Method method) {
for (Parameter parameter : method.getParameters()) {
RequestParam requestParam = AnnotatedElementUtils.findMergedAnnotation(parameter, RequestParam.class);
if (requestParam == null) {
continue;
}
if (!requestParam.required()) {
continue;
}
if (!ValueConstants.DEFAULT_NONE.equals(requestParam.defaultValue())) {
continue;
}
if (Optional.class.isAssignableFrom(parameter.getType())) {
continue;
}
return true;
}
return false;
}
private String normalizePath(String raw) {
Pattern varPattern = Pattern.compile("\\{[^/]+}");
Matcher matcher = varPattern.matcher(raw);
Regular → Executable
+4 -7
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Flyway Repair Script
# Repairs the Flyway schema history to match current migration files
# Flyway repair wrapper.
# Run from aggregator root so dependent modules are resolvable in CI runners.
set -euo pipefail
@@ -9,9 +9,6 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_ROOT"
echo "🔧 Running Flyway repair..."
# Run Maven Flyway repair
mvn flyway:repair -f pom.xml -q
echo "🔧 Running Flyway repair on ljwx-platform-app (with -am)"
mvn -q -f pom.xml -pl ljwx-platform-app -am flyway:repair
echo "✅ Flyway repair completed"
+2 -20
View File
@@ -1,27 +1,9 @@
#!/usr/bin/env bash
# Flyway Repair Script
# Fixes checksum mismatches in flyway_schema_history table
# Backward-compatible entrypoint for existing scripts.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
echo "🔧 Flyway Repair Tool"
echo "===================="
echo ""
cd "$PROJECT_ROOT/ljwx-platform-app"
echo "Running flyway:repair to fix checksum mismatches..."
mvn flyway:repair -q
if [ $? -eq 0 ]; then
echo "✅ Flyway repair completed successfully"
echo ""
echo "Checksum mismatches have been resolved."
echo "You can now run: bash scripts/gates/gate-all.sh 35"
else
echo "❌ Flyway repair failed"
exit 1
fi
bash "$PROJECT_ROOT/scripts/flyway-repair.sh"