up
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
This commit is contained in:
@@ -27,6 +27,58 @@ public static class PackageUrlBuilder
|
||||
return $"pkg:rpm/{Escape(name)}@{versionComponent}{releaseComponent}?arch={EscapeQuery(architecture)}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds a PURL for a Homebrew formula.
|
||||
/// Format: pkg:brew/{tap}/{formula}@{version}?revision={revision}
|
||||
/// </summary>
|
||||
public static string BuildHomebrew(string tap, string formula, string version, int revision)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(tap);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(formula);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(version);
|
||||
|
||||
var normalizedTap = tap.Trim().ToLowerInvariant();
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("pkg:brew/");
|
||||
builder.Append(Escape(normalizedTap));
|
||||
builder.Append('/');
|
||||
builder.Append(Escape(formula));
|
||||
builder.Append('@');
|
||||
builder.Append(Escape(version));
|
||||
|
||||
if (revision > 0)
|
||||
{
|
||||
builder.Append("?revision=");
|
||||
builder.Append(revision);
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds a PURL for a macOS pkgutil receipt.
|
||||
/// Format: pkg:generic/apple/{identifier}@{version}
|
||||
/// </summary>
|
||||
public static string BuildPkgutil(string identifier, string version)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(identifier);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(version);
|
||||
|
||||
return $"pkg:generic/apple/{Escape(identifier)}@{Escape(version)}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds a PURL for a macOS application bundle.
|
||||
/// Format: pkg:generic/macos-app/{bundleId}@{version}
|
||||
/// </summary>
|
||||
public static string BuildMacOsBundle(string bundleId, string version)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(bundleId);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(version);
|
||||
|
||||
return $"pkg:generic/macos-app/{Escape(bundleId)}@{Escape(version)}";
|
||||
}
|
||||
|
||||
private static string Escape(string value)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(value);
|
||||
|
||||
@@ -6,4 +6,7 @@ public enum PackageEvidenceSource
|
||||
ApkDatabase,
|
||||
DpkgStatus,
|
||||
RpmDatabase,
|
||||
HomebrewCellar,
|
||||
PkgutilReceipt,
|
||||
MacOsBundle,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user