Skip to content

Instantly share code, notes, and snippets.

@w0ltage
Created October 28, 2022 07:06
Show Gist options
  • Save w0ltage/6970c4d835c81ca51913e261211de071 to your computer and use it in GitHub Desktop.
Save w0ltage/6970c4d835c81ca51913e261211de071 to your computer and use it in GitHub Desktop.
Create a security plan (threat model) in markdown format by answering a questions
import sys
questions = [
"What do I want to protect? (asset)",
"Who do I want to protect it from? (threat)",
"How likely is that I will need to protect it? (adversary)",
"How bad are the consequences if I fail? (impact)",
"How much trouble are I willing to go through to prevent these consequences? (patience)"
]
def create_markdown(filename, questions):
with open(f"{filename}.md", "w") as file: # overwrite or create filename.md
for question in questions: # iterate through all the questions
print(question)
answers = [input("- ")]
while True:
if answers[-1]: # if last answer is not empty then
answers.append(input(f"- ")) # add answer to answers
else:
break # else stop asking current question
print()
file.write(f"#### {question}")
for answer in filter(None, answers): # skip empty elements in answers
file.write(f"\n- {answer}")
file.write(f"\n\n")
create_markdown(sys.argv[1], questions) # first argument = filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment