<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="https://swingletree-oss.github.io/swingletree/feed.xml" rel="self" type="application/atom+xml" /><link href="https://swingletree-oss.github.io/swingletree/" rel="alternate" type="text/html" hreflang="en-US" /><updated>2022-08-09T16:30:19+02:00</updated><id>https://swingletree-oss.github.io/swingletree/feed.xml</id><title type="html">Swingletree</title><subtitle>Swingletree is a GitHub App enabling you to integrate and observe the results of your CI/CD pipeline tools</subtitle><entry><title type="html">Automated OWASP Zap Security Scans</title><link href="https://swingletree-oss.github.io/swingletree/blog/2020/06/24/zap/" rel="alternate" type="text/html" title="Automated OWASP Zap Security Scans" /><published>2020-06-24T00:00:00+02:00</published><updated>2020-06-24T00:00:00+02:00</updated><id>https://swingletree-oss.github.io/swingletree/blog/2020/06/24/zap</id><content type="html" xml:base="https://swingletree-oss.github.io/swingletree/blog/2020/06/24/zap/">&lt;p&gt;&lt;a href=&quot;https://owasp.org/www-project-zap/&quot;&gt;OWASP Zap&lt;/a&gt; (aka Zed Attack Proxy) is a security scanner. Reports can be consumed by &lt;a href=&quot;https://github.com/swingletree-oss/plugin-zap&quot;&gt;plugin-zap&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For our CI purposes we will use a prepackaged &lt;a href=&quot;https://www.zaproxy.org/docs/docker/about/&quot;&gt;OWASP Zap docker container&lt;/a&gt; in
&lt;a href=&quot;https://www.zaproxy.org/docs/docker/baseline-scan/&quot;&gt;Baseline Scan&lt;/a&gt;-mode. In addition to the baseline scans, production and staging systems are scanned in full-mode on a schedule.&lt;/p&gt;

&lt;h3 id=&quot;fast-ci-responses&quot;&gt;Fast CI responses&lt;/h3&gt;

&lt;p&gt;Developers require fast responses for their builds. Therefore full OWASP Zap scans are not an option for branch or
Pull-Requests builds, since they take 30 minutes upwards depending on the complexity of your application.
Nonetheless it is a very good idea to perform small scans in your CI Pipeline to prevent “smaller” security issues
popping up in a later stage of your deployment pipeline, causing unplanned developer workloads.&lt;/p&gt;

&lt;p&gt;For this purpose OWASP Zap comes with a baseline scan mode, which is a timeboxed passive scan intended for use in CI/CD pipelines.&lt;/p&gt;

&lt;h3 id=&quot;anatomy-of-a-scan-performed-by-ci&quot;&gt;Anatomy of a scan performed by CI&lt;/h3&gt;

&lt;p&gt;The scan is performed at the end of the build process. Should you package your application inside an image run OWASP Zap against an instance
of your application image.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;CI launches the application. This instance is used as a target for the baseline scan.&lt;/li&gt;
  &lt;li&gt;CI starts the OWASP Zap container&lt;/li&gt;
  &lt;li&gt;Zap probes the application in baseline scan mode&lt;/li&gt;
  &lt;li&gt;Zap writes a report to a volume mount and exits&lt;/li&gt;
  &lt;li&gt;CI sends the report using Yoke CLI to Swingletree for further processing&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;mermaid&quot;&gt;
sequenceDiagram
  autoNumber
  participant app as Application instance
  participant ci as CI
  participant swingletree as Swingletree

  ci-&amp;gt;&amp;gt;app: start
  ci-&amp;gt;&amp;gt;ci: start Zap container
  rect rgba(0, 0, 0, .1)
  activate ci
  ci-&amp;gt;&amp;gt;app: zap probes
  ci-&amp;gt;&amp;gt;ci: write report to volume
  end
  deactivate ci
  ci-&amp;gt;&amp;gt;swingletree: send report using yoke
&lt;/div&gt;

&lt;h3 id=&quot;configuring-a-owasp-zap-scan&quot;&gt;Configuring a OWASP Zap scan&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;Some CI tools like Jenkins also offer &lt;a href=&quot;https://plugins.jenkins.io/zap/&quot;&gt;plugins&lt;/a&gt; to handle and orchestrate OWASP Zap scans&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A Baseline scan can be started and configured with a set of options passed to the Python script &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zap-baseline.py&lt;/code&gt; inside the OWASP Zap container.
This script is configurable via command-line options:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Usage: zap-baseline.py -t &amp;lt;target&amp;gt; [options]
    -t target         target URL including the protocol, eg https://www.example.com
Options:
    -h                print this help message
    -c config_file    config file to use to INFO, IGNORE or FAIL warnings
    -u config_url     URL of config file to use to INFO, IGNORE or FAIL warnings
    -g gen_file       generate default config file (all rules set to WARN)
    -m mins           the number of minutes to spider for (default 1)
    -r report_html    file to write the full ZAP HTML report
    -w report_md      file to write the full ZAP Wiki (Markdown) report
    -x report_xml     file to write the full ZAP XML report
    -J report_json    file to write the full ZAP JSON document
    -a                include the alpha passive scan rules as well
    -d                show debug messages
    -P                specify listen port
    -D                delay in seconds to wait for passive scanning 
    -i                default rules not in the config file to INFO
    -I                do not return failure on warning
    -j                use the Ajax spider in addition to the traditional one
    -l level          minimum level to show: PASS, IGNORE, INFO, WARN or FAIL, use with -s to hide example URLs
    -n context_file   context file which will be loaded prior to spidering the target
    -p progress_file  progress file which specifies issues that are being addressed
    -s                short output format - dont show PASSes or example URLs
    -T                max time in minutes to wait for ZAP to start and the passive scan to run
    -z zap_options    ZAP command line options e.g. -z &quot;-config aaa=bbb -config ccc=ddd&quot;
    --hook            path to python file that define your custom hooks
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The following command starts a scan configured to&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;spider the target for 2 Minutes&lt;/li&gt;
  &lt;li&gt;generate a JSON-formatted report &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;report.json&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;generate a HTML-formatted report &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;report.html&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;generate and use a default zap configuration written to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gen.conf&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;docker run &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;:/zap/wrk/:rw &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; owasp/zap2docker-weekly zap-baseline.py &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; https://targeturl &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; gen.conf &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; report.html &lt;span class=&quot;nt&quot;&gt;-J&lt;/span&gt; report.json &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; 2&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;swingletree-integration&quot;&gt;Swingletree integration&lt;/h3&gt;

&lt;p&gt;A JSON report is required by the &lt;a href=&quot;https://github.com/swingletree-oss/plugin-zap&quot;&gt;Swingletree OWASP Zap Plugin&lt;/a&gt;, which annotates the results to the Commit and Pull Request.
Developers have quick access to the information through GitHub Check runs to fix the findings:&lt;/p&gt;

&lt;p&gt;&lt;img class=&quot;showcase img-thumbnail&quot; src=&quot;/swingletree/assets/images/zap-check.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;summary&quot;&gt;Summary&lt;/h3&gt;

&lt;p&gt;Baseline OWASP Zap scans can help to fix security issues as early as possible. A scan performed inside the CI pipeline helps to maintain
security und and code quality each time the code is changed.&lt;/p&gt;

&lt;p&gt;A full scan should not be replaced by baseline scans. Scheduling full scans (for example nightly) preferrably on production systems is
mandatory.&lt;/p&gt;</content><author><name>Michael Gerbig</name></author><summary type="html">OWASP Zap (aka Zed Attack Proxy) is a security scanner. Reports can be consumed by plugin-zap</summary></entry></feed>