feat: 코드 리뷰 기반 전면 개선 — 보안, 검증, 테스트, 안정성
Some checks failed
Server CI/CD / lint-and-build (push) Failing after 47s
Server CI/CD / deploy (push) Has been skipped

- 체인 nonce 경쟁 조건 수정 (operatorMu + per-user mutex)
- 등록/SSAFY 원자적 트랜잭션 (wallet+profile 롤백 보장)
- IdempotencyRequired 미들웨어 (SETNX 원자적 클레임)
- 런치 티켓 API (JWT URL 노출 방지)
- HttpOnly 쿠키 refresh token
- SSAFY OAuth state 파라미터 (CSRF 방지)
- Refresh 시 DB 조회로 최신 role 사용
- 공지사항/유저목록 페이지네이션
- BodyLimit 미들웨어 (1MB, upload 제외)
- 입력 검증 강화 (닉네임, 게임데이터, 공지 길이)
- 에러 메시지 내부 정보 노출 방지
- io.LimitReader (RPC 10MB, SSAFY 1MB)
- RequestID 비출력 문자 제거
- 단위 테스트 (auth 11, announcement 9, bossraid 16)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-15 18:03:25 +09:00
parent cc8368dfba
commit b0de89a18a
25 changed files with 1691 additions and 105 deletions

View File

@@ -1,6 +1,8 @@
package middleware
import (
"strings"
"github.com/gofiber/fiber/v2"
"github.com/google/uuid"
)
@@ -11,6 +13,17 @@ func RequestID(c *fiber.Ctx) error {
if id == "" {
id = uuid.NewString()
}
// Truncate client-provided request IDs to prevent abuse
if len(id) > 64 {
id = id[:64]
}
// Strip non-printable characters to prevent log injection
id = strings.Map(func(r rune) rune {
if r < 32 || r == 127 {
return -1
}
return r
}, id)
c.Locals("requestID", id)
c.Set("X-Request-ID", id)
return c.Next()