Files
sharangandClaude Opus 5.5 34e3f6cf6a
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy MCP (push) Skipped
CI / Deploy Docs (push) Successful in 1m19s
CI / Deploy Dashboard (push) Successful in 5m25s
CI / Deploy Agent (push) Successful in 8m23s
feat(sast): DevSkim for .NET without a build (#494) (#506)
Legacy .NET Framework code often cannot be built outside the customer's
Windows toolchain, so no Roslyn analyser applies. DevSkim (MIT, Microsoft)
matches its rules on the source text and now runs as the sast_dotnet stage
on every tree with C# or VB.NET code: .cs, .vb, Razor/ASP.NET pages and
.config files, skipping bin/, obj/, packages/ and vendor directories
(anchored at the tree root).

- Only DevSkim's own rules at Critical/Important/Moderate (its ManualReview
  and BestPractice hints are not findings); DS205000 (NuGet feed mapping),
  DS184626 (controller base class) and DS440000 (generic twin of DS440020)
  are left out, and two that flood real C# (OpenRA, eShopOnWeb): DS148264
  matches any method named Random (71 hits in OpenRA), DS126858 the bare
  words md5/sha1, identifiers included (35). DS168931 and our own semgrep
  rules still cover broken hashes and System.Random. What remains: 3 hits
  in OpenRA (test vectors), 14 Low http:// hits in eShopOnWeb seed data;
  each run took about 2 s.
- SARIF is read with import::sarif::parse; findings are normalised like the
  other scanners (relative path, whole source line as snippet, one finding
  per rule/file/line), severity from DevSkim's own Critical/Important/
  Moderate (its SARIF level says "error" for both of the first two).
- DevSkim's SARIF names no CWE, so pipeline/devskim.rs gives each rule one;
  the control map binds the devskim tool by CWE to cra-ai-1, 8, 10, 13, 14,
  15, 16 and 20 for csharp and vb. A test checks every mapped rule reaches a
  control. A failed run is a sast_dotnet skip, so those controls read "not
  assessed" instead of clean.
- languages.rs now records VB.NET (vb).

Image: the CLI is published as a .NET tool on nuget.org only (no release
binaries). Dockerfile.agent pins the 1.0.100 nupkg by sha256 and the .NET
10.0.12 runtime (no SDK) by sha512, keeps only the linux-x64 natives, and
runs it through docker/devskim.sh with invariant globalisation (no ICU).
The tools stage grows from 1.525 GB to 1.623 GB (+98.5 MB: runtime 80 MB,
DevSkim 16 MB). Checked in that image as the unprivileged user with an empty
environment and --network none: it runs offline. tool-versions.json lists
devskim and dotnet-runtime.

Fixtures: fixtures/dotnet/legacy-sample, a small vulnerable C#/VB.NET
library with a Web.config (SSL 3, certificate validation off, DES, XXE,
BinaryFormatter in VB.NET, tracing, cookies without Secure), and nightly
targets for it and for framework48; their baselines need a bless run after
deploy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-10-06 12:51:10 +00:00

44 lines
2.8 KiB
Markdown

# .NET fixtures (#445)
Source trees standing for a .NET codebase, read by the unit test in
`compliance-agent/src/pipeline/dotnet/fixture_tests.rs` (no build, no network).
## `framework48`
A .NET Framework 4.8 solution in the old project style, the way an industrial
Windows codebase often looks: a WPF client, an ASP.NET/WCF service and an old
tool, NuGet packages in `packages.config` and committed under `packages/`.
| What | Expected |
|---|---|
| `Plant.sln`, three legacy `.csproj` (`v4.8`, `v4.8`, `v4.0`) | one solution, three projects, runtime `dotnet-framework` |
| `Plant.Hmi/packages.config` (EntityFramework 6.2.0, log4net 2.0.8, Newtonsoft.Json 12.0.1) | three NuGet components; Newtonsoft.Json 12.0.1 has GHSA-5crp-9r3c-p9vr |
| `packages/Newtonsoft.Json.12.0.1/` | the same component, not repeated; `packages/` is not own code |
| `Plant.Web/Plant.Web.csproj` with `<PackageReference>` BouncyCastle 1.8.5, no lockfile | the component, and a `sbom_dependencies` skip: transitive packages unknown |
| `Plant.Web/Web.config` | clear-text password, debug compilation, WCF `basicHttpBinding` with `security mode="None"` |
| `Plant.Hmi/App.config` | nothing: integrated security, and a masked password |
| `Plant.Hmi/bin/Debug/Plant.Hmi.exe.config` | nothing: build output |
| `Plant.Legacy` targeting `v4.0` | .NET Framework 4.0 out of support since 2016-01-12 |
| `Signing/Plant.snk` (a 596-byte key pair; dummy bytes) | signing key committed to the repository |
| `Plant.Web/OrderService.svc.cs` | C# rules: SQL by concatenation, BinaryFormatter, MD5, certificate validation off |
## `legacy-sample`
A small .NET Framework 4.8 library in C# and VB.NET with a `Web.config`,
planted for DevSkim (#494), which reads it without a build. Also a nightly
target (`dotnet-legacy-sample`), as is `framework48` (`dotnet-framework48`).
| What | Expected (DevSkim rule) |
|---|---|
| `TelemetryClient.cs`: `SecurityProtocolType.Ssl3` | outdated / hard-coded TLS version (DS440020, DS144436), CWE-757 |
| `TelemetryClient.cs`: `ServerCertificateValidationCallback = … => true` | certificate validation off (DS126187), CWE-295 |
| `TelemetryClient.cs`: `DESCryptoServiceProvider` | broken cipher (DS106864), CWE-327 |
| `TelemetryClient.cs`: `XmlResolver = new XmlUrlResolver()` | XML external entities (DS132783), CWE-611 |
| `LegacyLink.vb`: `SHA1.Create()` | nothing from DevSkim (its word match DS126858 is switched off as too noisy) |
| `LegacyLink.vb`: `BinaryFormatter.Deserialize` | unsafe deserialisation (DS425070), CWE-502 |
| `Web.config`: `<trace enabled="true">`, `requireSSL="false"` | tracing on (DS450002, CWE-489), cookies without Secure (DS450001, CWE-614) |
In `framework48`, DevSkim finds the `BinaryFormatter` (DS425070) in
`OrderService.svc.cs` (the MD5 hash there is our own semgrep rule's);
`packages/` and `bin/` are not read.