Skip to content

fix: audit SQL construction and general exception catches (CA2100, CA1031) - #157

Merged
DeepDiver1975 merged 1 commit into
mainfrom
fix/analyzer-sql-catches
Aug 30, 2026
Merged

fix: audit SQL construction and general exception catches (CA2100, CA1031)#157
DeepDiver1975 merged 1 commit into
mainfrom
fix/analyzer-sql-catches

Conversation

@DeepDiver1975

Copy link
Copy Markdown
Collaborator

Part of the analyzer-hardening effort (see #153 for rule scoping).

CA2100 (12 sites) — audited, then suppressed per helper.
Every SQL statement is built exclusively from compile-time schema constants (table/column names in Migrations, MasterDataStore, IncidentRepository) or literal PRAGMA statements; all data values flow through bound parameters ($v/$t/$c). No user input ever reaches CommandText. Each helper is marked with a justified SuppressMessage:

  • IncidentRepository ReadRow/ReadAll/Run/Exec
  • MasterDataStore ReadColumn/Run/Exec, Migrations.Exec, SchemaHelpers AddColumnIfMissing/ColumnExists, SqliteConnectionFactory.Execute
  • test: MigrationForwardCompatTests version-marker SQL now binds the value instead of interpolating it

CA1031 (13 sites) — all deliberate, documented broad catches; each carries a justified SuppressMessage because narrowing the exception types would change the documented behavior:

  • UI resilience (error banner instead of crash): About/Files/Home/IncidentWorkspace/Links/MasterDataEditor (Import + Export)
  • Best-effort services: StorageProviderFileDialogService.ResolveStartLocation, SystemAlarmService Play/TempFileFor/TryLoad
  • Try-read semantics: IncidentFileStore.TryReadBytes, IncidentRepository.TryReadState
  • TestDoubles.InvokeAsync (test fixture): exceptions delivered via TaskCompletionSource, not swallowed

Verification: harness build (--no-incremental, AnalysisMode=All) shows CA2100 = 0 and CA1031 = 0 with 0 errors and no new warnings in any other rule; all 801 tests pass.

…1031)

Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
@DeepDiver1975
DeepDiver1975 force-pushed the fix/analyzer-sql-catches branch from fa83bdd to e2c2337 Compare August 30, 2026 20:22
@DeepDiver1975
DeepDiver1975 merged commit 8b7d56d into main Aug 30, 2026
2 checks passed
@DeepDiver1975
DeepDiver1975 deleted the fix/analyzer-sql-catches branch August 30, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant