示例#1
0
#!/usr/bin/env python3

import random

from pytm.pytm import TM, Actor, Boundary, Dataflow, Datastore, Lambda, Server

# make sure generated diagrams do not change, makes sense if they're commited
random.seed(0)


tm = TM("my test tm")
tm.description = "This is a sample threat model of a very simple system - a web-based comment system. The user enters comments and these are added to a database and displayed back to the user. The thought is that it is, though simple, a complete enough example to express meaningful threats."
tm.isOrdered = True
tm.mergeResponses = True

internet = Boundary("Internet")
server_db = Boundary("Server/DB")
vpc = Boundary("AWS VPC")

user = Actor("User")
user.inBoundary = internet

web = Server("Web Server")
web.OS = "Ubuntu"
web.isHardened = True
web.sanitizesInput = False
web.encodesOutput = True
web.authorizesSource = False

db = Datastore("SQL Database")
db.OS = "CentOS"
#!/usr/bin/env python3

from pytm.pytm import TM, Server, Datastore, Dataflow, Boundary, Actor, Lambda

tm = TM("my test tm")
tm.description = "another test tm"

Web = Boundary("Internal Web")
external_web = Boundary("External Web")

user = Actor("App-y-Tenant")

app = Server("Mobile App")

buy_api = Server("Buy<br/>API-y")
buy_api.inBoundary = Web

rent_api = Server("Rent<br/>API-y")
rent_api.inBoundary = Web

alert_api = Server("Alert<br/>API-y")
alert_api.inBoundary = Web

cloud = Server("Phone Provider Cloud")
cloud.inBoundary = external_web
alert_api_to_cloud = Dataflow(alert_api, cloud, "push")
cloud_to_app = Dataflow(cloud, app, " ")

db_b = Datastore("Oracle Table B")
db_b.inBoundary = Web
buy_api_to_db = Dataflow(buy_api, db_b, " ")
示例#3
0
文件: tm.py 项目: luisfalconeri/pytm
#!/usr/bin/env python3

# TM, Element, Server, ExternalEntity, Datastore, Actor, Process, SetOfProcesses, Dataflow, Boundary and Lambda.

from pytm.pytm import TM, Server, Datastore, Dataflow, Boundary, Actor, Lambda, Element, Process, ExternalEntity, Classification

tm = TM("LetterApp flow diagram")
tm.description = """LetterApp is a cloud-based and machine learning-powered document-management 
                    and workflow system which allow users to upload documents and access 
                    them from a Web client and a mobile client, as well as programtically 
                    through a group of Restful API's. Besides making the documents avaiable 
                    across devices, it also allows for flow management - users can group, tag, 
                    and track activities related to each document. Computer vision helps users
                    with automatic tagging and entity extraction. Users can also send letters, 
                    faxes na messages straight from the app. Since the nature of the data stored 
                    is sensitve, security is of heightened importance for the app's development."""

tm.isOrdered = True
tm.mergeResponses = True
tm

#Actors
#TODO add mobile client?  programtic user? anonymous user?
#External Entities - out of control
#Sendgrid

#External Entities / Processes / Actors
web_user = ExternalEntity('Web User')
administrator = ExternalEntity('Administrator')
mobile_client = ExternalEntity("Mobile Client")
direct_api = ExternalEntity("API programatic access")
from pytm.pytm import TM, Boundary, Server, Actor, Datastore, Dataflow, SetOfProcesses

tm = TM("App-y-ness")
tm.description = "This is a sample threat model for the Threat Modeling Workshop."

internet = Boundary("Internet")

user = Actor("App-y-tenant")

app = Server("Mobile App")

buyApi = Server("Buy<br/>API-y")
buyApi.inBoundary = internet

rentApi = Server("Rent<br/>API-y")
rentApi.inBoundary = internet

market = SetOfProcesses("Market-y")
market.inBoundary = internet

alertApi = Server("Alert<br/>API-y")
alertApi.inBoundary = internet

authApi = Server("Auth<br/>API-y")
authApi.inBoundary = internet

allAuth = Server("All Auth")
allAuth.inBoundary = internet

phoneCloud = Server("Phone<br/>Provider<br/>Cloud")
示例#5
0
# !/usr/bin/env python3

from pytm.pytm import TM, Server, Datastore, Dataflow, Boundary, Actor, Lambda, Process

tm = TM("Kubernetes Threat Model")
tm.description = "a deep-dive threat model of Kubernetes"

# Boundaries

inet = Boundary("Internet")
mcdata = Boundary("Master Control Data")
apisrv = Boundary("API Server")
mcomps = Boundary("Master Control Components")
worker = Boundary("Worker")
contain = Boundary("Container")

# Actors

miu = Actor("Malicious Internal User")
ia = Actor("Internal Attacker")
ea = Actor("External Actor")
admin = Actor("Administrator")
dev = Actor("Developer")
eu = Actor("End User")

# Server & OS Components

etcd = Datastore("N-ary etcd servers")
apiserver = Server("kube-apiserver")
kubelet = Server("kubelet")
kubeproxy = Server("kube-proxy")
示例#6
0
# !/usr/bin/env python3

from pytm.pytm import TM, Server, Datastore, Dataflow, Boundary, Actor, ExternalEntity, Process

tm = TM("Basic threat model")
tm.description = "DFD for storytelling exercise"

# Define boundaries
User = Boundary("User")
API = Boundary("Internet facing")
DB = Boundary("Database")

test = ExternalEntity("test")
test.implementsNonce = False

# Define actors
user = Actor("User")
user.inBoundary = User

# Define components
api_search = Server("api_search")
api_search.inBoundary = API
api_search.inScope = True
api_search.providesConfidentiality = True

api_reservation = Server("api_reservation")
api_reservation.inBoundary = API
api_reservation.inScope = True

api_rating = Server("api_rating")
api_rating.inBoundary = API
示例#7
0
from pytm.pytm import TM, Boundary, Server, Actor, Datastore, Dataflow, SetOfProcesses

tm = TM("Generic CMS example")
tm.description = "This is a sample threat model for the Threat Model Cookbook."

internet = Boundary("Internet")

user = Actor("Generic/Privilege User")

webserver = Server("Web Server")
webserver.inBoundary = internet

user_to_webserver = Dataflow(user, webserver, "HTTPS")

db = Datastore("db")
db.inBoundary = internet
db_to_webserver = Dataflow(webserver, db, " ")

adminuser = Actor(" admin ")
admin_to_webserver = Dataflow(adminuser, db,
                              "unsecure<br/>mysql<br/>connection")

cdn = SetOfProcesses("CDN network")
user_to_cdn = Dataflow(user, cdn, "HTTP")
webserver_to_cdn = Dataflow(webserver, cdn, "Push to Bucket")

tm.process()