Skip to content

Commit d3e7cf5

Browse files
committed
fix(egress): atomic URL+headers rotation and Kotlin binary compat
- Make URL and headers rotation atomic: skip URL update when headers validation fails, preventing bootstrap header leakage to new URL - Add source(InlineCredentialSource) and source(HTTPCredentialSource) overloads to Kotlin Credential.Builder for binary compatibility with existing callers compiled against the previous SDK
1 parent e7e73bf commit d3e7cf5

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

components/egress/pkg/credentialvault/source_http.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,19 @@ func (s *httpSource) fetch(ctx context.Context) (string, error) {
145145
}
146146
urlValid := result.URL == "" || validateHTTPSourceURL(result.URL) == nil
147147
headersValid := result.Headers == nil || validateHTTPSourceHeaders(result.Headers) == nil
148-
if urlValid && result.URL != "" {
149-
s.nextURL = result.URL
150-
if result.Headers == nil {
151-
s.nextHeaders = nil
148+
if urlValid && headersValid {
149+
if result.URL != "" {
150+
s.nextURL = result.URL
151+
if result.Headers == nil {
152+
s.nextHeaders = nil
153+
s.headersRotated = true
154+
}
155+
}
156+
if result.Headers != nil {
157+
s.nextHeaders = result.Headers
152158
s.headersRotated = true
153159
}
154160
}
155-
if urlValid && headersValid && result.Headers != nil {
156-
s.nextHeaders = result.Headers
157-
s.headersRotated = true
158-
}
159161
s.mu.Unlock()
160162

161163
return result.Value, nil

sdks/sandbox/kotlin/sandbox/src/main/kotlin/com/alibaba/opensandbox/sandbox/domain/models/sandboxes/CredentialVaultModels.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ class Credential private constructor(
172172
return this
173173
}
174174

175+
fun source(source: InlineCredentialSource): Builder {
176+
this.source = source as CredentialSource
177+
return this
178+
}
179+
180+
fun source(source: HTTPCredentialSource): Builder {
181+
this.source = source as CredentialSource
182+
return this
183+
}
184+
175185
fun inlineSource(value: String): Builder {
176186
this.source = InlineCredentialSource.of(value)
177187
return this

0 commit comments

Comments
 (0)