Zap Docker API Scan: URL Not Found in the Scan Tree

See original GitHub issue

Describe the bug I’m trying to run Zap Docker in my Gitlab CI/CD pipeline and the API scan throws several errors when I try to use the host override, meaning I want to specify a URL different to the one in my OpenAPI file.

2020-10-06 21:10:41,984 http://localhost:48271 "GET http://zap/JSON/ascan/view/status/?scanId=**URL+Not+Found+in+the+Scan+Tree** HTTP/1.1" 400 52

**ValueError: invalid literal for int() with base 10: 'Does Not Exist'** because the scan ID is invalid. 

To Reproduce Steps to reproduce the behavior:

  1. Use the owasp/zap2docker-stable image.
  2. Run this command:

/zap/zap-api-scan.py -t $DAST_API_SPECIFICATION -f openapi -O $DAST_API_HOST_OVERRIDE -r $DAST_HTML_REPORT -d debug

Expected behavior I expect the active scan to generate an HTML report on my API.

StackTrace

 2020-10-06 21:10:36,948 Starting new HTTP connection (1): localhost:48271
 2020-10-06 21:10:36,953 http://localhost:48271 "GET http://zap/JSON/core/view/urls/ HTTP/1.1" 200 334
 2020-10-06 21:10:36,954 Using host override, new target: REDACTED
 2020-10-06 21:10:36,954 Number of Imported URLs: 5
 2020-10-06 21:10:36,954 Import warnings: []
 2020-10-06 21:10:36,954 Normalised target from REDACTED to REDACTED
 2020-10-06 21:10:36,955 Trigger hook: zap_active_scan, args: 3
 2020-10-06 21:10:36,955 Active Scan REDACTED / with policy API-Minimal
 2020-10-06 21:10:36,957 Starting new HTTP connection (1): localhost:48271
 2020-10-06 21:10:36,971 http://localhost:48271 "GET http://zap/JSON/ascan/action/scan/?url=REDACTED&apikey=&recurse=True&scanPolicyName=API-Minimal HTTP/1.1" 400 67
 2020-10-06 21:10:41,980 Starting new HTTP connection (1): localhost:48271
 2020-10-06 21:10:41,984 http://localhost:48271 "GET http://zap/JSON/ascan/view/status/?scanId=URL+Not+Found+in+the+Scan+Tree HTTP/1.1" 400 52
 2020-10-06 21:10:41,986 Unexpected error: <type 'exceptions.ValueError'>
 Traceback (most recent call last):
   File "/zap/zap-api-scan.py", line 425, in main
     zap_active_scan(zap, target, scan_policy)
   File "/zap/zap_common.py", line 84, in _wrap
     return_data = func(*args_list, **kwargs)
   File "/zap/zap_common.py", line 400, in zap_active_scan
     while(int(zap.ascan.status(ascan_scan_id)) < 100):
 ValueError: invalid literal for int() with base 10: 'Does Not Exist'
 ERROR <type 'exceptions.ValueError'>
 2020-10-06 21:10:41,987 Failed to find zap_log /zap/zap.out
 2020-10-06 21:10:41,987 Trigger hook: pre_exit, args: 3

Software versions

  • ZAP: owasp/zap2docker-stable

Errors from the zap.log file

 2020-10-06 21:10:41,987 **Failed to find zap_log /zap/zap.out**
 2020-10-06 21:10:41,987 Trigger hook: pre_exit, args: 3

I would love to include the zap.out file to help with debugging but it says that it doesn’t exist.

Additional context The integration with Gitlab isn’t the issue here. I have done some debugging with their version of Zap and they are having similar issues.

Would you like to help fix this issue? If I can, I would be happy to contribute code but I’m not familiar with the internals of the active scan for APIs.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
thc202commented, Apr 20, 2022

It’s not necessary to override the host, simply importing an API that points to other host is enough.

0reactions
thc202commented, Apr 24, 2022

That’s a known issue #5510.

Read more comments on GitHub >

github_iconTop Results From Across the Web

URL not found in scan tree · Issue #3036 - GitHub
That error means that the URL provided to the active scan is not known by ZAP (i.e. it was not found in the...
Read more >
URL Not Found in the Scan Tree - Google Groups
Hi all, I'm a zap newbie and am encountering this message when trying to start an active scan using the REST API: "URL...
Read more >
ZAP - API Scan
The ZAP API scan is a script that is available in the ZAP Docker images. It is tuned for performing scans against APIs...
Read more >
ZAP CLI url_not_found error when running an authenticated ...
Make sure the URL is in the site tree by using the open-url or scanner commands before running an active scan.
Read more >
Automating Web Application Security Testing Using OWASP ...
Open Web Application Security Project (OWASP) is a worldwide not- ... The ZAP Baseline scan is a script that is available in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found