fix(validation): close Theme 3 — 11 input-validation / unbounded-input findings
Each finding is a focused validation guard or upper bound at a trust boundary.
Highlights:
- Commons-015: EncryptionMetadata ctor now validates Algorithm (AES-256-GCM
only), Kdf (PBKDF2-SHA256 only), Iterations ([100k, 10M]), non-null Salt/IV.
- Transport-004: new BundleUnlockRateLimiter (sliding-window, per-key,
singleton) wired into BundleImporter.LoadAsync; over-budget callers see
BundleUnlockRateLimitedException. Per-bundle 3-strike + per-window cap.
- ESG-022: ExternalSystemClient.InvokeHttpAsync allow-lists the documented
GET/POST/PUT/PATCH/DELETE set (case-insensitive); unknown verbs throw.
- SEL-015: SiteEventLogger queue now bounded (10k cap, DropOldest); dropped
events fault their Task and increment FailedWriteCount so the drop is
observable instead of an unbounded memory growth.
- SEL-017: EventLogQueryService clamps caller-supplied PageSize to a new
MaxQueryPageSize cap (default 500) so int.MaxValue can't OOM the host.
- SEL-020: LogEventAsync rejects severities outside {Info, Warning, Error}
(matches SQLite BINARY-collation query filter).
- InboundAPI-020: ContentType "json" check now case-insensitive
(application/JSON no longer slips through as not-json).
- InboundAPI-024: _knownBadMethods capped at 1000 entries (drops new entries
once full); per-request DB lookup remains the correctness path.
- SR-025: HandleSetStaticAttribute validates the attribute name against the
deployed config; unknown names now return Success=false instead of
leaking orphan override rows into the SQLite store.
- TE-021: MoveTemplateAsync runs the sibling-name-collision check at the
destination, mirroring TemplateFolderService.MoveFolderAsync.
- TE-022: LockEnforcer's once-locked-stays-locked rule now also covers
LockedInDerived (was previously only IsLocked).
New regression tests across 8 test projects (EncryptionMetadata, rate
limiter, ESG client allow-list, SEL bounded channel / PageSize clamp /
severity validation, InboundAPI ContentType + bad-methods cap, SiteRT
unknown-attribute, TemplateEngine MoveTemplate + LockedInDerived).
Build clean; affected suites all green. README regenerated: 93 open (was 104).
Note: a separate manual re-run was needed for the SiteEventLogging hunk
because its initial subagent's source edits never landed on disk despite
reporting success (file-collision-style failure mode).
This commit is contained in:
@@ -985,9 +985,18 @@ bodyless request through the middleware.
|
||||
|--|--|
|
||||
| Severity | Low |
|
||||
| Category | Correctness & logic bugs |
|
||||
| Status | Open |
|
||||
| Status | Resolved |
|
||||
| Location | `src/ScadaLink.InboundAPI/EndpointExtensions.cs:70` |
|
||||
|
||||
**Resolution (2026-05-28):** swapped the case-sensitive `Contains("json")`
|
||||
substring match for `Contains("json", StringComparison.OrdinalIgnoreCase)` so
|
||||
`application/JSON` / `Application/Json` / `APPLICATION/JSON` all enter the
|
||||
JSON-deserialization path. Regression test
|
||||
`EndpointContentTypeTests.ContentTypeCheck_IsCaseInsensitive_ParsesBodyForAnyCasing`
|
||||
(theory, 4 casings) drives a TestServer-hosted `MapInboundAPI` end-to-end with
|
||||
a required Integer parameter — proving body parsing actually ran by asserting
|
||||
the parameter reaches the handler.
|
||||
|
||||
**Description**
|
||||
|
||||
`HandleInboundApiRequest` parses the JSON body only when
|
||||
@@ -1164,9 +1173,20 @@ resolved key name after successful auth, but is absent on auth failures).
|
||||
|--|--|
|
||||
| Severity | Low |
|
||||
| Category | Performance & resource management |
|
||||
| Status | Open |
|
||||
| Status | Resolved |
|
||||
| Location | `src/ScadaLink.InboundAPI/InboundScriptExecutor.cs:30`, `:77`, `:223`, `:233` |
|
||||
|
||||
**Resolution (2026-05-28):** capped the cache at `KnownBadMethodsCap = 1000`
|
||||
entries via a new `TryRecordBadMethod` helper that short-circuits when the cap
|
||||
is reached — both `CompileAndRegister` and the `ExecuteAsync` lazy-compile path
|
||||
now route through it. Once full, new bad-method records are dropped; the cache
|
||||
is just a fast-fail optimisation and the per-request DB lookup remains the
|
||||
correctness path. Regression tests
|
||||
`KnownBadMethodsCache_SizeNeverExceedsCap_UnderUniqueNameFlood` and
|
||||
`KnownBadMethodsCache_LazyCompilePath_AlsoCappedUnderUniqueNameFlood` flood
|
||||
`cap + 500` / `cap + 250` unique broken methods and assert the cache size never
|
||||
exceeds the cap. Internal `KnownBadMethodCount` exposed for testability only.
|
||||
|
||||
**Description**
|
||||
|
||||
The InboundAPI-009 fix introduced `_knownBadMethods`, a `ConcurrentDictionary<string, byte>`
|
||||
|
||||
Reference in New Issue
Block a user