Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lode/dotnet/analyzer-candidates/catalog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Analyzer Candidates: Settled Catalog
*Updated: 2026-11-13T22:43:07Z*
*Updated: 2026-11-17T22:44:32Z*

This file holds the settled side of the register: which rule shipped, which idea
was checked and rejected, and which sweep closed. Every rule ships from
Expand Down Expand Up @@ -48,6 +48,7 @@ conversion plan. Open .NET 11 conversion shapes: [net11-conversion-sweep.md](net
| E128225 | abstract-base-with-members-is-closed | implemented | 4/5 | 2026-11-13 |
| E128226 | comparer-set-by-loop | implemented | 3.5/5 | 2026-11-13 |
| E128227 | http-body-read-without-size-bound | implemented | 3.5/5 | 2026-11-13 |
| E128228 | token-validation-flag-false | implemented | n/a | 2026-11-17 |

## Rules From Guidance Documents

Expand Down
6 changes: 4 additions & 2 deletions lode/dotnet/analyzer-candidates/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Analyzer Candidates: Open Register
*Updated: 2026-11-17T16:36:03Z*
*Updated: 2026-11-17T22:44:32Z*

One register for every open analyzer candidate, whichever repository noticed it.
A candidate enters at status `new`, carries a four-dimension score, and leaves
Expand Down Expand Up @@ -31,6 +31,7 @@ No open candidate. `ByteSizeType.Is` matches the type by simple name, so a
namespace move does not break the E128080 exemption.

The body-read shape shipped as E128227. See [catalog.md](catalog.md).
The token-validation flag shape shipped as E128228. See [catalog.md](catalog.md).
The JSON enumerator shape closed as skipped, because the enumerator releases no
resource. See [skipped-decisions.md](skipped-decisions.md).

Expand All @@ -39,6 +40,8 @@ resource. See [skipped-decisions.md](skipped-decisions.md).
These clear the same bar and wait for a real defect in review.
The `AsReadOnly()` getter shape left this table on 2026-11-14, because E128058
and E128060 require that shape. See [skipped-decisions.md](skipped-decisions.md).
The token-validation flag shape left this table on 2026-11-17, because the
maintainer chose prevention over the real-defect bar.

| Rule | Check | Noise |
| ------------------------------------------------------------------ | -------------------------------------------------------------- | ------ |
Expand All @@ -49,7 +52,6 @@ and E128060 require that shape. See [skipped-decisions.md](skipped-decisions.md)
| `Array.Resize` or `Concat` in a loop | call reassigned to the same receiver inside the loop | Low |
| CORS wildcard with credentials | one chain holds `AllowAnyOrigin` and `AllowCredentials` | Low |
| Antiforgery missing on a state-changing action | verb attribute with no antiforgery attribute in scope | Medium |
| Token validation flag set to constant `false` | six `TokenValidationParameters` flags | Low |
| `readonly` field of a mutable struct | defensive copy on every member call | Low |
| Floating-point loop counter | `for` loop steps a `float` or `double` local | Low |
| Enum cast outside the member set | constant integral to enum conversion | Low |
Expand Down
4 changes: 2 additions & 2 deletions lode/dotnet/analyzers.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# .NET 11 Roslyn Analyzers
*Updated: 2026-11-17T13:33:06Z*
*Updated: 2026-11-17T22:44:32Z*

## Strategy: Deny by Default

Expand Down Expand Up @@ -123,7 +123,7 @@ Key rules by category (not exhaustive):
| Design | Sealed-by-default, async void, sync-over-async, ConfigureAwait, TimeProvider, DI, ImmutableArray, abstract base with members is closed (E128225) |
| Reliability | GeneratedRegex safety, DateTime roundtrip, Task.WhenAll, JsonDocument lifetime, pool Rent() guard, stackalloc bounds, pool zeroing, service lifetime (E128154, `TryAdd`, keyed, `typeof` and `AddHostedService` forms, and a singleton `DbContext`), `foreach` mutation (E128155, including array writes and `break` or `return` exits), `TaskCompletionSource` options and shared-source completers (E128159), hand-rolled process capture (E128223, redirect, read, then wait), `Path.Combine` segments (E128161), use after `Dispose` (E128162, direct block statement only), `ImmutableArray` default (E128163, no fix for struct instance fields), `await` in `finally` (E128186), exception filter text read (E128188), unreleased `GCHandle` (E128189), hidden `GetBuffer` (E128192), disposable field overwritten in a loop (E128193), `Lazy<T>` without thread safety (E128194), configuration key absent from the settings files (E128195), `JsonSerializerOptions` written after first use (E128196), fixed day count used as a month (E128197), `Substring` count underflow (E128198) |
| Performance | MinBy/MaxBy, HttpCompletionOption, FrozenSet, O(n²) loops, `SearchValues<char>` (E128102), UTF-8 parsing, alternate lookups (E128131 to E128135), span bulk methods (E128140), u8 literals (E128141), complexity ceiling (E128152), `RemoveAt(0)` in loop (E128153), `SaveChanges` in loop (E128185), uncapped `Parallel.ForEachAsync` (E128187), `FileStream` without async I/O (E128190), HTTP and database round trips in a loop (E128203, E128204), collection presize (E128205), empty spin loop (E128206), reflection lookup in a loop (E128207), concurrent dictionary double lookup (E128208), `GetBytes` length in a loop (E128209), `new Regex` in a loop (E128210), `Task.Delay` in a loop without a token (E128211), `ToCharArray` copy (E128212), `Activator` in a loop (E128213), handler without decompression (E128214), `StringBuilder` capacity (E128215), unbounded channel (E128216), large struct by value (E128217), read-only `MemoryStream` (E128224), comparer set filled by a loop (E128226) |
| Security | FIPS cryptography rules: unapproved hash names, `System.Random` in security code, managed and CNG type creation, RSA key size, cipher mode, PBKDF2 work factor, TLS versions, deprecated RNG, excluded cipher names, AES-GCM tag size, SHA-3 policy, HMAC key length (E128071, E128075, E128142 to E128151), certificate bypass (E128156, `SslOptions` and `SslStream` too), fixed-time compare (E128157), hardcoded URL (E128164, dot boundary), hardcoded secret (E128165, token, credential and bearer names, `??`, indexers, getter returns, `u8`, connection strings), sensitive log argument (E128166, `LoggerMessage`, wrapped args, whole-word `ssn` and `pwd`, skips `EventId` and `Exception`), PFX import without `EphemeralKeySet` (E128191), unvalidated JWT claims used as an identity (E128202) |
| Security | FIPS cryptography rules: unapproved hash names, `System.Random` in security code, managed and CNG type creation, RSA key size, cipher mode, PBKDF2 work factor, TLS versions, deprecated RNG, excluded cipher names, AES-GCM tag size, SHA-3 policy, HMAC key length (E128071, E128075, E128142 to E128151), certificate bypass (E128156, `SslOptions` and `SslStream` too), fixed-time compare (E128157), hardcoded URL (E128164, dot boundary), hardcoded secret (E128165, token, credential and bearer names, `??`, indexers, getter returns, `u8`, connection strings), sensitive log argument (E128166, `LoggerMessage`, wrapped args, whole-word `ssn` and `pwd`, skips `EventId` and `Exception`), PFX import without `EphemeralKeySet` (E128191), unvalidated JWT claims used as an identity (E128202), token validation flag pinned false (E128228) |
| Unsafe | `Unsafe.As` to `Unsafe.BitCast`, unaligned reads, unaligned non-blittable reads (E128139), bounds bypass, bool and int reinterpret, non-blittable `MemoryMarshal`, fixed buffers, `SkipInit`, unpinned pointers, string writes, null byref, delegate lifetime, bulk copy, pointer and length pairs, nonpublic reflection, raw IL, function pointer types (E128112 to E128129, E128136 to E128139, E128200) |
| Style | string.Empty, Encoding.UTF8, XML doc comments, null-forgiving operator |
| Maintainability | Direct recursion (E128199), conditional directive ceiling (E128201) |
Expand Down
30 changes: 29 additions & 1 deletion lode/dotnet/analyzers/rule-details-security.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Security Rule Detail Notes
*Updated: 2026-11-16T15:41:36Z*
*Updated: 2026-11-17T22:44:32Z*

Detection shape and exclusions for the E128 security rules that the main rule
table cannot show. The severity and the code-fix status live in
Expand Down Expand Up @@ -51,3 +51,31 @@ check to the measured path.

The rule needs `System.Net.Http.HttpContent`. Without that type it registers no
action, so a consumer with no HTTP reference gets no report.

### E128228: Token validation flag set to constant false

Flags an assignment of a literal `false` to a validation flag on
`Microsoft.IdentityModel.Tokens.TokenValidationParameters`. The analyzer resolves
the property symbol and the containing type, so an unrelated type with the same
property name stays silent. One `SimpleAssignmentExpression` action covers an
object initializer assignment and an assignment after construction.

Five flags default to `true`: `ValidateIssuer`, `ValidateAudience`,
`ValidateLifetime`, `RequireExpirationTime`, and `RequireSignedTokens`.

`ValidateIssuerSigningKey` defaults to `false`. The rule reports that flag with
its own message, because the assignment matches the default and changes no
runtime behavior.

The rule reports only a literal `false`, including a parenthesized literal. A
value read from configuration, a local, or a `const` stays silent, because the
rule cannot judge it. The safe value depends on the deployment, so the rule
carries no code fix.

The rule needs `Microsoft.IdentityModel.Tokens.TokenValidationParameters`.
Without that type it registers no action, so a consumer with no JWT reference
gets no report.

The analyzer declares two descriptors with one ID. The test harness cannot infer
a named markup diagnostic when descriptors share an ID, so the tests supply an
explicit `DiagnosticResult` with a keyed location.
3 changes: 2 additions & 1 deletion lode/dotnet/release-tracking.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Roslyn Analyzer Release Tracking
*Updated: 2026-11-17T13:14:44Z*
*Updated: 2026-11-17T22:56:03Z*

## Overview

Expand Down Expand Up @@ -170,6 +170,7 @@ that is missing from either file blocks the ship, even on a docs-only change set
| 2.11.0 | E128223-226 | Hand-rolled process capture, read-only `MemoryStream`, closed base with members, and comparer set construction. E128220 also reports a closed-hierarchy switch that ends in a discard arm. |
| 3.0.0 | (none) | E128160 removed. E128223 reports the read-then-wait shape that replaced the hand-rolled process capture. |
| 3.1.0 | E128227 | HTTP body read without a size bound. Security, Warning. |
| 3.2.0 | E128228 | Token validation flag set to constant false. Security, Warning. |

## Sources

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

8 changes: 8 additions & 0 deletions src/E128.Analyzers/AnalyzerReleases.Shipped.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Release 3.2.0

### New Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|------
E128228 | E128-Security | Warning | Token validation flag set to constant false

## Release 3.1.1

### Changed Rules
Expand Down
2 changes: 1 addition & 1 deletion src/E128.Analyzers/E128.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<!-- NuGet Packaging -->
<PropertyGroup>
<Version>3.1.5</Version>
<Version>3.2.0</Version>
<IsPackable>true</IsPackable>
<IncludeBuildOutput>false</IncludeBuildOutput>
<DevelopmentDependency>true</DevelopmentDependency>
Expand Down
27 changes: 26 additions & 1 deletion src/E128.Analyzers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Roslyn analyzers and code fixes that enforce opinionated .NET conventions at com
## Installation

```xml
<PackageReference Include="E128.Analyzers" Version="3.1.5" PrivateAssets="all" />
<PackageReference Include="E128.Analyzers" Version="3.2.0" PrivateAssets="all" />
```

> `PrivateAssets="all"` keeps the analyzers out of your consumers' dependency graph.
Expand Down Expand Up @@ -229,6 +229,7 @@ All rules default to **Warning** severity unless noted. Every rule includes a co
| E128202 | Unvalidated JWT claims used as an identity | No |
| E128222 | `Path.Combine` of a root `.FullName` and an uncontained leaf | Yes |
| E128227 | HTTP body read without a size bound | No |
| E128228 | Token validation flag set to constant false | No |

### Style

Expand Down Expand Up @@ -3297,6 +3298,30 @@ if (response.Content.Headers.ContentLength is not > MaxBodyBytes)
var json = await response.Content.ReadAsStringAsync(cancellationToken);
```

### E128228: Token validation flag set to constant false

Flags a `TokenValidationParameters` flag assigned a literal `false`. Five flags default to `true`, so a literal `false` disables the check with no build warning and no runtime warning. The token handler then accepts a token that the caller believes it rejects.

`ValidateIssuerSigningKey` defaults to `false`. The rule reports that flag with a distinct message, because the assignment matches the default value.

The rule resolves the property symbol against `TokenValidationParameters` and reports only a literal `false`. A value read from configuration or a variable stays silent. The rule carries no code fix, because the safe value depends on the deployment.

```csharp
// Before (warns)
var parameters = new TokenValidationParameters
{
ValidateIssuer = false,
ValidateAudience = false,
};

// After
var parameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
};
```

## Requirements

- .NET SDK 11.0+ (targets `netstandard2.0`, runs in any modern Roslyn host)
Expand Down
Loading