feat: safely control Shell Target

This commit is contained in:
proxyctl coordinator
2026-07-17 02:59:41 +08:00
parent 4e3f780eba
commit 12e857932b
15 changed files with 1552 additions and 16 deletions
+7 -1
View File
@@ -172,10 +172,16 @@ func normalizeBypassEntry(raw string) (string, error) {
var credentialPattern = regexp.MustCompile(`(?i)(https?|socks5h?)://([^/@\s:]+):([^@\s]*)@`)
// RedactText removes URL passwords from diagnostic text without requiring the
// surrounding text to be a valid URL.
func RedactText(value string) string {
return credentialPattern.ReplaceAllString(value, `${1}://${2}:REDACTED@`)
}
func ObscureURL(value string) string {
u, err := url.Parse(value)
if err != nil || u.User == nil {
return credentialPattern.ReplaceAllString(value, `${1}://${2}:REDACTED@`)
return RedactText(value)
}
if _, present := u.User.Password(); !present {
return value
+10
View File
@@ -112,6 +112,16 @@ func (systemIdentityEnvironment) LookupEnv(name string) (string, bool) {
return os.LookupEnv(name)
}
// SystemCurrentUser and SystemLookupUser expose the same injectable identity model
// to user-scoped Target configuration without duplicating OS account parsing.
func SystemCurrentUser() (UserIdentity, error) {
return systemIdentityEnvironment{}.CurrentUser()
}
func SystemLookupUser(name string) (UserIdentity, error) {
return systemIdentityEnvironment{}.LookupUser(name)
}
func ConfigPath() (string, error) {
configuration, err := ResolveConfigurationForCurrentProcess()
return configuration.Path, err