mirror of
https://github.com/Ryder-Sun/Meldwork.git
synced 2026-11-07 06:56:03 -10:00
Reject recognizable credentials in Connector endpoint paths
Prevent HTTP package paths from persisting recognizable plaintext or percent-encoded credentials. Checks: 79 Connector SDK, package and runtime tests.
This commit is contained in:
1 parent
dc4dd306b9
commit
72ff8c273b
2 files changed
+17
-1
No files matched your search
@@ -52,8 +52,9 @@ function safeTextSchema(max) {
|
||||
const httpsEndpointSchema = z.string().min(9).max(2048).superRefine((value, context) => {
|
||||
try {
|
||||
const parsed = new URL(value)
|
||||
const decodedPath = decodeURIComponent(parsed.pathname)
|
||||
if (parsed.protocol !== 'https:' || parsed.username || parsed.password
|
||||
|| parsed.search || parsed.hash) {
|
||||
|| parsed.search || parsed.hash || redactSecrets(decodedPath) !== decodedPath) {
|
||||
context.addIssue({ code: 'custom', message: 'HTTPS endpoint required' })
|
||||
}
|
||||
} catch {
|
||||
|
||||
@@ -100,6 +100,21 @@ function httpPackage(sessionOverrides = {}) {
|
||||
})
|
||||
}
|
||||
|
||||
test('HTTP connector packages reject recognizable credentials in endpoint paths', () => {
|
||||
const pkg = httpPackage()
|
||||
const create = endpoint => createAgentConnectorPackage({
|
||||
publisher: pkg.publisher,
|
||||
provider: { ...pkg.provider, config: { ...pkg.provider.config, endpoint } },
|
||||
manifest: pkg.manifest,
|
||||
})
|
||||
const token = `sk-${'a'.repeat(32)}`
|
||||
assert.throws(() => create(`https://connector.example.com/v1/${token}`),
|
||||
{ message: 'AGENT_CONNECTOR_PACKAGE_SCHEMA_INVALID' })
|
||||
assert.throws(() => create(`https://connector.example.com/v1/%73%6b%2d${'a'.repeat(32)}`),
|
||||
{ message: 'AGENT_CONNECTOR_PACKAGE_SCHEMA_INVALID' })
|
||||
assert.doesNotThrow(() => create('https://connector.example.com/v1/run'))
|
||||
})
|
||||
|
||||
test('concurrent HTTP Connector accounts use only their own credentials at the transport boundary', async t => {
|
||||
const requests = []
|
||||
const previous = process.env.OPENAI_API_KEY
|
||||
|
||||
Reference in new issue
Block a user