Minimal .NET/C# support for epic #445 (N1-N5; N6 out of scope): - N1: solutions and .csproj/.vbproj/.fsproj at any depth, old vs SDK style, TargetFramework(s)/TargetFrameworkVersion; recorded as target facts (dotnet_runtime, dotnet_solution, dotnet_project). - N2: NuGet components from packages.config, PackageReference (attribute, child element, VersionOverride, Directory.Packages.props), packages.lock.json, obj/project.assets.json and packages/<Id>.<Version>/ with pkg:nuget purls for OSV. PackageReference projects without lockfile or assets are reported as unresolved (sbom_dependencies). Target frameworks past Microsoft's end of support are findings (CWE-1104). - N3-lite: own semgrep rule pack cra_semgrep_csharp.yaml (SQLi, command injection, deserialization, XXE, path traversal, weak crypto/ECB, TLS validation off, hard-coded credentials) with semgrep --test cases; semgrep.rs runs every bundled pack. - N4: web.config/app.config checks (clear-text passwords, debug, customErrors, httpCookies, WCF security) and committed key/publish files. - N5: bin/obj beside projects, NuGet packages/, .vs, .nuget, TestResults are not own code. Control map bindings, fixtures/dotnet/framework48 with a test, and docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Net;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace Plant.Web
|
|
{
|
|
public class OrderService : IOrderService
|
|
{
|
|
private readonly SqlConnection _conn;
|
|
|
|
public OrderService(SqlConnection conn)
|
|
{
|
|
_conn = conn;
|
|
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, errors) => true;
|
|
}
|
|
|
|
public int CountOrders(string customer)
|
|
{
|
|
var cmd = new SqlCommand("SELECT COUNT(*) FROM Orders WHERE Customer = '" + customer + "'", _conn);
|
|
return (int)cmd.ExecuteScalar();
|
|
}
|
|
|
|
public object ReadState(Stream body)
|
|
{
|
|
var formatter = new BinaryFormatter();
|
|
return formatter.Deserialize(body);
|
|
}
|
|
|
|
public byte[] Checksum(byte[] data)
|
|
{
|
|
using (var md5 = MD5.Create())
|
|
{
|
|
return md5.ComputeHash(data);
|
|
}
|
|
}
|
|
}
|
|
}
|