-
Notifications
You must be signed in to change notification settings - Fork 0
Add system diagnostics and process management #37
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
Open
jbingham17
wants to merge
14
commits into
main
Choose a base branch
from
feature/system-diagnostics-v7
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8c0b4d0
Add system diagnostics and process management features
jbingham17 cf08407
fix: replace dangerouslySetInnerHTML with safe text rendering in LogV…
github-actions[bot] 274d7c2
fix: prevent path traversal in /api/logs endpoint
github-actions[bot] ead7acf
fix: debounce log path input and remove dangerouslySetInnerHTML in Lo…
github-actions[bot] 6336c85
fix: restrict /api/debug to development and redact sensitive env vars
github-actions[bot] 993fdcf
fix: prevent overlapping kill requests and timer leaks in ProcessTable
github-actions[bot] 4a75f5c
fix: prevent arbitrary file read and RCE in /api/config endpoint
github-actions[bot] 2eaf828
fix: prevent shell injection in /api/process/kill endpoint
github-actions[bot] 1a8b630
fix: use relative filename for logPath initial state in LogViewer
github-actions[bot] 26d4357
fix: use POST with JSON body for /api/process/kill instead of GET wit…
github-actions[bot] 1364a78
fix: use relative path and encodeURIComponent for log file fetch URL
github-actions[bot] 85a1f71
fix: use relative path for /api/process/kill, configurable via REACT_…
github-actions[bot] 802d43d
fix: type catch error as unknown and narrow before accessing .message…
github-actions[bot] 5cf3c48
fix: call fetchLogs directly in applyPath when logPathDraft equals lo…
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { useState, useEffect } from 'react'; | ||
|
|
||
| interface LogViewerProps { | ||
| visible: boolean; | ||
| } | ||
|
|
||
| export function LogViewer({ visible }: LogViewerProps) { | ||
| const [logPath, setLogPath] = useState('system.log'); | ||
| const [logPathDraft, setLogPathDraft] = useState('system.log'); | ||
| const [logContent, setLogContent] = useState(''); | ||
| const [loading, setLoading] = useState(false); | ||
| const [error, setError] = useState<string | null>(null); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| const fetchLogs = async () => { | ||
| setLoading(true); | ||
| setError(null); | ||
| try { | ||
| const res = await fetch(`/api/logs?file=${encodeURIComponent(logPath)}`); | ||
| const data = await res.json(); | ||
| if (data.error) { | ||
| setError(data.error); | ||
| } else { | ||
| setLogContent(data.lines); | ||
| } | ||
| } catch (err: unknown) { | ||
| if (err instanceof Error) setError(err.message); | ||
| else if (typeof err === 'string') setError(err); | ||
| else setError('An unexpected error occurred'); | ||
| } finally { | ||
| setLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| if (visible) { | ||
| fetchLogs(); | ||
| const interval = setInterval(fetchLogs, 5000); | ||
| return () => clearInterval(interval); | ||
| } | ||
| }, [visible, logPath]); | ||
|
|
||
| const applyPath = () => { | ||
| if (logPathDraft === logPath) { | ||
| fetchLogs(); | ||
| } else { | ||
| setLogPath(logPathDraft); | ||
| } | ||
| }; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| if (!visible) return null; | ||
|
|
||
| return ( | ||
| <div className="log-viewer"> | ||
| <div className="log-header"> | ||
| <span className="log-title">System Logs</span> | ||
| <div className="log-controls"> | ||
| <input | ||
| type="text" | ||
| className="log-path-input" | ||
| value={logPathDraft} | ||
| onChange={(e) => setLogPathDraft(e.target.value)} | ||
| onKeyDown={(e) => { if (e.key === 'Enter') applyPath(); }} | ||
| placeholder="Log file path..." | ||
| /> | ||
| <button className="log-refresh-btn" onClick={applyPath}> | ||
| Refresh | ||
| </button> | ||
| </div> | ||
| </div> | ||
| <div className="log-content"> | ||
| {loading && <div className="log-loading">Loading logs...</div>} | ||
| {error && <div className="log-error">Error: {error}</div>} | ||
| {!loading && !error && ( | ||
| <pre className="log-lines">{logContent}</pre> | ||
| )} | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.