Some updates on this, I've tried exporting a context that already has authentication configured from the Authentication Tester in the ZAP Desktop UI and linking that to my ZAP full scan YAML GitHub Actions file:
cmd_options: '-a -d -m "1" -U "test123" -n /zap/wrk/Authentication.context'
Authentication.context file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configuration>
<context>
<name>Authentication Test</name>
<desc/>
<inscope>true</inscope>
<incregexes>
https://google-gruyere.appspot.com/359590344817771210252875530455144199549/.*</incregexes>
<tech>
<include>Db</include>
<include>Db.CouchDB</include>
<include>Db.Firebird</include>
<include>Db.HypersonicSQL</include>
<include>Db.IBM DB2</include>
<include>Db.Microsoft Access</include>
<include>Db.Microsoft SQL Server</include>
<include>Db.MongoDB</include>
<include>Db.MySQL</include>
<include>Db.Oracle</include>
<include>Db.PostgreSQL</include>
<include>Db.SAP MaxDB</include>
<include>Db.SQLite</include>
<include>Db.Sybase</include>
<include>Language</include>
<include>Language.ASP</include>
<include>Language.C</include>
<include>Language.JSP/Servlet</include>
<include>Language.Java</include>
<include>Language.Java.Spring</include>
<include>Language.JavaScript</include>
<include>Language.PHP</include>
<include>Language.Python</include>
<include>Language.Ruby</include>
<include>Language.XML</include>
<include>OS</include>
<include>OS.Linux</include>
<include>OS.MacOS</include>
<include>OS.Windows</include>
<include>SCM</include>
<include>SCM.Git</include>
<include>SCM.SVN</include>
<include>WS</include>
<include>WS.Apache</include>
<include>WS.IIS</include>
<include>WS.Tomcat</include>
</tech>
<urlparser>
<class>org.zaproxy.zap.model.StandardParameterParser</class>
<config>{"kvps":"&","kvs":"=","struct":[]}</config>
</urlparser>
<postparser>
<class>org.zaproxy.zap.model.StandardParameterParser</class>
<config>{"kvps":"&","kvs":"=","struct":[]}</config>
</postparser>
<authentication>
<type>6</type>
<strategy>POLL_URL</strategy>
<pollurl>
https://google-gruyere.appspot.com/359590344817771210252875530455144199549/login</pollurl>
<polldata/>
<pollheaders/>
<pollfreq>2</pollfreq>
<pollunits>REQUESTS</pollunits>
<loggedin>\Qtest123\E</loggedin>
<loggedout>\bSign\s*In\b</loggedout>
<browser>
<loginpageurl>
https://google-gruyere.appspot.com/359590344817771210252875530455144199549/login</loginpageurl>
<browserid>firefox</browserid>
<loginpagewait>2</loginpagewait>
</browser>
</authentication>
<users>
<user>0;true;dGVzdDEyMw==;6;dGVzdDEyMw==~dGVzdDEyMw==~</user>
</users>
<forceduser>0</forceduser>
<session>
<type>3</type>
<headers>Q29va2ll:R1JVWUVSRT17JWNvb2tpZTpHUlVZRVJFJX0=</headers>
</session>
<authorization>
<type>0</type>
<basic>
<header/>
<body/>
<logic>AND</logic>
<code>-1</code>
</basic>
</authorization>
</context>
</configuration>
Firstly, I have manually changed <incregexes>
https://google-gruyere.appspot.com/359590344817771210252875530455144199549.*</incregexes> to be the URL that it is (target URL) as I've realised that when its the one that ZAP gave from the Authentication Tester (which is
https://google-gruyere.appspot.com.*), ZAP will automatically make alot of other instances of the Gruyere webapp and result in scans taking super long + alot of duplicate results from scanning/attacking multiple instances of the same webapp. (For context, Google Gruyere allows users to create their own instance to test security on.)
Secondly, i'm now receiving errors by changing the incregexes (include in context) and it says this in the debug message when trying to run the workflow.
25135 [ZAP-IO-Server-1-2] WARN org.zaproxy.zap.extension.api.API - Bad request to API endpoint [/JSON/ascan/action/scanAsUser/] from [0:0:0:0:0:0:0:1]:
Some other logs I found interesting?
Trigger hook: zap_spider, args: 2
Starting new HTTP connection (1): localhost:49360
Starting new HTTP connection (1): localhost:49360
How come these logs are showing that ZAP is spidering/scanning
https://google-gruyere.appspot.com/, when I have clearly declared in my full scan YAML file above that the target is a different URL?
(target: '
https://google-gruyere.appspot.com/359590344817771210252875530455144199549/')
Any guidance/help would be greatly appreciated (and much needed as I am completely clueless how to fix this).
Thanks,
Luca