Keep co-op's private settings out of the log and out of bug reports.

This line logs every setting nx2navi.ini sets, and a bug report takes a copy of nx2navi.ini along: with co-op both would have carried a room's secret, the relay's address and the player's name to whoever reads the report, and the secret lets anyone into the room. One list (runtime/cfg_private.h: the room's secret, the offer number, the relay, the name, the key a maker removes, the menu's test hook) now serves the log's line, "Copy system info" and the report's copy of the file, in the game and in the launcher: such a key reads "(set, not shown)", every other byte of the file stays.

Also: the last leftovers of the restorations that were left out with the puppets (their settings prefix and section), main.c's byte order mark as it was, and two comments that cited files this tree does not have.

Checked: with a room, a relay and a name in nx2navi.ini the log's line shows all three as set and none of their values; the same text gives the same bytes through the game's scrub and the launcher's (a launcher test, and the C function built alone); the launcher tests, the co-op probe, the relay tests and the tab check pass.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-11 00:20:22 -05:00
parent 7e07e13bac
commit ba9d6bac06
10 changed files with 151 additions and 27 deletions

View File

@@ -393,6 +393,37 @@ def _fresh_file(folder, stem, suffix):
NO_SAVE = 'the game has no save yet: play until it saves, then export'
# Settings whose values stay on the player's PC (runtime/cfg_private.h has the same list): a co-op room's secret and
# the offer number made for it, the relay's address, the player's name, the key a maker removes, the menu's test hook.
PRIVATE_SETTINGS = ('coop_room', 'coop_server', 'coop_name', 'coop_accept', 'coop_remove', 'menu_test_set')
PRIVATE_SHOWN = b'(set, not shown)'
def scrub_settings(data):
"""The bytes of an nx2navi.ini for a bug report: every private setting that has a value reads
"key = (set, not shown)"; everything else, comments and line ends included, byte for byte (cfg_ini_scrub in
runtime/cfg_private.h does the same for the game's own export)."""
out = []
for n, line in enumerate(data.split(b'\n')):
text = line[:-1] if line.endswith(b'\r') else line
start = 3 if n == 0 and text.startswith(b'\xef\xbb\xbf') else 0
body = text[start:].lstrip(b' \t')
key, eq, value = body.partition(b'=')
if (eq and value.strip(b' \t') and body[:1] not in (b'#', b';', b'[')
and key.strip(b' \t').lower() in tuple(k.encode() for k in PRIVATE_SETTINGS)):
line = text[:text.index(b'=') + 1] + b' ' + PRIVATE_SHOWN + line[len(text):]
out.append(line)
return b'\n'.join(out)
def _add_report_file(z, f):
"""One file of a bug report into the zip: nx2navi.ini without its private values, anything else as it is."""
if f.name == 'nx2navi.ini':
z.writestr(REPORT_DIR + f.name, scrub_settings(f.read_bytes()))
else:
z.write(f, REPORT_DIR + f.name)
def _export_log(game, dest, version, log):
"""The bug report of a game without a save (it stopped before its first one): NX2navi-log-<date>_<time>-bug-report.zip
with the game's latest log, nx2navi.ini and a manifest that counts no save files; import_zip refuses it as a zip
@@ -411,7 +442,7 @@ def _export_log(game, dest, version, log):
with zipfile.ZipFile(tmp, 'w', zipfile.ZIP_DEFLATED) as z:
z.writestr(MANIFEST, json.dumps(manifest, indent=1) + '\n')
for f in extras:
z.write(f, REPORT_DIR + f.name)
_add_report_file(z, f)
os.replace(tmp, out)
except BaseException:
tmp.unlink(missing_ok=True)
@@ -456,7 +487,7 @@ def export_save(game, dest=None, bug_report=False, version='', log=print):
for rel in files:
z.write(current / rel, SAVE_DIR + rel.as_posix())
for f in extras:
z.write(f, REPORT_DIR + f.name)
_add_report_file(z, f)
os.replace(tmp, out)
except FileNotFoundError:
tmp.unlink(missing_ok=True)