izar / pytm

A Pythonic framework for threat modeling
Other
891 stars 168 forks source link

Add missing _safeset to Data class #141

Closed mikejarrett closed 3 years ago

mikejarrett commented 3 years ago

When attempting to generate dfd, seq or report with where the datastore has the attribute isEncryptedAtRest and data has isStored attribute I receive:

ERROR: test_dfd (tests.test_pytmfunc.TestTM)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pytm/tests/test_pytmfunc.py", line 115, in test_dfd
    self.assertTrue(tm.check())
  File "/tmp/pytm/pytm/pytm.py", line 697, in check
    _apply_defaults(TM._flows, TM._data)
  File "/tmp/pytm/pytm/pytm.py", line 378, in _apply_defaults
    d._safeset("isDestEncryptedAtRest", e.sink.isEncryptedAtRest)
AttributeError: 'Data' object has no attribute '_safeset'

We're able to reproduce with this short example:

web = Server("Server")
db = Datastore("Db", isEncryptedAtRest=True)
data = Data("Data", isStored=True)
dataflow = Dataflow("Server to DB', data=[data])

I was unsure which test to extend and I am happy to move to a different one or write a new one.

This appears to be a result of https://github.com/izar/pytm/pull/127

I ran the following before committing:

make test
make format