Template Syntax
Standard Variables: {{Variable}}
Double curly braces for standard variable interpolation:
Foreach Variables: [[variable]]
Double square brackets for foreach loop variables:
[[]] syntax prevents conflicts between loop variables and template variables.
Built-in Variables
| Variable | Description | Example Value |
|---|---|---|
{{Target}} | Current scan target | example.com |
{{TargetSpace}} | Sanitized target (filesystem safe) | example_com |
{{Output}} | Workspace output directory | /home/user/osmedeus-base/workspaces/example.com |
{{BaseFolder}} | Osmedeus installation directory | /home/user/osmedeus-base |
{{Binaries}} | Path to tool binaries | /home/user/osmedeus-base/binaries |
{{Data}} | Path to data files | /home/user/osmedeus-base/data |
{{Workspaces}} | Path to workspaces directory | /home/user/osmedeus-base/workspaces |
{{threads}} | Thread count (based on tactic) | 50 |
{{baseThreads}} | Base thread count | 25 |
{{TaskID}} | Unique task identifier | abc123 |
{{Today}} | Current date (YYYY-MM-DD) | 2024-01-15 |
{{TimeStamp}} | Unix timestamp | 1705312000 |
{{RandomString}} | Random 8-character string | xK9mPq2r |
Variable Resolution
Variables are resolved in this order:- Exports - Values from previous step exports
- Parameters - User-provided params (
-p key=value) - Built-in Variables - System-provided values
- Environment Variables - From shell environment
Parameters
Defining Parameters
Passing Parameters
CLI:Using Parameters
Generator Functions
Use generator functions in parameter defaults:| Function | Description | Example |
|---|---|---|
uuid() | Generate UUID v4 | a1b2c3d4-... |
currentDate() | Current date (YYYY-MM-DD) | 2024-01-15 |
currentDate(format) | Formatted date | currentDate("02-Jan-2006") |
currentTimestamp() | Unix timestamp | 1705312000 |
getEnvVar(key) | Environment variable | getEnvVar("HOME") |
getEnvVar(key, default) | With default | getEnvVar("API_KEY", "none") |
randomInt(min, max) | Random integer | randomInt(1, 100) |
randomString(len) | Random string | randomString(8) |
concat(a, b, ...) | Concatenate strings | concat("a", "b") |
toLower(s) | Lowercase | toLower("ABC") → abc |
toUpper(s) | Uppercase | toUpper("abc") → ABC |
trim(s) | Trim whitespace | trim(" a ") → a |
replace(s, old, new) | Replace string | replace("a.b", ".", "_") |
split(s, sep) | Split string | split("a,b", ",") |
join(arr, sep) | Join array | join(["a","b"], "-") |
execCmd(cmd) | Execute command | execCmd("whoami") |
Template Rendering
Templates are rendered at different stages:Step Execution Time
Most fields are rendered just before step execution:Foreach Iteration Time
Loop variables are rendered during each iteration:Conditional Templates
Use templates in conditions:Nested Variables
Variables can reference other variables:{{output_dir}}resolves to{{Output}}/scans{{Output}}resolves to workspace path- Final:
/home/user/.../workspaces/example.com/scans
Best Practices
-
Quote paths with spaces
-
Use descriptive parameter names
-
Provide defaults when possible
-
Document parameters
-
Use built-in paths
Next Steps
- Variables - Exports and propagation
- Step Types - Using templates in steps
- Functions Reference - Built-in functions