Thank you for your advice, Simon. Using inline scripts really useful. I am generating a report file to understand if the variable is working or not:))
---
env:
contexts:
- name: "${ZAP_PROJECT_NAME}-${ZAP_PROJECT_COUNTRY}-${ZAP_PROJECT_ENV}"
urls:
- "
http://invoice.test.com"
includePaths:
- "http[s]?://
invoice.test.com/.*"
excludePaths: []
authentication:
parameters: {}
verification:
method: "response"
pollFrequency: 60
pollUnits: "requests"
sessionManagement:
method: "cookie"
parameters: {}
technology:
exclude: []
users:
- credentials:
password: "1234"
username: "admin"
parameters:
failOnError: false
failOnWarning: false
progressToStdout: true
vars:
PROJECT_NAME: ${ZAP_PROJECT_NAME}
PROJECT_COUNTRY: ${ZAP_PROJECT_COUNTRY}
PROJECT_ENV: '${ZAP_PROJECT_ENV}'
REPORT_PATH: "/zap/wrk"
SCRIPT_PATH: "/zap/wrk"
jobs:
- parameters:
action: "add"
type: "standalone"
engine: "ECMAScript : Oracle Nashorn"
name: "send_scan_start_teams_notification.js"
file: "${SCRIPT_PATH}/scripts/send_scan_start_teams_notification.js"
target: ""
inline: ""
name: "script"
type: "script"
- parameters:
action: "run"
type: "standalone"
engine: ""
name: "send_scan_start_teams_notification.js"
target: ""
inline: ""
name: "script"
type: "script"
- parameters:
action: "add"
type: "extender"
engine: "ECMAScript : Oracle Nashorn"
name: "send_alerts_found_teams_notification.js"
file: "${SCRIPT_PATH}/scripts/send_alerts_found_teams_notification.js"
target: ""
inline: ""
name: "script"
type: "script"
- parameters:
scanOnlyInScope: true
enableTags: false
disableAllRules: false
rules: []
name: "passiveScan-config"
type: "passiveScan-config"
- parameters:
context:
maxDuration: 0
maxDepth: 0
maxChildren: 0
acceptCookies: false
handleODataParametersVisited: false
handleParameters: "IGNORE_COMPLETELY"
maxParseSizeBytes: 3000000
parseComments: false
parseGit: false
parseRobotsTxt: false
parseSitemapXml: false
parseSVNEntries: false
postForm: false
processForm: false
requestWaitTime: 0
sendRefererHeader: false
userAgent: ""
tests:
- onFail: "INFO"
statistic: "automation.spider.urls.added"
site: ""
operator: ">="
value: 100
type: "stats"
name: "At least 100 URLs found"
name: "spider"
type: "spider"
- parameters: {}
name: "passiveScan-wait"
type: "passiveScan-wait"
- parameters:
template: "traditional-json"
reportDir: "${REPORT_PATH}/reports"
reportFile: "zap-report_${ZAP_PROJECT_NAME}-${ZAP_PROJECT_COUNTRY}-${ZAP_PROJECT_ENV}__{{yyyy-MM-dd}}"
reportTitle: "${ZAP_PROJECT_NAME}-${ZAP_PROJECT_COUNTRY}-${ZAP_PROJECT_ENV} - ZAP Scanning Report"
reportDescription: ""
displayReport: false
risks:
- "low"
- "medium"
- "high"
confidences:
- "low"
- "medium"
- "high"
- "confirmed"
name: "report"
type: "report"
When I am using PROJECT_NAME from the [vars] section in the [reportFile] file field, it puts exactly "${ZAP_PROJECT_NAME}" value, but not the value of the defined with -e parameter environment variable. Although, when I am using directly ${ZAP_PROJECT_NAME} environment variable it works.