use xslt!

This commit is contained in:
2023-04-09 01:06:01 +02:00
parent c7b85862e6
commit 3a162f4568
10 changed files with 238 additions and 227 deletions

View File

@ -1,19 +1,29 @@
<?php
$yaml = yaml_parse_file($argv[1]);
$xml = new SimpleXMLElement("<lanScanConf></lanScanConf>");
$site = str_replace(".yaml", "", basename($argv[1]));
foreach ($yaml as $groupName => $hosts) {
$xmlGroup = $xml->addChild("group");
$xmlGroup->addAttribute("name", $groupName);
if ($hosts) foreach ($hosts as $hostName => $services) {
$xmlHost = $xmlGroup->addChild("host");
$xmlHost->addAttribute("name", $hostName);
if ($services) foreach ($services as $service) {
$xmlHost->addChild("service");
$xmlHost->addAttribute("name", $service);
$xml = new SimpleXMLElement(<<<XML
<?xml version="1.0"?>
<?xml-stylesheet href='../results.xsl' type='text/xsl'?>
<lanScanConf/>
XML);
$xml->addChild("scan path='scans/$site.xml'");
foreach ($yaml as $siteName => $groups) {
$xml->addAttribute("name", $siteName);
if ($groups) foreach ($groups as $groupName => $hosts) {
$xmlGroup = $xml->addChild("group");
$xmlGroup->addAttribute("name", $groupName);
if ($hosts) foreach ($hosts as $hostName => $services) {
$xmlHost = $xmlGroup->addChild("host");
$xmlHost->addAttribute("address", $hostName);
if ($services) foreach ($services as $service) {
$xmlService = $xmlHost->addChild("service");
$xmlService->addAttribute("name", $service);
}
}
}
}
}
echo $xml->asXML();
$xml->asXML("site/$site.xml");
?>