Template Engine
Relevant source files
The following files were used as context for generating this wiki page:
The Template Engine in OWASP Nettacker is a dual-purpose system designed to manage both the declarative logic of vulnerability modules and the dynamic generation of user interfaces and reports. It utilizes YAML-based templates to define complex scanning steps, payload injections, and matching conditions, allowing for rapid module development without modifying the core Python engine.
Simultaneously, the engine handles HTML-based templating for the Web UI and reporting system. It uses a combination of server-side placeholder substitution and client-side rendering to present scan results, compare historical data, and provide interactive dashboards. This architecture ensures a separation between the scanning logic, the execution engine, and the presentation layer.
YAML Module Templates
Vulnerability and scanning modules are primarily defined as YAML templates. These templates specify metadata, execution steps, and success conditions.
Architecture and Data Flow
The YAML engine parses these files to execute sequential "steps" against a target. Each step utilizes a specific library (e.g., http) and performs actions like sending requests with dynamic payloads.
This flow shows how a YAML definition is transformed into active scan pulses.
Sources: nettacker/modules/vuln/nextjs_cve_2025_55182.yaml:1-50, nettacker/modules/vuln/wp_plugin_cve_2021_38314.yaml:1-20
Key YAML Components
| Component | Description | Example |
|---|---|---|
info | Metadata including name, author, severity, and references. | severity: 10.0 |
payloads | Defines the library and sequential execution steps. | library: http |
steps | Specific actions (method, headers, data, URL). | method: post |
response | Conditions to determine if a scan was successful. | condition_type: and |
Sources: nettacker/modules/vuln/nextjs_cve_2025_55182.yaml:1-25, nettacker/modules/vuln/wp_plugin_cve_2021_38314.yaml:15-30
Dynamic Variable Substitution
The engine supports a complex placeholder system to inject runtime data into templates. This is used for both the scanner (targeting) and the UI (rendering).
Scanner Placeholders
Templates use curly braces to denote variables that the engine must replace before execution:
{target}: The current host being scanned.{user_agent}: Random or configured browser strings.{{ports}}: Iterated port numbers from the configuration.{{schema}}: Protocol choice (e.g., http vs https).
Sources: nettacker/modules/vuln/nextjs_cve_2025_55182.yaml:65-75, nettacker/modules/vuln/wp_plugin_cve_2021_38314.yaml:25-35
UI/Report Placeholders
The Web UI and HTML reports use a different substitution syntax, often processed during the generation phase or via client-side JavaScript.
{% autoescape off %}{{variable}}{% endautoescape %}: Used inindex.htmlto inject module lists, profiles, and graph options.__data_will_locate_here__: A specific token incompare_report.htmlused by the engine to inject the final JSON result set for the comparison report.
Sources: nettacker/web/static/index.html:158-180, nettacker/web/static/report/compare_report.html:143
Reporting and UI Templating
The reporting engine translates raw scan data into formatted HTML documents using static templates.
Report Generation Process
When a scan completes, the engine loads the appropriate template (e.g., compare_report.html or the standard HTML report), substitutes placeholders with localized strings from en.yaml (or other locales), and embeds the scan results as a JSON object.
The sequence demonstrates the assembly of a final report from raw data and static assets.
Sources: nettacker/config.py:173-177, nettacker/web/static/report/compare_report.html:143-160
Comparison Reporting
The comparison template specifically focuses on "Drift Detection." It identifies changes between two scan IDs.
- New Targets Discovered: Highlighted in yellow in the report.
- Old Targets Not Detected: Highlighted in red, indicating a service or host may have gone offline or was secured.
Sources: nettacker/web/static/report/compare_report.html:200-220, nettacker/locale/en.yaml:126-130
Localization and Configuration
The engine relies on external YAML files and centralized configuration to populate templates with localized text and default behaviors.
Localized String Mapping
The locale/ files provide a mapping between internal keys used in code and human-readable text injected into the UI/Reports.
| Key | English Value | Usage |
|---|---|---|
nettacker_report | "OWASP Nettacker Report" | Report Title |
graph_message | "This graph created by OWASP Nettacker..." | Disclaimer in HTML reports |
vulnerable | "vulnerable to {0}" | Vulnerability detection status |
Sources: nettacker/locale/en.yaml:94-110, nettacker/locale/ar.yaml:1-50
Template Configuration
Default settings for the template and reporting engine are managed in config.py.
# Default report filename template using date/time and random tokens
report_path_filename = "{results_path}/results_{date_time}_{random_chars}.html".format(
results_path=PathConfig.results_dir,
date_time=now(format="%Y_%m_%d_%H_%M_%S"),
random_chars=generate_random_token(10),
)
Sources: nettacker/config.py:173-177
Summary
The Template Engine is a core component that abstracts the complexity of network interactions (via YAML modules) and data presentation (via HTML/JS reports). By using declarative templates, it enables users to extend the framework's capabilities without deep Python knowledge, while the reporting system provides consistent, localized, and actionable security insights through dynamic data injection.