Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 1.34 KB

create_file.md

File metadata and controls

35 lines (26 loc) · 1.34 KB

TTPForge Actions: create_file

The create_file action can be used to drop files on disk without the need to loudly invoke a shell and use cat or echo. Check out the TTP below to see how it works:

---
name: create_file_basic
description: |
This TTP shows you how to use the create_file action type
to create files on disk
steps:
- name: create-first-tmp-file
create_file: /tmp/ttpforge_create_file_{{randAlphaNum 10}}
contents: |
Using create_file is a convenient to simulate TTPs that
drop files to disk. We can control the permission mode
with which the file is created using `mode:`
mode: 0600
cleanup: default
- name: create-second-tmp-file
create_file: /tmp/ttpforge_create_file_overwritable
contents: |
This step uses `overwrite: true` which means
that even if the target file already exists, it will be overwritten with these
contents
overwrite: true
cleanup: default

You can experiment with the above TTP by installing the examples TTP repository (skip this if ttpforge list repos shows that the examples repo is already installed):

ttpforge install repo https://github.com/facebookincubator/TTPForge --name examples

and then running the below command:

ttpforge run examples//actions/create-file/basic.yaml

Fields

You can specify the following YAML fields for the create_file: action:

  • create_file: (type: string) the path to the file you want to create.
  • contents: (type: string) the contents that you want placed in the new file.
  • overwrite: (type: bool) whether the file should be overwritten if it already exists.
  • mode: the octal permission mode (chmod style) for the new file.
  • cleanup: you can set this to default in order to automatically cleanup the created file, or define a custom cleanup action.