MCPcopy
hub / github.com/openai/plugins / bounded_json_text

Function bounded_json_text

plugins/codex-security/scripts/finding_preview.py:247–262  ·  view source on GitHub ↗
(value: str, maximum_bytes: int)

Source from the content-addressed store, hash-verified

245
246
247def bounded_json_text(value: str, maximum_bytes: int) -> tuple[str, int]:
248 low = 0
249 high = len(value)
250 selected = ""
251 selected_size = 2
252 while low <= high:
253 midpoint = (low + high) // 2
254 candidate = value[:midpoint]
255 size = len(json.dumps(candidate, separators=(",", ":")).encode("utf-8"))
256 if size <= maximum_bytes:
257 selected = candidate
258 selected_size = size
259 low = midpoint + 1
260 else:
261 high = midpoint - 1
262 return selected, selected_size
263
264
265if __name__ == "__main__":

Callers 3

bounded_finding_detailsFunction · 0.85
bounded_code_evidenceFunction · 0.85
bounded_json_valueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected