Skip to content

Commit 9f47561

Browse files
committed
feat(logging): Capture resolved store properties after mapping
Signed-off-by: Matthew H. Irby <[email protected]>
1 parent e98c533 commit 9f47561

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

RemoteFile/RemoteFileJobTypeBase.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Newtonsoft.Json;
1212
using System;
1313
using System.Collections.Generic;
14+
using Keyfactor.Logging;
1415

1516
namespace Keyfactor.Extensions.Orchestrator.RemoteFile
1617
{
@@ -35,6 +36,8 @@ public abstract class RemoteFileJobTypeBase
3536

3637
internal void SetJobProperties(JobConfiguration config, CertificateStore certificateStoreDetails, ILogger logger)
3738
{
39+
logger.MethodEntry(LogLevel.Debug);
40+
3841
logger.LogDebug($"Begin {config.Capability} for job id {config.JobId}...");
3942
logger.LogDebug($"Server: {certificateStoreDetails.ClientMachine}");
4043
logger.LogDebug($"Store Path: {certificateStoreDetails.StorePath}");
@@ -73,17 +76,43 @@ internal void SetJobProperties(JobConfiguration config, CertificateStore certifi
7376
FileTransferProtocol = ApplicationSettings.FileTransferProtocol;
7477
if (properties.FileTransferProtocol != null && !string.IsNullOrEmpty(properties.FileTransferProtocol.Value))
7578
{
79+
logger.LogDebug($"Attempting to map file transfer protocol from properties. Current Value: {FileTransferProtocol}, Property Value: {properties.FileTransferProtocol.Value}");
7680
ApplicationSettings.FileTransferProtocolEnum fileTransferProtocol;
7781
if (Enum.TryParse(properties.FileTransferProtocol.Value, out fileTransferProtocol))
82+
{
83+
logger.LogDebug("Successfully mapped file transfer protocol from properties");
7884
FileTransferProtocol = fileTransferProtocol;
85+
}
86+
7987
}
8088

8189
if (config.JobProperties != null)
8290
{
8391
KeyType = !config.JobProperties.ContainsKey("keyType") || config.JobProperties["keyType"] == null || string.IsNullOrEmpty(config.JobProperties["keyType"].ToString()) ? string.Empty : config.JobProperties["keyType"].ToString();
8492
KeySize = !config.JobProperties.ContainsKey("keySize") || config.JobProperties["keySize"] == null || string.IsNullOrEmpty(config.JobProperties["keySize"].ToString()) || !int.TryParse(config.JobProperties["keySize"].ToString(), out int notUsed2) ? 2048 : Convert.ToInt32(config.JobProperties["keySize"]);
8593
SubjectText = !config.JobProperties.ContainsKey("subjectText") || config.JobProperties["subjectText"] == null || string.IsNullOrEmpty(config.JobProperties["subjectText"].ToString()) ? string.Empty : config.JobProperties["subjectText"].ToString();
86-
}
94+
}
95+
96+
logger.LogDebug("Store properties have been configured successfully. Property values:");
97+
logger.LogDebug($"UserName: {UserName}");
98+
logger.LogDebug($"UserPassword: {LogSensitiveField(UserPassword)}");
99+
logger.LogDebug($"StorePassword: {LogSensitiveField(StorePassword)}");
100+
logger.LogDebug($"SudoImpersonatedUser: {SudoImpersonatedUser}");
101+
logger.LogDebug($"RemoveRootCertificate: {RemoveRootCertificate}");
102+
logger.LogDebug($"SSHPort: {SSHPort}");
103+
logger.LogDebug($"IncludePortInSPN: {IncludePortInSPN}");
104+
logger.LogDebug($"FileTransferProtocol: {FileTransferProtocol}");
105+
logger.LogDebug($"CreateCSROnDevice: {CreateCSROnDevice}");
106+
logger.LogDebug($"KeyType: {KeyType}");
107+
logger.LogDebug($"KeySize: {KeySize}");
108+
logger.LogDebug($"SubjectText: {SubjectText}");
109+
110+
logger.MethodExit(LogLevel.Debug);
111+
}
112+
113+
private string LogSensitiveField(string input)
114+
{
115+
return string.IsNullOrWhiteSpace(input) ? "" : "(hidden)";
87116
}
88117
}
89118
}

RemoteFile/RemoteHandlers/SSHHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ public override byte[] DownloadCertificateFile(string path)
251251

252252
if (!string.IsNullOrEmpty(ApplicationSettings.SeparateUploadFilePath) && IsStoreServerLinux)
253253
{
254+
_logger.LogDebug("Splitting store path");
254255
SplitStorePathFile(path, out altPathOnly, out altFileNameOnly);
255256
downloadPath = ApplicationSettings.SeparateUploadFilePath + altFileNameOnly;
256257
RunCommand($"cp {path} {downloadPath}", null, ApplicationSettings.UseSudo, null);

0 commit comments

Comments
 (0)