Skip to content

Commit

Permalink
add a debug page and track the assembly version that is used to sign …
Browse files Browse the repository at this point in the history
…and verify sig
  • Loading branch information
dangershony committed Dec 9, 2024
1 parent e3f9922 commit 3b2cbf7
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
40 changes: 40 additions & 0 deletions src/Angor/Client/Pages/DebugPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@page "/debug"

@using Angor.Shared.Utilities
@inject ILogger<DebugPage> Logger

<PageTitle>Debug Page</PageTitle>

<h3>Assembly Information</h3>

@foreach (var assembly in assemblyInfos)
{
<div class="card mb-3">
<div class="card-header">
<h5>@assembly.Name</h5>
</div>
<div class="card-body">
<p><strong>Version:</strong> @assembly.Version</p>
<p><strong>Full Name:</strong> @assembly.FullName</p>
<p><strong>Location:</strong> @assembly.Location</p>
<p><strong>Image Runtime Version:</strong> @assembly.ImageRuntimeVersion</p>
<p><strong>Entry Point:</strong> @assembly.EntryPoint</p>
<p><strong>Referenced Assemblies:</strong></p>
<ul>
@foreach (var referencedAssembly in assembly.ReferencedAssemblies)
{
<li>@referencedAssembly</li>
}
</ul>
</div>
</div>
}

@code {
private List<AssemblyInfo> assemblyInfos = new();

protected override void OnInitialized()
{
assemblyInfos = AssemblyInfoHelper.GetAllAssembliesInfo();
}
}
2 changes: 2 additions & 0 deletions src/Angor/Shared/ProtocolNew/FounderTransactionActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public SignatureInfo SignInvestorRecoveryTransactions(ProjectInfo projectInfo, s

SignatureInfo info = new SignatureInfo { ProjectIdentifier = projectInfo.ProjectIdentifier };

AssemblyLogger.LogAssemblyVersion(key.GetType(), _logger);

// todo: david change to Enumerable.Range
for (var stageIndex = 0; stageIndex < projectInfo.Stages.Count; stageIndex++)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Angor/Shared/ProtocolNew/InvestorTransactionActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,10 @@ public bool CheckInvestorRecoverySignatures(ProjectInfo projectInfo, Transaction
.Select(_ => _.TxOut)
.ToArray();

bool failedValidation = false;
AssemblyLogger.LogAssemblyVersion(pubkey.GetType(), _logger);

// todo: David change to Enumerable.Range
bool failedValidation = false;
for (var stageIndex = 0; stageIndex < projectInfo.Stages.Count; stageIndex++)
{
var scriptStages = _investmentScriptBuilder.BuildProjectScriptsForStage(projectInfo, investorKey, stageIndex, secretHash);
Expand Down
51 changes: 51 additions & 0 deletions src/Angor/Shared/Utilities/AssemblyInfoHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Reflection;
using Microsoft.Extensions.Logging;

public static class AssemblyInfoHelper
{
public static List<AssemblyInfo> GetAllAssembliesInfo()
{
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
var assemblyInfos = new List<AssemblyInfo>();

foreach (var assembly in assemblies)
{
var assemblyInfo = new AssemblyInfo
{
Name = assembly.GetName().Name,
Version = assembly.GetName().Version?.ToString() ?? "Version not found",
FullName = assembly.FullName,
Location = assembly.Location,
ImageRuntimeVersion = assembly.ImageRuntimeVersion,
EntryPoint = assembly.EntryPoint?.ToString() ?? "No entry point",
ReferencedAssemblies = assembly.GetReferencedAssemblies().Select(a => a.FullName).ToList()
};

assemblyInfos.Add(assemblyInfo);
}

return assemblyInfos;
}
}

public class AssemblyInfo
{
public string Name { get; set; }
public string Version { get; set; }
public string FullName { get; set; }
public string Location { get; set; }
public string ImageRuntimeVersion { get; set; }
public string EntryPoint { get; set; }
public List<string> ReferencedAssemblies { get; set; } = new();
}

public static class AssemblyLogger
{
public static void LogAssemblyVersion(Type type, ILogger logger)
{
var assembly = type.Assembly;
var version = assembly.GetName().Version?.ToString() ?? "Version not found";
var name = assembly.GetName().Name;
logger.LogInformation($"Assembly: {name}, Version: {version}");
}
}

0 comments on commit 3b2cbf7

Please sign in to comment.