@openai/codex-security 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +306 -0
- package/_bundled_plugin/.app.json +20 -0
- package/_bundled_plugin/.codex-plugin/plugin.json +41 -0
- package/_bundled_plugin/.mcp.json +20 -0
- package/_bundled_plugin/assets/logo.png +0 -0
- package/_bundled_plugin/examples/completed-scan/coverage.json +22 -0
- package/_bundled_plugin/examples/completed-scan/findings.json +51 -0
- package/_bundled_plugin/examples/completed-scan/scan-manifest.json +43 -0
- package/_bundled_plugin/mcp/mcp-app.html.br +0 -0
- package/_bundled_plugin/mcp/server.mjs +24 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/preflight/capability-profiles.toml +179 -0
- package/_bundled_plugin/references/config-preflight.md +115 -0
- package/_bundled_plugin/references/final-report.md +205 -0
- package/_bundled_plugin/references/finding-detail-fields.md +162 -0
- package/_bundled_plugin/references/sarif-adapter.md +26 -0
- package/_bundled_plugin/references/scan-artifacts.md +116 -0
- package/_bundled_plugin/references/scan-contract.md +164 -0
- package/_bundled_plugin/references/security-guidance.md +15 -0
- package/_bundled_plugin/references/shared-hard-rules.md +15 -0
- package/_bundled_plugin/references/static-finding-assessment.md +75 -0
- package/_bundled_plugin/schemas/coverage.schema.json +228 -0
- package/_bundled_plugin/schemas/findings.schema.json +359 -0
- package/_bundled_plugin/schemas/scan-manifest.schema.json +332 -0
- package/_bundled_plugin/scripts/config_preflight.py +901 -0
- package/_bundled_plugin/scripts/deep_scan_config.py +108 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +1547 -0
- package/_bundled_plugin/scripts/filesystem_identity.py +30 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +2208 -0
- package/_bundled_plugin/scripts/finding_preview.py +270 -0
- package/_bundled_plugin/scripts/generate_rank_input.py +1013 -0
- package/_bundled_plugin/scripts/normalize_candidates.py +320 -0
- package/_bundled_plugin/scripts/rank_preview.py +968 -0
- package/_bundled_plugin/scripts/report_projection.py +844 -0
- package/_bundled_plugin/scripts/resolve_security_md.py +158 -0
- package/_bundled_plugin/scripts/snapshot_sqlite.py +26 -0
- package/_bundled_plugin/scripts/validate_report_format.py +138 -0
- package/_bundled_plugin/scripts/validate_scan_contract.py +108 -0
- package/_bundled_plugin/scripts/validate_tracking_source.py +92 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +612 -0
- package/_bundled_plugin/scripts/workbench/__init__.py +1 -0
- package/_bundled_plugin/scripts/workbench/handoff.py +238 -0
- package/_bundled_plugin/scripts/workbench_cli.py +325 -0
- package/_bundled_plugin/scripts/workbench_constants.py +81 -0
- package/_bundled_plugin/scripts/workbench_db.py +3728 -0
- package/_bundled_plugin/scripts/workbench_native_indexes.py +242 -0
- package/_bundled_plugin/scripts/workbench_progress.py +226 -0
- package/_bundled_plugin/scripts/workbench_remediation.py +125 -0
- package/_bundled_plugin/scripts/workbench_scan_history.py +829 -0
- package/_bundled_plugin/scripts/workbench_scan_start.py +149 -0
- package/_bundled_plugin/scripts/workbench_schema.py +714 -0
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +99 -0
- package/_bundled_plugin/scripts/workbench_target.py +469 -0
- package/_bundled_plugin/scripts/workbench_target_state.py +63 -0
- package/_bundled_plugin/scripts/workbench_validation.py +294 -0
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +117 -0
- package/_bundled_plugin/skills/attack-path-analysis/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/attack-path-analysis/references/attack-path-facts.md +76 -0
- package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +153 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +166 -0
- package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/define-security-policy/SKILL.md +93 -0
- package/_bundled_plugin/skills/define-security-policy/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +155 -0
- package/_bundled_plugin/skills/finding-discovery/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/fix-finding/SKILL.md +112 -0
- package/_bundled_plugin/skills/fix-finding/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +240 -0
- package/_bundled_plugin/skills/propose-security-hardening/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +424 -0
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +167 -0
- package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/security-scan/SKILL.md +42 -0
- package/_bundled_plugin/skills/security-scan/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/security-scan/references/repository-wide-scan.md +48 -0
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +85 -0
- package/_bundled_plugin/skills/threat-model/SKILL.md +59 -0
- package/_bundled_plugin/skills/threat-model/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/threat-model/references/threat-model-guidance.md +48 -0
- package/_bundled_plugin/skills/track-findings/SKILL.md +222 -0
- package/_bundled_plugin/skills/track-findings/agents/openai.yaml +6 -0
- package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +54 -0
- package/_bundled_plugin/skills/track-findings/references/jira.md +77 -0
- package/_bundled_plugin/skills/triage-finding/SKILL.md +342 -0
- package/_bundled_plugin/skills/triage-finding/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +168 -0
- package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +62 -0
- package/_bundled_plugin/skills/triage-finding/references/triage-result-contract.md +108 -0
- package/_bundled_plugin/skills/validation/SKILL.md +110 -0
- package/_bundled_plugin/skills/validation/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/validation/references/validation-guidance.md +122 -0
- package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +263 -0
- package/_bundled_plugin/skills/vulnerability-writeup/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/vulnerability-writeup/references/report-format.md +104 -0
- package/bin/codex-security.mjs +26 -0
- package/dist/api.d.ts +112 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +1051 -0
- package/dist/api.js.map +1 -0
- package/dist/auth.d.ts +29 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +246 -0
- package/dist/auth.js.map +1 -0
- package/dist/bulk-scan-discovery.d.ts +35 -0
- package/dist/bulk-scan-discovery.d.ts.map +1 -0
- package/dist/bulk-scan-discovery.js +217 -0
- package/dist/bulk-scan-discovery.js.map +1 -0
- package/dist/cli.d.ts +67 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +2128 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +199 -0
- package/dist/config.js.map +1 -0
- package/dist/contract.d.ts +21 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +848 -0
- package/dist/contract.js.map +1 -0
- package/dist/cost.d.ts +30 -0
- package/dist/cost.d.ts.map +1 -0
- package/dist/cost.js +280 -0
- package/dist/cost.js.map +1 -0
- package/dist/errors.d.ts +38 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +52 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge-base.d.ts +7 -0
- package/dist/knowledge-base.d.ts.map +1 -0
- package/dist/knowledge-base.js +181 -0
- package/dist/knowledge-base.js.map +1 -0
- package/dist/models.d.ts +231 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +3 -0
- package/dist/models.js.map +1 -0
- package/dist/multiscan.d.ts +30 -0
- package/dist/multiscan.d.ts.map +1 -0
- package/dist/multiscan.js +397 -0
- package/dist/multiscan.js.map +1 -0
- package/dist/result.d.ts +39 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +71 -0
- package/dist/result.js.map +1 -0
- package/dist/runtime.d.ts +69 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +997 -0
- package/dist/runtime.js.map +1 -0
- package/dist/scan-comparison.d.ts +42 -0
- package/dist/scan-comparison.d.ts.map +1 -0
- package/dist/scan-comparison.js +153 -0
- package/dist/scan-comparison.js.map +1 -0
- package/dist/scan-history-renderer.d.ts +13 -0
- package/dist/scan-history-renderer.d.ts.map +1 -0
- package/dist/scan-history-renderer.js +297 -0
- package/dist/scan-history-renderer.js.map +1 -0
- package/dist/targets.d.ts +39 -0
- package/dist/targets.d.ts.map +1 -0
- package/dist/targets.js +295 -0
- package/dist/targets.js.map +1 -0
- package/dist/trusted-executable.d.ts +6 -0
- package/dist/trusted-executable.d.ts.map +1 -0
- package/dist/trusted-executable.js +77 -0
- package/dist/trusted-executable.js.map +1 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +42 -0
- package/dist/version.js.map +1 -0
- package/dist/worker-progress.d.ts +13 -0
- package/dist/worker-progress.d.ts.map +1 -0
- package/dist/worker-progress.js +113 -0
- package/dist/worker-progress.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"""Bound structured finding details for workbench list responses."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
12
|
+
from workbench_constants import (
|
|
13
|
+
FINDING_ATTACK_PATH_PREVIEW_BYTES,
|
|
14
|
+
FINDING_CODE_EVIDENCE_LIMIT,
|
|
15
|
+
FINDING_CODE_EVIDENCE_SNIPPET_BYTES,
|
|
16
|
+
FINDING_DETAILS_PREVIEW_BYTES,
|
|
17
|
+
FINDING_EVIDENCE_EXCERPT_BYTES,
|
|
18
|
+
FINDING_ROOT_CAUSE_PREVIEW_BYTES,
|
|
19
|
+
FINDING_VALIDATION_PREVIEW_BYTES,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def bounded_finding_details(value: Any) -> dict[str, Any]:
|
|
24
|
+
if not isinstance(value, dict):
|
|
25
|
+
return {}
|
|
26
|
+
prepared: dict[str, Any] = {}
|
|
27
|
+
for aliases, maximum_bytes, priority_keys, reserved_fields in (
|
|
28
|
+
(
|
|
29
|
+
("rootCause", "root_cause"),
|
|
30
|
+
FINDING_ROOT_CAUSE_PREVIEW_BYTES,
|
|
31
|
+
(
|
|
32
|
+
"summary",
|
|
33
|
+
"description",
|
|
34
|
+
"detail",
|
|
35
|
+
"cause",
|
|
36
|
+
"rationale",
|
|
37
|
+
"why",
|
|
38
|
+
"explanation",
|
|
39
|
+
"evidenceRefs",
|
|
40
|
+
"evidence_refs",
|
|
41
|
+
),
|
|
42
|
+
(
|
|
43
|
+
(("summary", "description", "detail", "cause", "rationale", "why"), 1_000),
|
|
44
|
+
(("evidenceRefs", "evidence_refs"), 400),
|
|
45
|
+
),
|
|
46
|
+
),
|
|
47
|
+
(
|
|
48
|
+
("validation",),
|
|
49
|
+
FINDING_VALIDATION_PREVIEW_BYTES,
|
|
50
|
+
(
|
|
51
|
+
"summary",
|
|
52
|
+
"conclusion",
|
|
53
|
+
"method",
|
|
54
|
+
"status",
|
|
55
|
+
"disposition",
|
|
56
|
+
"result",
|
|
57
|
+
"rationale",
|
|
58
|
+
"evidenceRef",
|
|
59
|
+
"evidence_ref",
|
|
60
|
+
"evidenceRefs",
|
|
61
|
+
"evidence_refs",
|
|
62
|
+
"assertions",
|
|
63
|
+
"evidence",
|
|
64
|
+
"limitations",
|
|
65
|
+
),
|
|
66
|
+
(
|
|
67
|
+
(("summary", "conclusion", "rationale", "detail", "disposition"), 800),
|
|
68
|
+
(("method",), 256),
|
|
69
|
+
(("status",), 128),
|
|
70
|
+
(("evidenceRefs", "evidence_refs"), 400),
|
|
71
|
+
(("assertions",), 400),
|
|
72
|
+
(("evidence",), 400),
|
|
73
|
+
(("limitations",), 400),
|
|
74
|
+
),
|
|
75
|
+
),
|
|
76
|
+
(
|
|
77
|
+
("attackPath",),
|
|
78
|
+
FINDING_ATTACK_PATH_PREVIEW_BYTES,
|
|
79
|
+
(
|
|
80
|
+
"narrative",
|
|
81
|
+
"summary",
|
|
82
|
+
"description",
|
|
83
|
+
"dataFlow",
|
|
84
|
+
"data_flow",
|
|
85
|
+
"dataflow",
|
|
86
|
+
"path",
|
|
87
|
+
"reachability",
|
|
88
|
+
"steps",
|
|
89
|
+
"authScope",
|
|
90
|
+
"auth_scope",
|
|
91
|
+
"vector",
|
|
92
|
+
"preconditions",
|
|
93
|
+
"assumptions",
|
|
94
|
+
"impact",
|
|
95
|
+
"likelihood",
|
|
96
|
+
"evidenceRefs",
|
|
97
|
+
"evidence_refs",
|
|
98
|
+
),
|
|
99
|
+
(
|
|
100
|
+
(("narrative", "summary", "description"), 600),
|
|
101
|
+
(("dataFlow", "data_flow", "dataflow", "path"), 600),
|
|
102
|
+
(("reachability",), 500),
|
|
103
|
+
(("steps",), 500),
|
|
104
|
+
(("authScope", "auth_scope"), 200),
|
|
105
|
+
(("vector",), 200),
|
|
106
|
+
(("preconditions",), 500),
|
|
107
|
+
(("assumptions",), 300),
|
|
108
|
+
(("evidenceRefs", "evidence_refs"), 300),
|
|
109
|
+
),
|
|
110
|
+
),
|
|
111
|
+
):
|
|
112
|
+
key = next((alias for alias in aliases if alias in value), None)
|
|
113
|
+
if key is not None:
|
|
114
|
+
prepared[key] = bounded_finding_section(
|
|
115
|
+
value[key],
|
|
116
|
+
maximum_bytes,
|
|
117
|
+
priority_keys,
|
|
118
|
+
reserved_fields,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
writeup = value.get("writeup")
|
|
122
|
+
if isinstance(writeup, dict) and isinstance(writeup.get("reportPath"), str):
|
|
123
|
+
prepared["writeup"] = {"reportPath": bounded_json_text(writeup["reportPath"], 512)[0]}
|
|
124
|
+
|
|
125
|
+
evidence_key = next(
|
|
126
|
+
(key for key in ("codeEvidence", "code_evidence") if key in value),
|
|
127
|
+
None,
|
|
128
|
+
)
|
|
129
|
+
if evidence_key is not None:
|
|
130
|
+
prepared[evidence_key] = bounded_code_evidence(value[evidence_key])
|
|
131
|
+
|
|
132
|
+
for key in (
|
|
133
|
+
"confidence",
|
|
134
|
+
"detectedAt",
|
|
135
|
+
"evidence",
|
|
136
|
+
"evidenceExcerpt",
|
|
137
|
+
"identity",
|
|
138
|
+
"provenance",
|
|
139
|
+
"ruleId",
|
|
140
|
+
"severity",
|
|
141
|
+
"status",
|
|
142
|
+
"taxonomy",
|
|
143
|
+
):
|
|
144
|
+
if key in value:
|
|
145
|
+
prepared[key] = (
|
|
146
|
+
bounded_json_text(value[key], FINDING_EVIDENCE_EXCERPT_BYTES)[0]
|
|
147
|
+
if key == "evidenceExcerpt" and isinstance(value[key], str)
|
|
148
|
+
else value[key]
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
budget = [FINDING_DETAILS_PREVIEW_BYTES]
|
|
152
|
+
bounded = bounded_json_value(prepared, budget)
|
|
153
|
+
return bounded if isinstance(bounded, dict) else {}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def bounded_finding_section(
|
|
157
|
+
value: Any,
|
|
158
|
+
maximum_bytes: int,
|
|
159
|
+
priority_keys: tuple[str, ...],
|
|
160
|
+
reserved_fields: tuple[tuple[tuple[str, ...], int], ...],
|
|
161
|
+
) -> Any:
|
|
162
|
+
if not isinstance(value, dict):
|
|
163
|
+
return bounded_json_value(value, [maximum_bytes])
|
|
164
|
+
ordered: dict[str, Any] = {}
|
|
165
|
+
for aliases, field_bytes in reserved_fields:
|
|
166
|
+
key = next((alias for alias in aliases if alias in value), None)
|
|
167
|
+
if key is not None:
|
|
168
|
+
ordered[key] = bounded_json_value(value[key], [field_bytes])
|
|
169
|
+
for key in (*priority_keys, *value):
|
|
170
|
+
if key in value and key not in ordered:
|
|
171
|
+
ordered[key] = value[key]
|
|
172
|
+
evidence_key = next(
|
|
173
|
+
(key for key in ("codeEvidence", "code_evidence") if key in ordered),
|
|
174
|
+
None,
|
|
175
|
+
)
|
|
176
|
+
if evidence_key is not None:
|
|
177
|
+
ordered[evidence_key] = bounded_code_evidence(ordered[evidence_key])
|
|
178
|
+
ordered.pop("code_evidence" if evidence_key == "codeEvidence" else "codeEvidence", None)
|
|
179
|
+
return bounded_json_value(ordered, [maximum_bytes])
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def bounded_code_evidence(value: Any) -> Any:
|
|
183
|
+
if not isinstance(value, list):
|
|
184
|
+
return value
|
|
185
|
+
bounded = []
|
|
186
|
+
for item in value[:FINDING_CODE_EVIDENCE_LIMIT]:
|
|
187
|
+
if not isinstance(item, dict):
|
|
188
|
+
bounded.append(item)
|
|
189
|
+
continue
|
|
190
|
+
evidence = dict(item)
|
|
191
|
+
code = evidence.get("code")
|
|
192
|
+
if isinstance(code, str):
|
|
193
|
+
evidence["code"] = bounded_json_text(
|
|
194
|
+
code,
|
|
195
|
+
FINDING_CODE_EVIDENCE_SNIPPET_BYTES,
|
|
196
|
+
)[0]
|
|
197
|
+
bounded.append(evidence)
|
|
198
|
+
return bounded
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def bounded_json_value(value: Any, budget: list[int], *, depth: int = 0) -> Any:
|
|
202
|
+
if budget[0] <= 0:
|
|
203
|
+
return None
|
|
204
|
+
if depth >= 4:
|
|
205
|
+
consume_json_budget(budget, 4)
|
|
206
|
+
return None
|
|
207
|
+
if isinstance(value, str):
|
|
208
|
+
bounded, size = bounded_json_text(value, budget[0])
|
|
209
|
+
consume_json_budget(budget, size)
|
|
210
|
+
return bounded
|
|
211
|
+
if value is None or isinstance(value, (bool, int, float)):
|
|
212
|
+
consume_json_budget(budget, len(json.dumps(value, separators=(",", ":")).encode("utf-8")))
|
|
213
|
+
return value
|
|
214
|
+
if isinstance(value, list):
|
|
215
|
+
if not consume_json_budget(budget, 2):
|
|
216
|
+
return []
|
|
217
|
+
result = []
|
|
218
|
+
for item in value[:20]:
|
|
219
|
+
separator = 0 if not result else 1
|
|
220
|
+
if not consume_json_budget(budget, separator):
|
|
221
|
+
break
|
|
222
|
+
result.append(bounded_json_value(item, budget, depth=depth + 1))
|
|
223
|
+
return result
|
|
224
|
+
if isinstance(value, dict):
|
|
225
|
+
if not consume_json_budget(budget, 2):
|
|
226
|
+
return {}
|
|
227
|
+
result = {}
|
|
228
|
+
for key, item in list(value.items())[:20]:
|
|
229
|
+
if budget[0] <= 0 or not isinstance(key, str):
|
|
230
|
+
break
|
|
231
|
+
separator = 0 if not result else 1
|
|
232
|
+
if not consume_json_budget(budget, separator):
|
|
233
|
+
break
|
|
234
|
+
bounded_key, key_size = bounded_json_text(key, min(budget[0], 512))
|
|
235
|
+
if not consume_json_budget(budget, key_size + 1):
|
|
236
|
+
break
|
|
237
|
+
result[bounded_key] = bounded_json_value(item, budget, depth=depth + 1)
|
|
238
|
+
return result
|
|
239
|
+
consume_json_budget(budget, 4)
|
|
240
|
+
return None
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def consume_json_budget(budget: list[int], size: int) -> bool:
|
|
244
|
+
if budget[0] < size:
|
|
245
|
+
budget[0] = 0
|
|
246
|
+
return False
|
|
247
|
+
budget[0] -= size
|
|
248
|
+
return True
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def bounded_json_text(value: str, maximum_bytes: int) -> tuple[str, int]:
|
|
252
|
+
low = 0
|
|
253
|
+
high = len(value)
|
|
254
|
+
selected = ""
|
|
255
|
+
selected_size = 2
|
|
256
|
+
while low <= high:
|
|
257
|
+
midpoint = (low + high) // 2
|
|
258
|
+
candidate = value[:midpoint]
|
|
259
|
+
size = len(json.dumps(candidate, separators=(",", ":")).encode("utf-8"))
|
|
260
|
+
if size <= maximum_bytes:
|
|
261
|
+
selected = candidate
|
|
262
|
+
selected_size = size
|
|
263
|
+
low = midpoint + 1
|
|
264
|
+
else:
|
|
265
|
+
high = midpoint - 1
|
|
266
|
+
return selected, selected_size
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
if __name__ == "__main__":
|
|
270
|
+
argparse.ArgumentParser(description=__doc__).parse_args()
|