Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
- Implemented the PhpAnalyzerPlugin to analyze PHP projects. - Created ComposerLockData class to represent data from composer.lock files. - Developed ComposerLockReader to load and parse composer.lock files asynchronously. - Introduced ComposerPackage class to encapsulate package details. - Added PhpPackage class to represent PHP packages with metadata and evidence. - Implemented PhpPackageCollector to gather packages from ComposerLockData. - Created PhpLanguageAnalyzer to perform analysis and emit results. - Added capability signals for known PHP frameworks and CMS. - Developed unit tests for the PHP language analyzer and its components. - Included sample composer.lock and expected output for testing. - Updated project files for the new PHP analyzer library and tests.
26 lines
805 B
C#
26 lines
805 B
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace StellaOps.Findings.Ledger.Domain;
|
|
|
|
public static class LedgerChainIdGenerator
|
|
{
|
|
public static Guid FromTenantPolicy(string tenantId, string policyVersion)
|
|
{
|
|
return FromTenantSubject(tenantId, policyVersion);
|
|
}
|
|
|
|
public static Guid FromTenantSubject(string tenantId, string subject)
|
|
{
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(tenantId);
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(subject);
|
|
|
|
var normalized = $"{tenantId.Trim()}::{subject.Trim()}";
|
|
var bytes = Encoding.UTF8.GetBytes(normalized);
|
|
Span<byte> guidBytes = stackalloc byte[16];
|
|
var hash = SHA256.HashData(bytes);
|
|
hash.AsSpan(0, 16).CopyTo(guidBytes);
|
|
return new Guid(guidBytes);
|
|
}
|
|
}
|