Fix/backup webauthn ml export bugs - #4
Merged
Conversation
Several real bugs surfaced by the batch-1/2 coverage agents, all now
fixed:
- WebAuthnService: registration origin mismatch and authentication
signature-counter regression (cloned-authenticator signal) were only
logged, never rejected. Both are now hard failures.
- DatabaseRestoreService: encrypted-backup restore was broken two ways
- ValidateBackupAsync's ZIP-structure gate rejected genuinely
AES-encrypted backups outright (they are IV-prefixed ciphertext, not
a ZIP), and DecryptAndExtractAsync never actually decrypted, just
copied the stream verbatim. Both fixed: a non-ZIP stream long enough
to hold an IV is now treated as an encrypted-backup candidate, and
decryption genuinely happens (same AES key derivation as
BackupManagementService.EncryptBackupAsync). Also fixed
IsBackupEncryptedAsync's metadata-entry filename check (was looking
for "backup_metadata.json", JsonBackupHelper writes "metadata.json"),
and removed ~55 lines of dead restore code superseded by the JSON
restore path.
- BackupManagementService: Weekly/Monthly retention cutoffs had an
inverted sign (AddDays(+28)/(+365) instead of negative), making
Weekly retention tighter than Daily's and Monthly backups deleted
unconditionally regardless of age.
CleanupBackupsByProviderSettingsAsync's doc comment claimed
"Weekly and monthly handled analogously" but only ever processed
Daily rows; now processes all three. A failed remote delete no
longer purges the DB row (the backup may still exist at the
provider - it's retried on the next cleanup run instead).
- CategoryPredictionService: the ML training pipeline's first step
(MapValueToKey("Label")) made building a PredictionEngine always
throw "Could not find input column 'Label'", both right after
training and after every reload - so the ML model never actually
worked, silently falling back to keyword-only suggestions forever.
CategoryPredictionInput now carries the (unused-at-prediction-time)
Label column the schema requires. The reload guard that caught this
exception and deleted the just-trained model file (without
resetting _trainedModel, so IsMlModelTrained lied about it) is
removed - reload now succeeds outright.
FindSimilarProductsAsync also matched case-sensitively against
already-lowercased keywords, so it silently missed most real
product names.
- ExportService: storage-location Excel export called
.Include(sl => sl.Room) on a plain string column, not a navigation
property, throwing on every call.
- ApplicationInsightsService: MemoryTotalMB was hardcoded to
long.MinValue instead of a real reading.
- DatabaseHealthService: GetHealthReportAsync never called the
existing GetLastBackupDateAsync helper, so LastBackup stayed null
regardless of actual backup history.
Also fixes an unrelated pre-existing test bug in
SecurityRiskServiceTests (asserted UserId descending order when the
test's own scenario makes the lower-UserId user score higher - the
correct invariant is RiskScore descending).
Every test that previously documented one of the bugs fixed in the prior commit now asserts the corrected behavior instead, plus new tests where the fix needed a real relational provider (SQLite) that EF Core InMemory can't translate the query against. Also fixes SecurityRiskServiceTests' own pre-existing assertion bug (unrelated to the production fixes): it asserted UserId descending order, but the test's own scenario gives the lower-UserId user the higher risk score - the correct invariant is RiskScore descending.
|
🎉 This PR is included in version 1.2.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
fix backup webauthn ml export and minor bugs