Fix 12 issues from second code audit#2
Merged
felizvida merged 3 commits intoMay 25, 2026
Conversation
- notebook_search_service: add 120s timeout to OpenAI response body read
- backup_models: null-safe casts in BackupRecord.fromJson to avoid TypeError
- backup_parser: validate table name against allowlist before PRAGMA interpolation
- backup_service: sanitize CR/LF in _csv(); emit first-chunk download progress;
document why DisabledSecretStore is chosen when a custom root is supplied;
log a warning instead of silently swallowing chmod failures
- readable_notebook_exporter: return [] (not ['']) for empty _splitText input
- archive_extractor: remove dead startsWith('//') branch (covered by '/')
- labarchives_auth_flow: replace deprecated hmac.new() with hmac.digest()
- secure_secret_store: clarify why MacOSKeychainReadOnlySecretStore has delete()
- labarchives_client: document that SHA-1 is mandated by the LabArchives API
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full-pass code audit follow-up covering safety, correctness, and clarity issues across 9 files.
Safety / correctness
notebook_search_service.dart— add a 120 s timeout to the OpenAI response body read; previously only the header exchange was time-bounded, leaving the body read able to hang indefinitelybackup_models.dart— replace hard casts (as String,as int) inBackupRecord.fromJsonwith null-safe fallbacks (as String? ?? '',as int? ?? 0) to preventTypeErroron malformed ledger entriesbackup_parser.dart— validate thetableargument against an explicit allowlist before interpolating it into a PRAGMA string; all current call sites use hard-coded names so no behaviour change, but this closes the injection path for future callersbackup_service.dart(_csv) — strip CR and LF characters before quoting so that multi-line values don't corrupt CSV row boundariesbackup_service.dart(_setOwnerOnlyPermissions) — log astderrwarning whenchmod 600exits non-zero or throws instead of swallowing the failure silentlyreadable_notebook_exporter.dart(_splitText) — returnconst [](notconst ['']) for empty input; the empty-string chunk would generate a search index entry with no contentProgress / UX
backup_service.dart(download progress) — emit a progress event on the first chunk so small notebooks (< 25 MB) are no longer silently downloaded with no feedbackDead code / clarity
archive_extractor.dart— remove the redundantstartsWith('//')check; any path starting with//already matchesstartsWith('/')scripts/labarchives_auth_flow.py— replace the deprecatedhmac.new()withhmac.digest()(removed in Python 3.13)secure_secret_store.dart— add a comment explaining whyMacOSKeychainReadOnlySecretStoreexposesdelete()despite its "read-only" namelabarchives_client.dart— document that SHA-1 is required by the LabArchives API signature scheme, not a discretionary choicebackup_service.dart(constructor) — add a comment explaining whenDisabledSecretStoreis selected over the Keychain storeTest plan
flutter analyzepasses with no new warningsBackupRecord.fromJsonreturns a default rather than throwingscripts/labarchives_auth_flow.py --helpunder Python 3.13 — no deprecation warning🤖 Generated with Claude Code