Skip to content
This is the documentation for pieceofcake2/security-dast, a CakePHP 2.x plugin for pieceofcake2/cakephp. About this fork.

Configuration ​

Each setting is an option of the command, an environment variable, or a key of the settings file. The options win over the environment variables, and the environment variables over the file.

Options ​

What to Scan ​

OptionEnvironment variableDefault
--project=DIRthe current directoryThe directory of the application
--url=URLSECURITY_DAST_URLThe URL of a running application to scan, instead of the built-in web server
--webroot=DIRSECURITY_DAST_WEBROOTWWW_ROOT of the applicationThe document root of the built-in web server, relative to the project
--app-env=ENVSECURITY_DAST_APP_ENVtestAPP_ENV of the built-in web server (and of the End-to-End tests)
--exclude=LISTSECURITY_DAST_EXCLUDE.*logout.*Regular expressions (of Java) of the URLs to leave out, comma separated

How to Scan ​

OptionEnvironment variableDefault
--scan=SCANSECURITY_DAST_SCANbaselinebaseline, or full to attack the pages too (Scans)
--scan-minutes=NSECURITY_DAST_SCAN_MINUTES10The most minutes of the attacks of the full scan
--minutes=NSECURITY_DAST_MINUTES1Minutes to crawl the site; not with --end-to-end, which does not crawl
--ajax-spider=1SECURITY_DAST_AJAX_SPIDERCrawl with a browser too, for the links that JavaScript builds; not with --end-to-end
--end-to-end=COMMANDSECURITY_DAST_END_TO_ENDThe command of the End-to-End tests to scan, instead of the crawl (End-to-End Tests)
--login-url=PATHSECURITY_DAST_LOGIN_URLThe login page, a path or a URL, to scan as a user (Login)
--username=NAMESECURITY_DAST_USERNAMEThe user to log in as
--password=PASSWORDSECURITY_DAST_PASSWORDIts password; prefer the environment variable

The Result ​

OptionEnvironment variableDefault
--pdf=PATHSECURITY_DAST_PDFtmp/security-dast.pdfThe PDF report
--fail-on=RISKSECURITY_DAST_FAIL_ONhighThe lowest risk that fails: high, medium, low, info or none
--ignore=LISTSECURITY_DAST_IGNOREAlert IDs that do not fail the scan, comma separated; the report lists them (Ignoring an Alert)
--language=LANGSECURITY_REPORT_LANGUAGEenen or ja, or a language of --locale-dir
--locale-dir=DIRSECURITY_REPORT_LOCALE_DIR<language>.json files that add or replace messages
--title=TITLESECURITY_DAST_TITLEthe title of the languageThe title of the report
--project-name=NAMESECURITY_REPORT_PROJECTthe name in composer.jsonThe project under the title
--note=TEXTSECURITY_DAST_NOTEA note on the cover

ZAP and Docker ​

OptionEnvironment variableDefault
--image=IMAGESECURITY_DAST_IMAGEghcr.io/zaproxy/zaproxy:stableThe Docker image of ZAP, e.g. a fixed version ghcr.io/zaproxy/zaproxy:2.17.0
--docker=COMMANDSECURITY_DAST_DOCKERdockerThe Docker command, e.g. podman
--zap-options=OPTIONSSECURITY_DAST_ZAP_OPTIONSMore options of ZAP, separated by spaces, e.g. -config spider.maxDepth=5
--settings=FILESECURITY_SETTINGSconfig/security.php or app/Config/security.phpThe settings file

The paths of --pdf, --settings, --locale-dir and of the dir of the report are relative to the current directory, not to the project: run the command in the project, or give absolute paths. --webroot is relative to the project.

The REPORT_CHROME_BINARY and REPORT_NO_SANDBOX variables of pieceofcake2/report set the Chrome that prints the PDF.

The Settings File ​

The settings of the security checks of pieceofcake2 can be kept in the project, in config/security.php (app/Config/security.php of the legacy layout). It returns an array with a section for each check, sca, sast and dast, and a report section that they share:

php
<?php
// config/security.php
return [
    'report' => [
        'language' => 'ja',
        'dir' => 'tmp/security',
        'project' => 'Acme',
    ],
    'dast' => [
        'scan' => 'full',
        'scanMinutes' => 20,
        'failOn' => 'medium',
        'endToEnd' => 'vendor/bin/phpunit --testsuite EndToEnd',
        'loginUrl' => '/users/login',
        'username' => 'test@example.com',
        'password' => getenv('SECURITY_DAST_PASSWORD') ?: null,
        'exclude' => ['.*/users/logout.*', '.*/users/delete.*'],
        'ignore' => ['10049' => 'The public pages may be cached'],
    ],
];
  • The keys of the dast section are the options in camel case (--fail-on is failOn, --end-to-end is endToEnd), with arrays for the lists. An unknown key is an error.
  • The report section has language, localeDir, project (the project name), note and dir, the directory of the reports: this one writes tmp/security/security-dast.pdf.
  • The file is PHP: read the secrets from the environment, and commit the file.

A setting of the file is used unless the option or the environment variable is given, e.g. the baseline scan of the pull requests with the settings of the nightly full scan:

bash
SECURITY_DAST_SCAN=baseline vendor/bin/security-dast

See LICENSE for copyright and license information. Not affiliated with the Cake Software Foundation.