728x90 properties2 안전하지 않은 리플렉션 - 동적 클래스 적재(loading)에 외부의 검증되지 않은 입력을 사용할 경우, 공격자가 외부 입력을 변조하여 의도하지 않은 클래스가 적재되도록 할 수 있다. - 외부의 입력을 직접 클래스 이름으로 사용하지 않고, 외부의 입력에 따라 미리 정한 후보(white list)중에서 적절한 클래스 이름을 선택하도록 한다. 안전하지 않은 코드 ▼ public void workType() { Properties props = new Properties(); // ... if( in != null && in.available() > 0 ) { props.load(in); if(props == null || props.isEmpty()) return; } Strong type = props.getProperty("t.. 2023. 2. 1. Java의 properties - load 일반적으로 컴파일된 코드 외부에서 간단한 매개변수를 키-값-쌍으로 저장하기 위해 사용java.util.Properties .properties 파일에서 키-값 쌍을 로드하는 예제app.properties ▼version = 1.0name = TestAppdate = 2016-11-12 catalog ▼c1 = filesc2 = imagesc3 = videos- .properties로 파일 명을 짓는게 좋으나, 필수는 아님Properties instance 로 쉽게 load할 수 있다.String rootPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();String appConfigPath = rootPath + .. 2023. 2. 1. 이전 1 다음 728x90