fix(desktop): reject reserved remote profile names
This commit is contained in:
parent
e2c6f2ebc4
commit
6d3cb23d24
|
|
@ -166,6 +166,15 @@ test('normalizeSshConfig rejects unsafe remote profile mappings', () => {
|
|||
mode: 'ssh',
|
||||
host: 'box'
|
||||
})
|
||||
assert.deepEqual(normalizeSshConfig({ mode: 'ssh', host: 'box', remoteProfile: 'root' }), {
|
||||
mode: 'ssh',
|
||||
host: 'box'
|
||||
})
|
||||
assert.deepEqual(normalizeSshConfig({ mode: 'ssh', host: 'box', remoteProfile: 'default' }), {
|
||||
mode: 'ssh',
|
||||
host: 'box',
|
||||
remoteProfile: 'default'
|
||||
})
|
||||
})
|
||||
|
||||
test('normalizeSshConfig handles IPv6 and strict port bounds', () => {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ const RT_COOKIE_VARIANTS = ['__Host-hermes_session_rt', '__Secure-hermes_session
|
|||
// cookies above. `privy-token` is the access token (the required signal);
|
||||
// variants cover the secured-prefix forms and the older `privy-session` name.
|
||||
const PRIVY_SESSION_COOKIE_VARIANTS = ['__Host-privy-token', '__Secure-privy-token', 'privy-token', 'privy-session']
|
||||
// Keep this aligned with hermes_cli.profiles.validate_profile_name(). `default`
|
||||
// is the built-in root alias; these names cannot be created as profiles.
|
||||
const RESERVED_REMOTE_PROFILES = new Set(['hermes', 'test', 'tmp', 'root', 'sudo'])
|
||||
|
||||
function normalizeRemoteBaseUrl(rawUrl) {
|
||||
let value = String(rawUrl || '').trim()
|
||||
|
|
@ -287,7 +290,7 @@ function normalizeSshConfig(entry) {
|
|||
// historical same-name behavior in the caller.
|
||||
const remoteProfile = String(entry.remoteProfile || '').trim()
|
||||
|
||||
if (/^[a-z0-9][a-z0-9_-]{0,63}$/.test(remoteProfile)) {
|
||||
if (/^[a-z0-9][a-z0-9_-]{0,63}$/.test(remoteProfile) && !RESERVED_REMOTE_PROFILES.has(remoteProfile)) {
|
||||
out.remoteProfile = remoteProfile
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue