Nmap Development mailing list archives

[RFC] Add DOCTYPE to Nmap XML?


From: Daniel Miller <bonsaiviking () gmail com>
Date: Fri, 18 Oct 2013 14:52:47 -0500

List,

Since we have a DTD, would it make sense to add a DOCTYPE declaration to Nmap's XML output? Here's a patch to do so:

diff --git a/nmap.cc b/nmap.cc
index 71f80b9..7654992 100644
--- a/nmap.cc
+++ b/nmap.cc
@@ -1707,6 +1707,7 @@ int nmap_main(int argc, char *argv[]) {
   chomp(mytime);
   char *xslfname = o.XSLStyleSheet();
   xml_start_document();
+ log_write(LOG_XML, "<!DOCTYPE nmaprun PUBLIC \"-//IDN nmap.org//DTD Nmap XML %s//EN\" \"https://svn.nmap.org/nmap/docs/nmap.dtd\";>\n", NMAP_XMLOUTPUTVERSION);
   if (xslfname) {
     xml_open_pi("xml-stylesheet");
     xml_attribute("href", "%s", xslfname);

This declares a PUBLIC doctype, as opposed to the SYSTEM doctype suggested for validation in nmap.dtd. The Formal Public Identifier (FPI, the part with all the //) is constructed as follows:

-// = Unregistered owner
IDN nmap.org = Name of owner derived from domain name
//DTD = This FPI identifies a DTD
Nmap XML 1.03 = Description of the subject
//EN = Language the DTD is written in

The URI references the current version of the DTD. This is not ideal, because the NMAP_XMLOUTPUTVERSION can change. Ideally, the URI would change, too, with historical copies available at unique URIs, but this would work for now.

Any thoughts/testing are appreciated.

Dan
_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/


Current thread: