修复投递结果恢复并隔离远程验收资源

This commit is contained in:
xuans committed 2026-09-17 11:21:49 +08:00
1 parent 5198e2d515
commit 1d202934cf
13 files changed
+511 -34

No files matched your search

+6 -2
View File
@@ -203,6 +203,10 @@ func isAbsoluteUserCertificatePath(value string) bool {
if filepath.IsAbs(value) {
return true
}
// 非 Windows 主机也要识别盘符,避免把异平台路径静默拼到项目目录。
if len(value) >= 2 && value[1] == ':' && ((value[0] >= 'A' && value[0] <= 'Z') || (value[0] >= 'a' && value[0] <= 'z')) {
return true
}
volume := filepath.VolumeName(value)
return volume != "" || strings.HasPrefix(value, `\\`) || strings.HasPrefix(value, "//")
}
@@ -218,8 +222,8 @@ func validateUserCertificatePaths(privatePath, publicPath string) (string, strin
}
path := strings.TrimSpace(value)
if isAbsoluteUserCertificatePath(path) {
if filepath.VolumeName(path) != "" && !filepath.IsAbs(path) {
return "", nil, newUserCertificateError("SSL 路径必须是完整的绝对路径")
if !filepath.IsAbs(path) {
return "", nil, newUserCertificateError("SSL 路径必须是当前服务器支持的完整绝对路径")
}
} else {
path = filepath.Join(rootPath, path)
@@ -54,12 +54,13 @@ func TestIsAbsoluteUserCertificatePathRecognizesWindowsPaths(t *testing.T) {
cases := []string{
`C:\outside\private.key`,
`D:/outside/public.crt`,
`C:private.key`,
`\\server\share\private.key`,
`//server/share/public.crt`,
}
for _, value := range cases {
if !isAbsoluteUserCertificatePath(value) {
t.Errorf("path %q was accepted", value)
t.Errorf("path %q was not recognized", value)
}
}
}
@@ -73,6 +74,17 @@ func TestIsAbsoluteUserCertificatePathRejectsEmptyAndAcceptsRelative(t *testing.
}
}
func TestValidateUserCertificatePathsRejectsNonNativeAbsolutePath(t *testing.T) {
for _, path := range []string{`C:private.key`, `C:\outside\private.key`, `\\server\share\private.key`} {
if filepath.IsAbs(path) {
continue
}
if _, _, err := validateUserCertificatePaths(path, path); err == nil || err.Error() != "SSL 路径必须是当前服务器支持的完整绝对路径" {
t.Fatalf("non-native path %q: %v", path, err)
}
}
}
func TestApplyManagedSSLReferenceDoesNotPersistLegacyPaths(t *testing.T) {
cfg := &config.Config{
SSLPrivateKeyPath: "config/ssl/private.key",