fix: EgovDateUtil.getDayOfWeekCount 미인식 요일 입력 시 무한 루프 방지#250
Open
z3rotig4r wants to merge 1 commit into
Open
Conversation
유효 요일집합(일~토) 밖의 yoil이나 null이 들어오면 while 루프가 영원히 종료되지 않아 무한루프(DoS)에 빠지는 문제를 수정한다. 정규화 후 요일을 검증하여 미인식 시 IllegalArgumentException을 던진다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
변경 이유
EgovDateUtil.getDayOfWeekCount(from, to, yoil)에 유효 요일 집합{일, 월, 화, 수, 목, 금, 토}밖의yoil값이 들어오면 무한 루프가 발생합니다.(dayOfWeek - 1) % 7인덱스는 0~6만 순환하므로,yoil이 어떤 요일과도 일치하지 못하면dayOfWeek는 무한히 증가하지만 루프는 빠져나오지 못합니다. 영문 입력("Mon"), 길이 2 입력("월요"), 빈 문자열, 3자리 오타, null 등이 이에 해당합니다. 기존 line 418의 정규화는 길이 3("X요일") 형태만 처리하고 입력 검증은 없습니다.해당 메서드는
public static이고 호출 가드가 없어 외부에서 임의의 요일 문자열을 전달할 수 있습니다. 미인식 입력 시 CPU 100% 점유로 이어지는 무한 루프(DoS)가 발생합니다.변경 내용
IllegalArgumentException을 던지며, 허용 요일을 메시지에 명시합니다.while루프 로직은 변경하지 않아 유효 입력 경로의 동작을 그대로 보존합니다.테스트 방법
assertThrows(IllegalArgumentException)검증을 추가했습니다.@Timeout을 적용했습니다.org.egovframe.rte.fdl.string모듈 47개 테스트가 모두 통과합니다.영향 범위
yoil이 무한 루프였으므로, 미인식 값으로 정상 결과를 받던 호출자는 존재할 수 없습니다. 따라서 기존 동작과의 호환성은 깨지지 않습니다.