Code-review fixes: bad-format visibility, view-aware sync, counter hygiene
- The RAM step line (and the plain send's PoR line) now name a bad-format
failure ("bad format 02 (wrong length)") instead of reading "PoR ok": the
step record carries por_bad_format_name and ramStepLine renders it.
- ramSyncCounter follows the view the notice came from ('ram'/'sp' - preset
and keyset selectors alike) and refreshes the keyset labels after a sync.
- The ETSI-release line no longer hides behind the memory block (it needs
only the ELF list).
- /api/send-ota reports final_cntr only for a packet the card accepted: the
failed-envelope path used to persist the packet's own counter on a
rejection (the audit trail's small bump on cntr_low).
- _ram_detect_format's docstring corrected (both expanded codings execute on
the live ISD; the earlier bad format was a length-mismatched template).
- Tests: ramStepLine bad format, the view-aware notice, the accepted/rejected
final_cntr cases, and an end-to-end /api/counter-probe endpoint test
(400s, no write on a rejected walk, accepted+1 stored).
- sw cache simple-v356.
This commit is contained in:
@@ -27,7 +27,7 @@ const FNS = ['berLenStr', 'buildApdu', 'escHtml', 'esc', 'chainInit', 'chainRamB
|
||||
'stkParamsBuild', 'ramRemoteSwOk', 'spPorAccepted', 'ramIncrementCntr', 'ramDeleteFromExplorer', 'ramListingSpi2', 'ramRemoveFromExplorer', 'ramHasInstance', 'ramExpandedQueryApdu',
|
||||
'_parseRawElfEntry', '_parseRawAppEntry', 'ramParseElfStatus', 'ramParseAppStatus', 'ramParseModuleAids', 'parseTLV', '_parseE3Entry', '_parseMenuEntries',
|
||||
'ramExpandedReport', 'ramExpandedMore', 'ramExpandedTags', 'ramExpandedGroups', 'ramExpandedElfForm', 'ramElfVersionHint', 'cardEtsiRelease', 'ramChainGetResponse', 'ramDeriveElfVersions', 'ramElfAppletCandidate',
|
||||
'spCntrLow', 'ramCntrLowHtml', 'ramCntrLowPresetIdx', 'ramShowCntrLow',
|
||||
'spCntrLow', 'ramCntrLowHtml', 'ramCntrLowPresetIdx', 'ramCntrLowView', 'ramShowCntrLow',
|
||||
'spKeysetKvnOf', 'spKeysetList', 'spKeysetFor', 'spKeysetCheck',
|
||||
'spKeysetOptionsHtml', 'spPresetIdx', 'tarPresetIdx',
|
||||
'cardsKeysetsFromForm', 'spKeysetSync', 'spKeysetApply', 'spKeysetChanged',
|
||||
@@ -852,18 +852,21 @@ test('ramCntrLowHtml states the facts without a fabricated counter', () => {
|
||||
globalThis.t = s => s;
|
||||
const out = ramCntrLowHtml(2);
|
||||
const noPreset = ramCntrLowHtml(-1);
|
||||
// the notice follows the failed operation's view ('sp' -> its own keyset)
|
||||
const spView = ramCntrLowHtml(1, 'sp');
|
||||
delete globalThis.t;
|
||||
assert.ok(out.includes('Low counter \u2014 the card rejected the packet'), out);
|
||||
// the PoR's CNTR is a copy of the command's counter, never the card's: no
|
||||
// value may be shown (v3.9.x), only the verdict and the two actions
|
||||
assert.ok(!out.includes('card counter'), out);
|
||||
assert.ok(out.includes('onclick="ramSyncCounter(2)"'), out);
|
||||
assert.ok(out.includes('onclick="ramSyncCounter(2, \'ram\')"'), out);
|
||||
assert.ok(out.includes('Sync counter'), out);
|
||||
assert.ok(out.includes('onclick="ramGoToPreset(2)"'), out);
|
||||
assert.ok(out.includes('Go to preset'), out);
|
||||
// without a known preset the buttons still work (-1)
|
||||
assert.ok(noPreset.includes('onclick="ramGoToPreset(-1)"'), noPreset);
|
||||
assert.ok(noPreset.includes('onclick="ramSyncCounter(-1)"'), noPreset);
|
||||
assert.ok(noPreset.includes('onclick="ramSyncCounter(-1, \'ram\')"'), noPreset);
|
||||
assert.ok(spView.includes('onclick="ramSyncCounter(1, \'sp\')"'), spView);
|
||||
});
|
||||
|
||||
test('the explorer shows versions on app and ISD rows too', () => {
|
||||
@@ -877,6 +880,19 @@ test('the explorer shows versions on app and ISD rows too', () => {
|
||||
assert.ok(out.includes('Version: 9.3'), out);
|
||||
});
|
||||
|
||||
test('ramStepLine names a bad-format failure instead of "PoR ok"', () => {
|
||||
globalThis.t = s => s;
|
||||
const line = ramStepLine({ name: 'P2=02 (lean)', por_status: 'por_ok',
|
||||
por_error: 'bad format 02 (wrong length)', por_bad_format: '02',
|
||||
por_bad_format_name: 'wrong length' }, 0);
|
||||
const plain = ramStepLine({ name: 'LOAD', por_status: 'por_ok', por_sw: '9000' }, 1);
|
||||
delete globalThis.t;
|
||||
assert.ok(line.includes('bad format 02 (wrong length)'), line);
|
||||
assert.ok(!line.includes('PoR ok'), line);
|
||||
// a healthy step is unchanged
|
||||
assert.ok(plain.includes('9000') || plain.includes('PoR ok'), plain);
|
||||
});
|
||||
|
||||
test('the Explore retries the ELF tag lists with P1=20 and per applet AID', () => {
|
||||
const src = extractFunc(html, 'ramExplore');
|
||||
assert.ok(src.includes('elfTagListRetry'), 'the P1=20 tag-list retry must exist');
|
||||
@@ -908,9 +924,11 @@ test('every SCP80/RAM flow checks the low counter and stops', () => {
|
||||
// preset, the keyset the failed operation used and its SPI/TAR
|
||||
const sync = extractFunc(html, 'ramSyncCounter');
|
||||
assert.ok(sync.includes("'/api/counter-probe'"), sync);
|
||||
assert.ok(sync.includes("kvnOf('ram-keyset-sel')"), sync);
|
||||
assert.ok(sync.includes("kvnOf('sp-keyset-sel')"), sync);
|
||||
assert.ok(sync.includes("own = view === 'sp'"), sync);
|
||||
assert.ok(sync.includes('kvnOf(own)'), sync);
|
||||
assert.ok(sync.includes('kvnOf(other)'), sync);
|
||||
assert.ok(sync.includes("getElementById('sp-cntr')"), sync);
|
||||
assert.ok(sync.includes('spKeysetSync()'), 'the keyset labels must refresh');
|
||||
});
|
||||
|
||||
test('the RAM form offers the command format choice', () => {
|
||||
|
||||
@@ -30,7 +30,7 @@ let code = '';
|
||||
for (const fn of ['berLenStr', 'ramDeleteApdu', 'ramIncrementCntr', 'ramSaveCntr',
|
||||
'getRamSpParams', 'spPorAccepted', 'ramRemoteSwOk', 'ramShowProgress',
|
||||
'ramHideProgress', 'ramDeleteFromExplorer',
|
||||
'spCntrLow', 'ramCntrLowHtml', 'ramCntrLowPresetIdx', 'ramShowCntrLow',
|
||||
'spCntrLow', 'ramCntrLowHtml', 'ramCntrLowPresetIdx', 'ramCntrLowView', 'ramShowCntrLow',
|
||||
'escHtml', 'esc',
|
||||
'spKeysetKvnOf', 'spKeysetList', 'spKeysetFor', 'spKeysetCheck',
|
||||
'spKeysetOptionsHtml', 'cardsKeysetRowHtml', 'cardsKeysetRowsRender',
|
||||
|
||||
Reference in New Issue
Block a user