fix: EgovSequenceGenerator 가 예측 가능한 Math.random() 을 쓰고 솔트마다 SecureRandom 을 새로 만들던 문제 수정 - #412
Open
comghost wants to merge 1 commit into
Open
Conversation
…dom 을 새로 만들던 문제 수정 WebFlux 시퀀스 생성기는 시각 + 랜덤 5자 문자열을 솔트와 함께 해시한다. 랜덤 문자열은 Math.random() 으로, 솔트는 호출마다 new SecureRandom() 으로 만들었다. Math.random() 은 시드가 관측되면 예측 가능한 난수이고, SecureRandom 을 호출마다 새로 만드는 것은 시드 수집 비용만 반복한다. - 클래스 단위로 공유하는 SecureRandom 하나로 랜덤 문자열과 솔트를 모두 만든다. SecureRandom 은 스레드 안전하다 - 생성 형식(시각 17자 + 5자, SHA 다이제스트 16진수)과 공개 메소드는 그대로다 EgovSequenceGeneratorTest 2건 추가 — 모킹 없는 실동작으로 시퀀스 1,000건의 형식과 유일성, 랜덤 문자열의 길이와 허용 문자 집합을 확인한다.
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.
수정 사유 Reason for modification
수정된 소스 내용 Modified source
문제
EgovSequenceGenerator는 시각(17자)에 랜덤 5자를 붙인 문자열을 16바이트 솔트와 함께 해시해 시퀀스를 만듭니다.그런데 두 난수가 서로 다른 소스에서 나옵니다.
Math.random()— 시드가 관측되면 다음 값을 예측할 수 있는 일반 난수입니다.new SecureRandom()— 안전하지만 매번 인스턴스를 만들어 시드 수집 비용을 반복합니다.수정
클래스 단위로 공유하는
SecureRandom하나로 랜덤 문자열과 솔트를 모두 만듭니다.SecureRandom은 스레드 안전하므로WebFlux 의 동시 호출에서도 공유할 수 있습니다.
SecureRandom이었으므로 결과 해시의 예측 불가성이 새로 생기는 것은 아닙니다. 이 PR 은 난수 소스를하나로 통일하고 호출마다 SecureRandom 을 만들던 비용을 없애는 정리입니다.
JUnit 테스트 JUnit tests
EgovSequenceGeneratorTest2건 추가(기존 mockStatic 테스트 1건 유지),fdl.reactive모듈 전건 통과.Tests run: 5, Failures: 0, Errors: 0, Skipped: 0Tests run: 5, Failures: 0, Errors: 0, Skipped: 0A-Za-z0-9) 5자수동 확인: 현재
main(cc2b332) 위에서fdl.reactive모듈 빌드·테스트가 통과함을 Windows 와 Linux 에서 확인했습니다.테스트 브라우저 Test Browser
해당 없음 — 라이브러리 내부 수정입니다.
테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
해당 없음 — 위 JUnit 테스트 결과로 갈음합니다.
base:
eGovFramework:main@cc2b332(2026-09-10 fetch 기준, #366~#379 머지 후) · 단일 커밋