Use the Platform object for cross-platform TTPs
mainTTPForge provides a Platform struct that allows you to write platform-agnostic TTPs. You can access the current execution environment using:
.Platform.OS: The operating system (e.g.,windows,linux,darwin)..Platform.Arch: The architecture of the platform.
Example of platform-specific commands and dynamic file naming:
steps:
- name: hello_world
inline: |
{{ if eq .Platform.OS "windows" }}
Write-Host "Hello Windows!"
{{ else if eq .Platform.OS "linux" }}
echo "Hello Linux!"
{{ else if eq .Platform.OS "darwin" }}
echo "Hello macOS!"
{{ end }}
- name: download_ttpforge
fetch_uri: https://github.com/facebookincubator/TTPForge/releases/
download/v1.2.3/TTPForge_1.2.3_{{ .Platform.OS }}_{{ .Platform.Arch }}.tar.gz
location: ttpforge.tar.gzrequirements:
platforms:
- os: linux
- os: darwin
- os: windows
steps:
- name: hello_world
inline: |
{{ if eq .Platform.OS "windows" }}
Write-Host "Hello Windows!"
{{ else if eq .Platform.OS "linux" }}
echo "Hello Linux!"
{{ else if eq .Platform.OS "darwin" }}
echo "Hello macOS!"
{{ end }}
- name: download_ttpforge
description: Downloads the platform-appropriate release of TTPForge
fetch_uri: https://github.com/facebookincubator/TTPForge/releases/
download/v1.2.3/TTPForge_1.2.3_{{ .Platform.OS }}_{{ .Platform.Arch }}.tar.gz
location: ttpforge.tar.gz