Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ab#66779 #32

Open
wants to merge 33 commits into
base: release-2.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9a8981f
doc updates
bhillkeyfactor Jan 7, 2025
23f490d
Upgrade .net 6 and .net 8
bhillkeyfactor Jan 7, 2025
a4a8638
new doc tool
bhillkeyfactor Jan 7, 2025
e55b7f8
new doc tool
bhillkeyfactor Jan 7, 2025
0593d47
new doc tool
bhillkeyfactor Jan 8, 2025
224e2d2
new doc tool
bhillkeyfactor Jan 8, 2025
ef1c300
Update generated docs
Jan 8, 2025
bbe2ffc
new doc tool
bhillkeyfactor Jan 8, 2025
226f7dd
Merge branch 'ab#66779' of https://github.com/Keyfactor/paloalto-fire…
bhillkeyfactor Jan 8, 2025
d3fa0ac
new doc tool
bhillkeyfactor Jan 8, 2025
d89804c
Update generated docs
Jan 8, 2025
dc5d627
new doc tool
bhillkeyfactor Jan 8, 2025
03371f6
Merge branch 'ab#66779' of https://github.com/Keyfactor/paloalto-fire…
bhillkeyfactor Jan 8, 2025
171f924
Update generated docs
Jan 8, 2025
05c149e
new doc tool
bhillkeyfactor Jan 8, 2025
b522bda
Merge branch 'ab#66779' of https://github.com/Keyfactor/paloalto-fire…
bhillkeyfactor Jan 8, 2025
e60e057
Update generated docs
Jan 8, 2025
e0a4732
new doc tool
bhillkeyfactor Jan 8, 2025
ff0ec63
Update generated docs
Jan 8, 2025
0977a7d
new doc tool
bhillkeyfactor Jan 8, 2025
4cc5e62
Update generated docs
Jan 8, 2025
7e4f13f
new doc tool
bhillkeyfactor Jan 8, 2025
f22bd73
Update generated docs
Jan 8, 2025
703afa3
new doc tool
bhillkeyfactor Jan 8, 2025
d83a469
Update generated docs
Jan 8, 2025
01f6396
new doc tool
bhillkeyfactor Jan 8, 2025
3f6a7f9
Update generated docs
Jan 8, 2025
5b948ef
Update content.md
bhillkeyfactor Jan 9, 2025
c1d3b09
Update generated docs
Jan 9, 2025
700f1b1
Update paloalto.md
bhillkeyfactor Jan 9, 2025
4c2c62d
Update generated docs
Jan 9, 2025
d1729c7
Update CHANGELOG.md
bhillkeyfactor Jan 9, 2025
8755daf
Added chain fixes from version 2.3 to 2.4
bhillkeyfactor Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ on:

jobs:
call-starter-workflow:
uses: keyfactor/actions/.github/workflows/starter.yml@v2
uses: keyfactor/actions/.github/workflows/starter.yml@3.1.2
secrets:
token: ${{ secrets.V2BUILDTOKEN}}
APPROVE_README_PUSH: ${{ secrets.APPROVE_README_PUSH}}
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }}
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }}
scan_token: ${{ secrets.SAST_TOKEN }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.3.1
* .Net 6 and .Net 8 Build Support
* Documentation Updates

2.3.0
* Added support for Template Only Commits
* Added support for Template Stack Commits
Expand Down
55 changes: 55 additions & 0 deletions PaloAlto/Client/PaloAltoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
using Keyfactor.Extensions.Orchestrator.PaloAlto.Models.Responses;
using Keyfactor.Logging;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Keyfactor.Extensions.Orchestrator.PaloAlto.Client
{
Expand Down Expand Up @@ -393,6 +395,59 @@ private void EnsureSuccessfulResponse(HttpResponseMessage response)
_logger.LogError($"Error Occured in PaloAltoClient.EnsureSuccessfulResponse: {e.Message}");
throw;
}
}

