fix(review): 3 issues found in agent review of PR #41
BUG-3 (high): /api/profile/delete missing RuntimeError catch. When
deleting the active profile while an agent was running, delete_profile_api()
called switch_profile('default') which raises RuntimeError('Cannot switch
profiles while agent is running'). This propagated to the 500 handler
giving the user 'Internal server error' with no context. Added the same
except RuntimeError -> 409 pattern that /api/profile/switch already uses.
INFO-1 (defense-in-depth): /api/profile/create had no server-side name
validation before delegating to hermes_cli.validate_profile_name. Added
server-side ^[a-z0-9][a-z0-9_-]{0,63}$ check, consistent with client-side
regex in submitProfileCreate(). Prevents path-traversal-ish names from
reaching hermes_cli even if the client-side guard is bypassed.
INFO-2 (defense-in-depth): clone_from parameter was passed directly to
hermes_cli with no validation. Applied the same name regex check to
clone_from before delegating.
BUG-11 (low): toggleProfileDropdown() and toggleWsDropdown() could both
be open simultaneously. Added cross-dropdown close calls: opening the
profile dropdown now closes the workspace dropdown, and vice versa.
Tests: 415 passed, 0 failed.
This commit is contained in:
@@ -477,6 +477,7 @@ function toggleWsDropdown(){
|
||||
const open=dd.classList.contains('open');
|
||||
if(open){closeWsDropdown();}
|
||||
else{
|
||||
closeProfileDropdown(); // close profile dropdown if open
|
||||
loadWorkspaceList().then(data=>{
|
||||
renderWorkspaceDropdown(data.workspaces, S.session?S.session.workspace:'');
|
||||
dd.classList.add('open');
|
||||
@@ -642,6 +643,7 @@ function toggleProfileDropdown() {
|
||||
const dd = $('profileDropdown');
|
||||
if (!dd) return;
|
||||
if (dd.classList.contains('open')) { closeProfileDropdown(); return; }
|
||||
closeWsDropdown(); // close workspace dropdown if open
|
||||
api('/api/profiles').then(data => {
|
||||
renderProfileDropdown(data);
|
||||
dd.classList.add('open');
|
||||
|
||||
Reference in New Issue
Block a user