-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/system hardening #92
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
Changes from all commits
d729462
2f359bc
d752aa6
88e0ac4
a0c8999
2bea6fc
f828d9a
6f50eec
3930380
82f2a2a
5ee99b9
28929c9
04a8a48
15495b7
0c5992f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { Menu } from 'electron'; | ||
| import { buildMenuTemplate } from './menu'; | ||
|
|
||
| export function registerMenu(): void { | ||
| const menu = Menu.buildFromTemplate(buildMenuTemplate()); | ||
| export function registerMenu(currentTheme: string): void { | ||
| const menu = Menu.buildFromTemplate(buildMenuTemplate(currentTheme)); | ||
| Menu.setApplicationMenu(menu); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,12 +39,13 @@ export function validatePath(filePath: string) { | |
| // Prevent access to sensitive OS system folders | ||
| const lower = resolvedPath.toLowerCase(); | ||
| if (process.platform === 'win32') { | ||
| const sysDrive = (process.env.SystemDrive ?? 'C:').toLowerCase(); | ||
| const forbiddenPrefixes = [ | ||
| 'c:\\windows\\', | ||
| 'c:\\winnt\\', | ||
| 'c:\\boot\\', | ||
| 'c:\\system volume information\\', | ||
| 'c:\\$recycle.bin\\', | ||
| `${sysDrive}\\windows\\`, | ||
| `${sysDrive}\\winnt\\`, | ||
| `${sysDrive}\\boot\\`, | ||
| `${sysDrive}\\system volume information\\`, | ||
| `${sysDrive}\\$recycle.bin\\`, | ||
|
Comment on lines
+42
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Block protected Windows folders on all volumes, not only On Line 42 and Lines 44-48, forbidden prefixes are derived only from Suggested fix- const sysDrive = (process.env.SystemDrive ?? 'C:').toLowerCase();
+ const sysDrive = (process.env.SystemDrive ?? 'C:').toLowerCase();
+ const driveMatch = lower.match(/^([a-z]:)\\/);
+ if (!driveMatch) return false;
+ const inputDrive = driveMatch[1];
const forbiddenPrefixes = [
`${sysDrive}\\windows\\`,
`${sysDrive}\\winnt\\`,
`${sysDrive}\\boot\\`,
- `${sysDrive}\\system volume information\\`,
- `${sysDrive}\\$recycle.bin\\`,
+ `${inputDrive}\\system volume information\\`,
+ `${inputDrive}\\$recycle.bin\\`,
];As per coding guidelines: "File/folder access must guard path traversal, missing files, permissions, symlinks, and deleted watched files." 🤖 Prompt for AI Agents |
||
| ]; | ||
| if (forbiddenPrefixes.some((p) => lower === p.slice(0, -1) || lower.startsWith(p))) { | ||
| return false; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |||||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||||||
| <meta | ||||||
| http-equiv="Content-Security-Policy" | ||||||
| content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:" | ||||||
| content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:" | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Harden CSP further with explicit deny directives. This policy still omits Suggested CSP tightening- content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:"
+ content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| /> | ||||||
| </head> | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,6 @@ | |
| title: Architecture | ||
| --- | ||
|
|
||
| # Architecture | ||
|
|
||
| # Architecture Overview | ||
|
|
||
| ## 1. System Communication Flow | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,6 @@ | |
| title: Architecture | ||
| --- | ||
|
|
||
| # Architecture | ||
|
|
||
| # Architecture Overview | ||
|
|
||
| ## 1. System Communication Flow | ||
|
|
||
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.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: mindfiredigital/markdown-reader
Length of output: 1112
🏁 Script executed:
Repository: mindfiredigital/markdown-reader
Length of output: 118
🏁 Script executed:
Repository: mindfiredigital/markdown-reader
Length of output: 118
🏁 Script executed:
Repository: mindfiredigital/markdown-reader
Length of output: 3377
🏁 Script executed:
Repository: mindfiredigital/markdown-reader
Length of output: 792
🏁 Script executed:
Repository: mindfiredigital/markdown-reader
Length of output: 5615
Avoid
autoUpdater.removeAllListeners(...)clobbering other handlers (apps/main-processor/src/updater.ts lines 9-11): those calls remove all listeners for the given events; even though this repo currently only registers these handlers insetupAutoUpdater, a second feature (or anothercreateWindow()run) could silently wipe it. Keep module-scoped handler references and useautoUpdater.off('update-available', handler)/off('update-downloaded', handler)/off('error', handler)(orremoveListener) before re-registering.🤖 Prompt for AI Agents