我在Python中有触发器zap,如下所示:
文字来源:-
https://github.com/zaproxy/zaproxy/wiki/ApiPython
我希望通过命令行生成一个HTML报告。
我也想和詹金斯融合。我在Jenkins中发现了很少的Owasp插件,但似乎并没有像预期的那样工作。
任何想法,链接,教程都会对我有帮助。
发布于 2017-08-11 13:08:03
在这个URL/API ( http://ZAP-IP:PORT/UI/core/other/htmlreport/)中,用户可以得到报告。
我没有找到任何zap支持插件,所以我编写了脚本来完成我的任务。守则是:-
@Test
public void Report() {
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"\\src\\lib\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://localhost:8080/UI/core/other/htmlreport");
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.findElement(By.id("apikey")).sendKeys("ChangeMe");
driver.findElement(By.id("button")).click();
SimpleDateFormat dateFormatForFoldername = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
Date currentDate = new Date();
String folderDateFormat = dateFormatForFoldername.format(currentDate);
try {
URL oracle = new URL(driver.getCurrentUrl());
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
BufferedWriter writer = new BufferedWriter(new FileWriter("Reports"+File.separator+"OwaspReport-"+folderDateFormat+".html"));
String inputLine;
while ((inputLine = in.readLine()) != null){
try{
writer.write(inputLine);
}
catch(IOException e){
e.printStackTrace();
return;
}
}
in.close();
writer.close();
driver.quit();
}
catch(Exception ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}注意:-根据zap端口更改URL中的端口,并替换apiKey
希望它能帮助你:)
发布于 2018-01-22 13:21:54
我发现python只与本地zaproxy服务器连接,所以jenkins从服务器和zaproxy服务器应该在同一台机器(Pod)中运行。
我使用jenkins管道和publishHTML插件集成到jenkins结果的报告。
https://stackoverflow.com/questions/45617031
复制相似问题