public string MaskSensitiveData(string json)
{
try
{
JObject jsonObject = JObject.Parse(json);

// Replace all keys named "Password" or similar
MaskKey(jsonObject, "StorePassword");
MaskKey(jsonObject, "ServerPassword");
MaskKey(jsonObject, "PrivateKeyPassword");

return jsonObject.ToString(Newtonsoft.Json.Formatting.Indented);
}
catch (JsonException ex)
{
Console.WriteLine("Invalid JSON provided: " + ex.Message);
return json; // Return the original JSON if parsing fails
}
}

private static void MaskKey(JObject jsonObject, string key)
{
foreach (var property in jsonObject.Properties())
{
if (property.Name.Equals(key, StringComparison.OrdinalIgnoreCase))
{
property.Value = "*****";
}
else if (property.Value.Type == JTokenType.Object)
{
MaskKey((JObject)property.Value, key);
}
else if (property.Value.Type == JTokenType.String)
{
// Optionally handle nested JSON strings
string value = property.Value.ToString();
if (value.StartsWith("{") && value.EndsWith("}"))
{
try
{
JObject nestedObject = JObject.Parse(value);
MaskKey(nestedObject, key);
property.Value = nestedObject.ToString(Newtonsoft.Json.Formatting.None);
}
catch
{
// Not a valid JSON string, skip
}
}
}
}
}
}
}
18 changes: 10 additions & 8 deletions PaloAlto/Jobs/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public Inventory(IPAMSecretResolver resolver)
_resolver = resolver;
}

private PaloAltoClient _client;
private string ServerPassword { get; set; }
private string ServerUserName { get; set; }

Expand Down Expand Up @@ -79,25 +80,26 @@ private JobResult PerformInventory(InventoryJobConfiguration config, SubmitInven
config.JobHistoryId, ServerUserName, ServerPassword);
if (!valid) return result;

//Get the list of certificates and Trusted Roots
_client =
new PaloAltoClient(config.CertificateStoreDetails.ClientMachine,
ServerUserName, ServerPassword); //Api base URL Plus Key

_logger.LogTrace("Store Properties are Valid");
_logger.LogTrace($"Inventory Config {JsonConvert.SerializeObject(config)}");
_logger.LogTrace($"Inventory Config {_client.MaskSensitiveData(JsonConvert.SerializeObject(config))}");
_logger.LogTrace(
$"Client Machine: {config.CertificateStoreDetails.ClientMachine} ApiKey: {config.ServerPassword}");

//Get the list of certificates and Trusted Roots
var client =
new PaloAltoClient(config.CertificateStoreDetails.ClientMachine,
ServerUserName, ServerPassword); //Api base URL Plus Key
_logger.LogTrace("Inventory Palo Alto Client Created");

//Change the path if you are pointed to a Panorama Device
var rawCertificatesResult = client.GetCertificateList($"{config.CertificateStoreDetails.StorePath}/certificate/entry").Result;
var rawCertificatesResult = _client.GetCertificateList($"{config.CertificateStoreDetails.StorePath}/certificate/entry").Result;

var certificatesResult =
rawCertificatesResult.CertificateResult.Entry.FindAll(c => c.PublicKey != null);
LogResponse(certificatesResult); //Trace Write Certificate List Response from Palo Alto

var trustedRootPayload = client.GetTrustedRootList().Result;
var trustedRootPayload = _client.GetTrustedRootList().Result;
LogResponse(trustedRootPayload); //Trace Write Trusted Cert List Response from Palo Alto

var warningFlag = false;
Expand Down Expand Up @@ -133,7 +135,7 @@ private JobResult PerformInventory(InventoryJobConfiguration config, SubmitInven
try
{
_logger.LogTrace($"Building Trusted Root Inventory Item Alias: {trustedRootCert.Name}");
var certificatePem = client.GetCertificateByName(trustedRootCert.Name);
var certificatePem = _client.GetCertificateByName(trustedRootCert.Name);
_logger.LogTrace($"Certificate String Back From Palo Pem: {certificatePem.Result}");
var bytes = Encoding.ASCII.GetBytes(certificatePem.Result);
var cert = new X509Certificate2(bytes);
Expand Down
Loading
Loading