-
Notifications
You must be signed in to change notification settings - Fork 0
feat : python add #14
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
Conversation
WalkthroughThis pull request introduces changes to the security configuration, adds a new notebook execution feature, and makes minor modifications to existing classes. The primary additions include a Changes
Sequence DiagramsequenceDiagram
participant Client
participant NotebookController
participant Python Process
Client->>NotebookController: POST /api/notebook/execute
NotebookController->>Python Process: Execute notebook script
Python Process-->>NotebookController: Capture process output
alt Successful Execution
NotebookController-->>Client: Return success message
else Execution Failure
NotebookController-->>Client: Return error message
end
Possibly related PRs
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/java/com/example/redunm/config/SecurityConfig.java(1 hunks)src/main/java/com/example/redunm/dto/SignUpRequest.java(0 hunks)src/main/java/com/example/redunm/python/NotebookController.java(1 hunks)src/main/java/com/example/redunm/python/NotebookService.java(1 hunks)
💤 Files with no reviewable changes (1)
- src/main/java/com/example/redunm/dto/SignUpRequest.java
✅ Files skipped from review due to trivial changes (1)
- src/main/java/com/example/redunm/python/NotebookService.java
🔇 Additional comments (5)
src/main/java/com/example/redunm/python/NotebookController.java (4)
1-2: Package location looks appropriate.
No issues detected for these lines.
3-6: Imports are valid and minimal.
All imports here are standard library or Spring imports. No immediate concerns.
7-10: Controller annotations and base URL
The @RestController and @RequestMapping("/api/notebook") usage is correct. Keep in mind to handle authorization if needed.
40-40: Class closing bracket
No issues here.
src/main/java/com/example/redunm/config/SecurityConfig.java (1)
Line range hint 40-60: Carefully review the impact of removing any default authentication requirement
By removing or not including .anyRequest().authenticated(), potentially all unspecified routes are publicly accessible. Confirm this aligns with your security requirements, especially for the new /api/notebook/execute endpoint, which may need protection.
Do you want me to provide a revised snippet restricting access to the /api/notebook/** endpoints if needed?
| @PostMapping("/execute") | ||
| public String executeNotebook(@RequestParam String notebookPath) { | ||
| try { | ||
| ProcessBuilder processBuilder = new ProcessBuilder( | ||
| "python", | ||
| "python/execute_notebook.py", | ||
| notebookPath | ||
| ); | ||
| processBuilder.redirectErrorStream(true); | ||
|
|
||
| Process process = processBuilder.start(); | ||
|
|
||
| BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); | ||
| StringBuilder output = new StringBuilder(); | ||
| String line; | ||
| while ((line = reader.readLine()) != null) { | ||
| output.append(line).append("\n"); | ||
| } | ||
|
|
||
| int exitCode = process.waitFor(); | ||
| if (exitCode == 0) { | ||
| return "Notebook 실행 성공: " + output.toString(); | ||
| } else { | ||
| return "Notebook 실행 실패: " + output.toString(); | ||
| } | ||
| } catch (Exception e) { | ||
| return "오류 발생: " + e.getMessage(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential shell injection / path validation risk
The user-supplied notebookPath is directly passed to the process builder arguments. This can allow arbitrary command execution if notebookPath is manipulated. Consider sanitizing or validating the notebookPath to mitigate security risks.
Possible resource management improvement
Consider using a timeout or asynchronous approach for large or long-running notebooks to avoid blocking the main thread.
Provide structured output
Currently, the output is returned as a single string. Returning structured JSON might improve clarity and integration on the frontend side.
Summary by CodeRabbit
New Features
Security Changes
Code Maintenance
NotebookServiceclass for future development