build(core): warn when translation blob size become too high
What changed, and why it matters
This commit adds a build-time warning to the Trezor firmware translation tool. It checks how large each language translation file is compared to the maximum space available on each device model, and logs a yellow warning or red error if the file is getting too close to the limit. There is no change to device runtime code, no user-facing behavior change, and no security fix or vulnerability.
No security action needed. This is a benign build-helper improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change modifies core/translations/cli.py’s build_all_blobs() function. It queries an external layout_parser tool for each model’s ASSETS_MAXSIZE, records each generated translation blob’s byte length, and after writing all blobs emits LOG.warning or LOG.error messages when a blob’s size exceeds 95% or 99% of the model’s maximum asset storage. This is purely a CI/build observability improvement.
Changed components
core/translations/cli.pyInspect captured patch +22 / −1
diff --git a/core/translations/cli.py b/core/translations/cli.py
index d389c190..1a6d8ea9 100755
--- a/core/translations/cli.py
+++ b/core/translations/cli.py
@@ -213,6 +213,12 @@ def build_all_blobs(
signature: bytes,
production: bool = False,
) -> None:
+ max_sizes = {}
+ for model in ALL_MODELS:
+ parser_output = subprocess.check_output(args=["layout_parser", model.internal_name, "ASSETS_MAXSIZE"])
+ max_sizes[model.internal_name] = int(parser_output.decode().strip())
+
+ sizes = []
for blob in all_blobs:
proof = translations.Proof(
merkle_proof=merkle_tree.get_proof(blob.header_bytes),
@@ -228,9 +234,24 @@ def build_all_blobs(
else:
suffix = "-unsigned"
filename = f"translation-{model}-{header.language}-{version}{suffix}.bin"
- (HERE / filename).write_bytes(blob.build())
+ blob_bytes = blob.build()
+ (HERE / filename).write_bytes(blob_bytes)
+
+ sizes.append((filename, len(blob_bytes), model))
LOG.info(f"Wrote {header.language} for {model} v{version}: {filename}")
+ for filename, size, model in sorted(sizes):
+ max_size = max_sizes[model]
+ ratio = size / max_size
+ if ratio < 0.95:
+ continue
+ elif ratio < 0.99:
+ log_fn, icon = LOG.warning, "🟡"
+ else:
+ log_fn, icon = LOG.error, "🔴"
+
+ log_fn(f"{icon} {filename} flash utilization is {ratio * 100:.1f}% (out of {max_size / 1024:.1f} kB)")
+
@click.group()
def cli() -> None:
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.