Esempio n. 1
0
        private XmlNode GetNexposeReport(string id)
        {
            byte[] report;
            using (NexposeSession session = new NexposeSession(this.Configuration["nexposeHost"])) {
                session.Authenticate(this.Configuration ["nexposeUser"], this.Configuration ["nexposePass"]);

                using (NexposeManager11 manager = new NexposeManager11(session)) {
                    Dictionary <NexposeReportFilterType, string> filters = new Dictionary <NexposeReportFilterType, string> ();
                    filters.Add(NexposeReportFilterType.Site, id);

                    report = manager.GenerateAdHocReport(NexposeUtil.GenerateAdHocReportConfig("audit-report", NexposeReportFormat.RawXMLv2, filters));

                    //stupid hack
                    while (report.Length < 91)
                    {
                        Thread.Sleep(500);
                        report = manager.GenerateAdHocReport(NexposeUtil.GenerateAdHocReportConfig("audit-report", NexposeReportFormat.RawXMLv2, filters));
                    }
                }
            }

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(Encoding.UTF8.GetString(report));

            return(doc.LastChild);
        }
Esempio n. 2
0
        public override void ProcessRequest(HttpContext context)
        {
            using (NexposeSession session = new NexposeSession("192.168.56.105"))
            {
                session.Authenticate("nexpose", "nexpose");

                using (NexposeManager11 manager = new NexposeManager11(session))
                {
                    string template = "audit-report";
                    string format   = "text";
                    string siteID   = context.Request["SiteID"];
                    string xml      = string.Empty;

                    xml = xml + "<AdhocReportConfig template-id=\"" + template + "\" format=\"" + format + "\">";
                    xml = xml + "<Filters><filter type=\"site\" id=\"" + siteID + "\"></filter></Filters>";
                    xml = xml + "</AdhocReportConfig>";

                    XmlDocument request = new XmlDocument();
                    request.LoadXml(xml);

                    byte[] report = manager.GenerateAdHocReport(request);

                    context.Response.Write(Encoding.ASCII.GetString(report));
                }
            }
        }