v3.29.2: the strict row rule for the outfile import

The format is positional: an empty value drops its token, so the parser
now requires every data row to have exactly the header's column count.
That catches an empty value anywhere - including a middle one, which
would otherwise shift the following columns (a missing ADM made the KIC
columns read the KIK values: valid hex, wrong preset) - and a KICn/KIDn
pair declared in the header must carry a usable hex value in every row
(a placeholder fails).

A violation makes the whole file invalid: the report's error names the
line, no presets are returned, and an import (mode) answers 400 - it is
never partially imported.  The PWA disables the Import button while the
report carries an error and guards the call.

Unchanged per-row reports: a non-hex PIN/PUK/ADM/PSK value (dropped, the
card kept), an unsupported key size (that keyset skipped), a card whose
remaining keysets are unusable (skipped).  All three real samples satisfy
the rule exactly (11/11, 18/18, 18/18).

Docs: help EN/RU, api.md, the repo AGENTS.  Tests: the short/long row and
the placeholder-keyset file errors, the valid-file round trip, the
endpoint's refusal (nothing stored), the PWA's disabled button.
926 frontend + 945 Python; sw cache simple-v449.
This commit is contained in:
2026-10-15 00:43:53 +03:00
parent 8a66ea5a0a
commit 94d7cff485
11 changed files with 105 additions and 24 deletions
+8 -1
View File
@@ -37,7 +37,7 @@ from osmocom.tlv import BER_TLV_IE
from osmocom.utils import rpad
VERSION = '3.29.1'
VERSION = '3.29.2'
MAX_ENVELOPE_SEGMENTS = 5 # max SMS segments for outgoing C-APDU in ENVELOPE
@@ -11360,6 +11360,13 @@ class PysimHandler(BaseHTTPRequestHandler):
self._send_json(resp)
self._log_resp(resp)
return
if parsed['report'].get('error'):
# A structurally invalid file (v3.29.2) is never partially
# imported - the preview shows the error, the import refuses.
resp = {'error': parsed['report']['error']}
self._send_json(resp, 400)
self._log_resp(resp)
return
try:
result = store.import_presets(parsed['presets'], mode)
except OSError as e: