【问题标题】:OWASP ZAP API root element is missing errorOWASP ZAP API 根元素丢失错误
【发布时间】:2021-09-01 17:59:47
【问题描述】:

我正在使用 OWASP ZAP API 在 Windows 上编写一个程序,以自动执行针对目标 URL 运行 ZAP 的过程。到目前为止,我能够使用 zap.bat 文件和参数 -daemon -config api.disablekey=true 成功启动应用程序。启动应用程序,ZAP 能够监听 localhost:8080。我还创建了传递这些参数的 ClientAPi 对象:

ClientApi zaproxy = new ClientApi("127.0.0.1", 8080, null);

我现在尝试使用 Context 类中的 includeInContext(string contextname, string regex) 方法设置上下文,但出现错误:

System.Exception: 'System.Xml.XmlException: Root element is missing.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at System.Xml.XmlTextReaderImpl.Read()
   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.LoadXml(String xml)
   at OWASPZAPDotNetAPI.ClientApi.CallApiRaw(String component, String operationType, String operationName, Dictionary 2 parameters)
   at OWASPZAPDotNetAPI.ClientApi.CallApi(String component, String operationType, String operationName, Dictionary 2 parameters)
   at OWASPZAPDotNetAPI.Generated.Context.includeInContext(String contextname, String regex)

但是,当我在后台启动 ZAP GUI,然后运行守护程序并设置上下文时,它似乎可以工作。有人可以让我知道如何解决上述错误吗?谢谢!

【问题讨论】:

    标签: security testing owasp zap penetration-testing


    【解决方案1】:

    看看https://www.zaproxy.org/docs/automate/ - 这列出了您可以自动化 ZAP 的方法。 我怀疑其中一个打包的扫描可能更易于您使用。

    【讨论】: