izar / pytm

A Pythonic framework for threat modeling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Got an error "AttributeError: 'str' object has no attribute 'name'" when using the "--sqldump SQLDUMP".

darwin-xu opened this issue · comments

I encountered the error:

dxu@remotedev-dxu-sea:~/open-source/pytm> ./tm.py --sqldump SQLDUMP
Traceback (most recent call last):
  File "./tm.py", line 127, in <module>
    tm.process()
  File "/ifs/home/dxu/open-source/pytm/pytm/pytm.py", line 1055, in process
    self.sqlDump(result.sqldump)
  File "/ifs/home/dxu/open-source/pytm/pytm/pytm.py", line 1149, in sqlDump
    for k, v in serialize(e).items():
  File "/ifs/home/dxu/open-source/pytm/pytm/pytm.py", line 1873, in serialize
    value = [v.id if isinstance(v, Finding) else v.name for v in value]
  File "/ifs/home/dxu/open-source/pytm/pytm/pytm.py", line 1873, in <listcomp>
    value = [v.id if isinstance(v, Finding) else v.name for v in value]
AttributeError: 'str' object has no attribute 'name'

Is it a mistake on my end, or could it be a bug?

Hi,

it looks like you have an Iterable which holds a string as a value.
Without the tm.py it is difficult to see the exact problem, but the line which fails is taking a list, tuple or iterator and the values in the iterable need to be Findinds or have a name attribute.

Without an example it is difficult to see if this is a usability issue or not.