Support agent status hooks over SSH (#1865)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
export const PLUGIN_SOURCE_MAX_BYTES = 256 * 1024
|
||||
|
||||
export function assertPluginSourceUnderByteCap(fieldName: string, value: unknown): void {
|
||||
if (typeof value !== 'string') {
|
||||
return
|
||||
}
|
||||
// Why: the relay receives JSON strings over the wire; cap actual UTF-8
|
||||
// bytes instead of UTF-16 code units so non-ASCII source cannot bypass it.
|
||||
if (Buffer.byteLength(value, 'utf8') > PLUGIN_SOURCE_MAX_BYTES) {
|
||||
throw new Error(`${fieldName} exceeds ${PLUGIN_SOURCE_MAX_BYTES} byte cap`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user