Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Schedule 도메인의 반복 일정과 관련된 필드값을 Embedded로 분리 #70

Merged
merged 5 commits into from
Feb 8, 2025

Conversation

KIMSEI1124
Copy link
Member

@KIMSEI1124 KIMSEI1124 commented Feb 8, 2025

📑 개요

✅ PR 체크리스트


  • 🔀 PR 제목의 형식을 잘 작성했나요?
  • 💯 테스트는 잘 통과했나요?
  • 🏗️ 빌드는 성공했나요?
  • 🧹 불필요한 코드는 제거했나요?
  • 💭 이슈는 등록했나요?
  • 🏷️ 라벨은 등록했나요?

🚀 상세 작업 내용


  • 패키지 분리
.
└── jpacalendardomain
    ├── calendar
    │   ├── data
    │   │   └── InviteStatus.java
    │   ├── domain
    │   │   ├── Calendar.java
    │   │   ├── MemberCalendar.java
    │   │   └── MemberCalendarId.java
    │   └── repository
    └── schedule
        ├── data
        │   ├── ConvertibleSchedule.java
        │   └── ConvertibleScheduleInfo.java
        ├── domain
        │   ├── Schedule.java
        │   ├── ScheduleInfo.java
        │   └── embedded
        │       ├── Repetition.java
        │       └── RepetitionCycle.java
        ├── mapper
        │   ├── ScheduleInfoMapper.java
        │   └── ScheduleMapper.java
        └── repository
            ├── ScheduleInfoRepository.java
            └── ScheduleRepository.java

기존에 같이 있던 CalendarSchedule를 분리하였습니다.

  • Embedded 클래스 생성
@AllArgsConstructor
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@Embeddable
public class Repetition {
	@Column(name = "repetition_start_date")
	private LocalDate startDate;

	@Column(name = "repetition_end_date")
	private LocalDate endDate;

	@Getter
	@Enumerated(EnumType.STRING)
	private RepetitionCycle repetitionCycle; // 반복 주기 (일, 주, 달, 년)

	@Column(name = "day_of_week")
	private Integer dayOfWeek; // 반복 요일: Bit Masking

	@Column(name = "week_interval")
	private Integer weekInterval; // 주 반복 (1~3)
}

📁 ETC


현재 진행중인 이슈와 충돌 가능성이 매우 큽니다. 그러므로 @jiwon83 께서 확인해주시고, 진행중인 이슈 완료시 해당 PR을 머지하는 방식으로 해야할 것 같습니다.

close: #56

@KIMSEI1124 KIMSEI1124 requested a review from jiwon83 February 8, 2025 05:54
@KIMSEI1124 KIMSEI1124 self-assigned this Feb 8, 2025
@KIMSEI1124 KIMSEI1124 changed the title Feat/#56 Schedule 도메인의 반복 일정과 관련된 필드값을 Embedded로 분리 Feb 8, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schedule과 Repetition을 객체지향으로 분리해서 반복 속성을 따로 관리하기에 더 편해진 것 같네요 b!

originalImagePath.toAbsolutePath().toString(),
"-quality", "50",
avifImagePath.toAbsolutePath().toString()
"convert",

Check failure

Code scanning / CodeQL

Uncontrolled command line Critical

This command line depends on a
user-provided value
.
This command line depends on a
user-provided value
.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to ensure that the file paths derived from user input are properly validated and sanitized before being used in the ProcessBuilder. This can be achieved by checking that the file paths do not contain any malicious characters or sequences that could lead to command injection. Additionally, we can use a whitelist approach to ensure that only valid file extensions are allowed.

The best way to fix the problem without changing existing functionality is to add a method that validates the file paths and call this method before constructing the ProcessBuilder. This method should check for any invalid characters and ensure that the file paths are within the expected directory.

Suggested changeset 1
application/wypl-image/src/main/java/com/wypl/wyplimage/image/ImageMagickConvert.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/application/wypl-image/src/main/java/com/wypl/wyplimage/image/ImageMagickConvert.java b/application/wypl-image/src/main/java/com/wypl/wyplimage/image/ImageMagickConvert.java
--- a/application/wypl-image/src/main/java/com/wypl/wyplimage/image/ImageMagickConvert.java
+++ b/application/wypl-image/src/main/java/com/wypl/wyplimage/image/ImageMagickConvert.java
@@ -68,2 +68,4 @@
 	private void imageConvertProcess(Path originalImagePath, Path avifImagePath) {
+		validateFilePath(originalImagePath);
+		validateFilePath(avifImagePath);
 		ProcessBuilder processBuilder = new ProcessBuilder(
@@ -85,2 +87,9 @@
 		}
+	}
+
+	private void validateFilePath(Path filePath) {
+		String pathString = filePath.toString();
+		if (pathString.contains("..") || pathString.contains(";") || pathString.contains("&")) {
+			throw new ImageException(ImageErrorCode.INVALID_FILE_PATH);
+		}
 	}
EOF
@@ -68,2 +68,4 @@
private void imageConvertProcess(Path originalImagePath, Path avifImagePath) {
validateFilePath(originalImagePath);
validateFilePath(avifImagePath);
ProcessBuilder processBuilder = new ProcessBuilder(
@@ -85,2 +87,9 @@
}
}

private void validateFilePath(Path filePath) {
String pathString = filePath.toString();
if (pathString.contains("..") || pathString.contains(";") || pathString.contains("&")) {
throw new ImageException(ImageErrorCode.INVALID_FILE_PATH);
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link
Member

@jiwon83 jiwon83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@KIMSEI1124 KIMSEI1124 changed the title Schedule 도메인의 반복 일정과 관련된 필드값을 Embedded로 분리 [Refactor] Schedule 도메인의 반복 일정과 관련된 필드값을 Embedded로 분리 Feb 8, 2025
@KIMSEI1124 KIMSEI1124 changed the title [Refactor] Schedule 도메인의 반복 일정과 관련된 필드값을 Embedded로 분리 Refactor: Schedule 도메인의 반복 일정과 관련된 필드값을 Embedded로 분리 Feb 8, 2025
@KIMSEI1124 KIMSEI1124 merged commit 0078793 into dev Feb 8, 2025
2 of 3 checks passed
@KIMSEI1124 KIMSEI1124 deleted the feat/#56 branch February 8, 2025 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Schedule 도메인의 반복 일정과 관련된 필드값을 Embedded로 분리한다.
2 participants