feat(sast): DevSkim for .NET without a build (#494) #506

Merged
sharang merged 1 commits from feat/494-devskim into main 2026-10-06 12:51:11 +00:00
Owner

Closes #494.

What

DevSkim (MIT, Microsoft) as a new SAST stage sast_dotnet on trees with C# or VB.NET code: .cs, .vb, Razor/ASP.NET pages and .config files, without a build. Runs offline in the agent image; SARIF read with import::sarif::parse; findings normalised like the other scanners and control-mapped.

  • Rules: DevSkim's defaults at Critical/Important/Moderate (ManualReview/BestPractice hints left out). Ignored: DS205000 (NuGet feed mapping), DS184626 (controller base class), DS440000 (generic twin of DS440020), and two FP storms on real C#: DS148264 (any method named Random, 71 hits in OpenRA) and DS126858 (the bare words md5/sha1, 35 in OpenRA). DS168931 and our own semgrep rules still cover weak hashes and System.Random. After that: OpenRA 3 hits, eShopOnWeb 14 Low http:// hits, about 2 s each.
  • Severity from DevSkim's own Critical/Important/Moderate (its SARIF level says error for both of the first two).
  • CWE: DevSkim's SARIF has none, so pipeline/devskim.rs gives each rule one; the control map binds devskim by CWE (cra-ai-1, 8, 10, 13, 14, 15, 16, 20) for csharp and vb. A failed run is a sast_dotnet skip, so those controls are "not assessed" rather than clean.
  • languages.rs now records VB.NET (vb).
  • C# semgrep depth (GitLab csharp/) came with #492 (#504). elttam has no C# weakness rules: its C# content is an entrypoint enumerator and ORM-leak hints whose upstream tests fail, so neither is vendored.

Image

There is no DevSkim release binary for Linux; the CLI ships as a .NET tool on nuget.org. Dockerfile.agent pins the 1.0.100 nupkg (sha256) and the .NET 10.0.12 runtime only, no SDK (sha512), keeps only the linux-x64 natives and runs it through docker/devskim.sh with invariant globalisation (no ICU). Tools stage: 1.525 GB → 1.623 GB (+98.5 MB: runtime 80 MB, DevSkim 16 MB). Checked in the built tools image as uid 10001 with an empty environment and --network none: runs and finds the planted weaknesses. tool-versions.json gains devskim and dotnet-runtime.

Fixtures

fixtures/dotnet/legacy-sample (C# + VB.NET + Web.config: SSL 3, certificate validation off, DES, XXE, BinaryFormatter, tracing, cookies without Secure), README table, and nightly targets dotnet-legacy-sample and dotnet-framework48 with expect blocks. Their baselines don't exist yet: they need a bless dispatch once this image is deployed.

Checks

cargo fmt, cargo clippy -p compliance-agent --all-targets -- -D warnings, cargo test -p compliance-agent -p control-map --lib. Staging check: test plan §25.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

Closes #494. ## What DevSkim (MIT, Microsoft) as a new SAST stage `sast_dotnet` on trees with C# or VB.NET code: `.cs`, `.vb`, Razor/ASP.NET pages and `.config` files, without a build. Runs offline in the agent image; SARIF read with `import::sarif::parse`; findings normalised like the other scanners and control-mapped. - Rules: DevSkim's defaults at Critical/Important/Moderate (ManualReview/BestPractice hints left out). Ignored: DS205000 (NuGet feed mapping), DS184626 (controller base class), DS440000 (generic twin of DS440020), and two FP storms on real C#: DS148264 (any method named `Random`, 71 hits in OpenRA) and DS126858 (the bare words md5/sha1, 35 in OpenRA). DS168931 and our own semgrep rules still cover weak hashes and `System.Random`. After that: OpenRA 3 hits, eShopOnWeb 14 Low http:// hits, about 2 s each. - Severity from DevSkim's own Critical/Important/Moderate (its SARIF level says `error` for both of the first two). - CWE: DevSkim's SARIF has none, so `pipeline/devskim.rs` gives each rule one; the control map binds `devskim` by CWE (cra-ai-1, 8, 10, 13, 14, 15, 16, 20) for `csharp` and `vb`. A failed run is a `sast_dotnet` skip, so those controls are "not assessed" rather than clean. - `languages.rs` now records VB.NET (`vb`). - C# semgrep depth (GitLab `csharp/`) came with #492 (#504). elttam has no C# weakness rules: its C# content is an entrypoint enumerator and ORM-leak hints whose upstream tests fail, so neither is vendored. ## Image There is no DevSkim release binary for Linux; the CLI ships as a .NET tool on nuget.org. `Dockerfile.agent` pins the 1.0.100 nupkg (sha256) and the .NET 10.0.12 runtime only, no SDK (sha512), keeps only the linux-x64 natives and runs it through `docker/devskim.sh` with invariant globalisation (no ICU). **Tools stage: 1.525 GB → 1.623 GB (+98.5 MB: runtime 80 MB, DevSkim 16 MB).** Checked in the built tools image as uid 10001 with an empty environment and `--network none`: runs and finds the planted weaknesses. `tool-versions.json` gains `devskim` and `dotnet-runtime`. ## Fixtures `fixtures/dotnet/legacy-sample` (C# + VB.NET + Web.config: SSL 3, certificate validation off, DES, XXE, BinaryFormatter, tracing, cookies without Secure), README table, and nightly targets `dotnet-legacy-sample` and `dotnet-framework48` with `expect` blocks. Their baselines don't exist yet: they need a `bless` dispatch once this image is deployed. ## Checks `cargo fmt`, `cargo clippy -p compliance-agent --all-targets -- -D warnings`, `cargo test -p compliance-agent -p control-map --lib`. Staging check: test plan §25. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-10-06 12:37:54 +00:00
feat(sast): DevSkim for .NET without a build (#494)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 8m32s
05fa4975d8
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
sharang force-pushed feat/494-devskim from a00ae6cfa6 to 05fa4975d8 2026-10-06 12:37:54 +00:00 Compare
sharang merged commit 34e3f6cf6a into main 2026-10-06 12:51:11 +00:00
Sign in to join this conversation.