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

Fix json output when a node with attributes has the same key several times #245

Merged
merged 1 commit into from
Nov 3, 2024

Conversation

yardlogs
Copy link
Contributor

Some XML nodes have the same key multiple times. If the sub node have attributes, only the last key is keeped.
I adapted the code that managed nodes without attributes to manage those with.

The event "Microsoft-Windows-CertificateServicesClient-Lifecycle-System/Operational 1007" with the "EKU" node show the case.

image

Before the fix

{
  [...]
    "UserData": {
      "CertNotificationData": {
        "#attributes": {
          "ProcessName": "PowerShell.exe",
          "AccountName": "LAB___\\Administrator",
          "Context": "Machine"
        },
        "CertificateDetails": {
          "#attributes": {
            "Thumbprint": "a35fb0138078445b81b907997a719c2d55f070a8"
          },
          "SubjectNames": {
            "SubjectName": "www.test.local",
            "SubjectName_1": "CN=test.local",
            "SubjectName_2": "test.local"
          },
          "EKUs": {
            "EKU": {
              "#attributes": {
                "Name": "Server Authentication",
                "OID": "1.3.6.1.5.5.7.3.1"
              }
            }
          },
          "NotValidAfter": "2025-09-23T13:23:57Z"
        }
      }
    }
  }
}

After the fix:

 {
   [...]
    "UserData": {
      "CertNotificationData": {
        "#attributes": {
          "ProcessName": "PowerShell.exe",
          "AccountName": "LAB___\\Administrator",
          "Context": "Machine"
        },
        "CertificateDetails": {
          "#attributes": {
            "Thumbprint": "a35fb0138078445b81b907997a719c2d55f070a8"
          },
          "SubjectNames": {
            "SubjectName": "www.test.local",
            "SubjectName_1": "CN=test.local",
            "SubjectName_2": "test.local"
          },
          "EKUs": {
            "EKU": {
              "#attributes": {
                "Name": "Server Authentication",
                "OID": "1.3.6.1.5.5.7.3.1"
              }
            },
            "EKU_1": {
              "#attributes": {
                "Name": "Client Authentication",
                "OID": "1.3.6.1.5.5.7.3.2"
              }
            }
          },
          "NotValidAfter": "2025-09-23T13:23:57Z"
        }
      }
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants