🔒️ 행안부 프리셋 보안 점검 1차 점검
This commit is contained in:
@@ -103,7 +103,7 @@ public class MenuService extends AbstractService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public MenuTreeResponseDto updateName(Long menuId, String name) {
|
public MenuTreeResponseDto updateName(Long menuId, String name) throws EntityNotFoundException {
|
||||||
Menu menu = menuRepository.findById(menuId)
|
Menu menu = menuRepository.findById(menuId)
|
||||||
.orElseThrow(() ->
|
.orElseThrow(() ->
|
||||||
new EntityNotFoundException(getMessage("valid.notexists.format", new Object[]{getMessage("menu")}) + " ID= " + menuId));
|
new EntityNotFoundException(getMessage("valid.notexists.format", new Object[]{getMessage("menu")}) + " ID= " + menuId));
|
||||||
@@ -122,7 +122,7 @@ public class MenuService extends AbstractService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public MenuResponseDto update(Long menuId, MenuUpdateRequestDto updateRequestDto) {
|
public MenuResponseDto update(Long menuId, MenuUpdateRequestDto updateRequestDto) throws EntityNotFoundException, BusinessMessageException {
|
||||||
Menu menu = menuRepository.findById(menuId)
|
Menu menu = menuRepository.findById(menuId)
|
||||||
.orElseThrow(() ->
|
.orElseThrow(() ->
|
||||||
new EntityNotFoundException(getMessage("valid.notexists.format", new Object[]{getMessage("menu")}) + " ID= " + menuId));
|
new EntityNotFoundException(getMessage("valid.notexists.format", new Object[]{getMessage("menu")}) + " ID= " + menuId));
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class FileStorageUtils implements StorageUtils {
|
|||||||
try {
|
try {
|
||||||
mimeType = Files.probeContentType(filePath);
|
mimeType = Files.probeContentType(filePath);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
//ignore
|
log.error("Files.probeContentType", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mimeType == null ? URLConnection.guessContentTypeFromName(filePath.toString()) : mimeType;
|
return mimeType == null ? URLConnection.guessContentTypeFromName(filePath.toString()) : mimeType;
|
||||||
@@ -279,14 +279,14 @@ public class FileStorageUtils implements StorageUtils {
|
|||||||
* image 태그에서 호출 시 byte 배열로 return
|
* image 태그에서 호출 시 byte 배열로 return
|
||||||
*
|
*
|
||||||
* @param imagename
|
* @param imagename
|
||||||
* @return
|
* @return public String getContentType(String filename) {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public AttachmentImageResponseDto loadImage(String imagename) {
|
public AttachmentImageResponseDto loadImage(String imagename) {
|
||||||
try {
|
try {
|
||||||
Path imagePath = this.fileStorageLocation.resolve(imagename).normalize();
|
Path imagePath = this.fileStorageLocation.resolve(imagename).normalize();
|
||||||
try (InputStream is = new FileInputStream(imagePath.toFile())) {
|
try (InputStream is = new FileInputStream(imagePath.toFile())) {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
try (ByteArrayOutputStream buffer = new ByteArrayOutputStream()) {
|
||||||
int read;
|
int read;
|
||||||
byte[] data = new byte[(int) imagePath.toFile().length()];
|
byte[] data = new byte[(int) imagePath.toFile().length()];
|
||||||
while ((read = is.read(data, 0, data.length)) != -1) {
|
while ((read = is.read(data, 0, data.length)) != -1) {
|
||||||
@@ -298,6 +298,7 @@ public class FileStorageUtils implements StorageUtils {
|
|||||||
.data(data)
|
.data(data)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (FileNotFoundException | NoSuchFileException ex) {
|
} catch (FileNotFoundException | NoSuchFileException ex) {
|
||||||
// 파일을 찾을 수 없습니다.
|
// 파일을 찾을 수 없습니다.
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ public class FtpStorageUtils implements StorageUtils {
|
|||||||
* @param isTemp .temp 파일 생성 여부
|
* @param isTemp .temp 파일 생성 여부
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String storeFile(MultipartFile file, String basePath, boolean isTemp) {
|
public String storeFile(MultipartFile file, String basePath, boolean isTemp) throws BusinessMessageException {
|
||||||
String filename = getPhysicalFileName(file.getOriginalFilename(), isTemp);
|
String filename = getPhysicalFileName(file.getOriginalFilename(), isTemp);
|
||||||
|
|
||||||
if (filename.contains("..")) {
|
if (filename.contains("..")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user