Rajashekhar Muntha
Rajashekhar Muntha

Reputation: 61

How to integrate ZAP to jenkins using python?

Actually I don't know python. In order to integrate zap with jenkins I googled a lot. But I couldn't find anything useful.
This is link I found

I followed the steps.. but while executing the python script.

Traceback (most recent call last):
File "zap-python-script.py", line 15, in zap.urlopen(target)
File "/usr/lib/python2.6/site-packages/python_owasp_zap_v2.4-0.0.2-py2.6.egg/zapv2/init.py", line 116, in urlopen return urllib.urlopen(*args, **kwargs).read()
File "/usr/lib64/python2.6/urllib.py", line 86, in urlopen return opener.open(url)
File "/usr/lib64/python2.6/urllib.py", line 207, in open return getattr(self, name)(url)
File "/usr/lib64/python2.6/urllib.py", line 346, in open_httph.endheaders()
File "/usr/lib64/python2.6/httplib.py", line 908, in endheadersself._send_output()
File "/usr/lib64/python2.6/httplib.py", line 780, in _send_outputself.send(msg)
File "/usr/lib64/python2.6/httplib.py", line 739, in sendself.connect()
File "/usr/lib64/python2.6/httplib.py", line 720, in connectself.timeout)
File "/usr/lib64/python2.6/socket.py", line 567, in create_connectionraise error, msg

IOError: [Errno socket error] [Errno 111] Connection refused

I am getting this error. here ttarget = http://10.200.35.11:7006/myapplicationurl

Please provide me the solution to solve this error or suggest me a way to integrate ZAP with jenkins.

Python code

#!/usr/bin/env python
import time
from pprint import pprint
from zapv2 import ZAPv2
target = 'http://10.200.35.11:7006/MyApp/login.jsp'
# zap = ZAPv2()
# Use the line below if ZAP is not listening on 8090
zap=ZAPv2(proxies='http':http://127.0.0.1:8090','https':'http://127.0.0.1:8090'})
# do stuff
print 'Accessing target %s' % target
# try have a unique enough session...
zap.urlopen(target)
# Give the sites tree a chance to get updated
time.sleep(2)

print 'Spidering target %s' % target
zap.spider.scan(target)
# Give the Spider a chance to start
time.sleep(2)
while (int(zap.spider.status()) < 100):
 print 'Spider progress %: ' + zap.spider.status()
 time.sleep(2)
print 'Spider completed'
# Give the passive scanner a chance to finish
time.sleep(5)
print 'Scanning target %s' % target
zap.ascan.scan(target)
while (int(zap.ascan.status()) < 100):
 print 'Scan progress %: ' + zap.ascan.status()
 time.sleep(5)
print 'Scan completed'
# Report the results
print 'Hosts: ' + ', '.join(zap.core.hosts)
print 'Alerts: '
pprint (zap.core.alerts())

Please advise me onthis...

Upvotes: 1

Views: 801

Answers (1)

Related Questions