smicallef / spiderfoot

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
http://www.spiderfoot.net
MIT License
13.27k stars 2.29k forks source link

sfcli: -e argument: AttributeError: 'str' object has no attribute 'close' #1820

Open bcoles opened 1 year ago

bcoles commented 1 year ago

The -e argument clobbers stdin with file contents as a string:

https://github.com/smicallef/spiderfoot/blob/e84db07ffa681f1acd9445a2ffdc9f28ffe0330a/sfcli.py#L1368-L1379

Where as Python Cmd expects _io.TextIOWrapper not str:

# ./sfcli.py -e /tmp/asdf
Traceback (most recent call last):
  File "/root/Desktop/spiderfoot/./sfcli.py", line 1422, in <module>
    s.cmdloop()
  File "/usr/lib/python3.11/cmd.py", line 132, in cmdloop
    line = self.stdin.readline()
           ^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'readline'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/Desktop/spiderfoot/./sfcli.py", line 1424, in <module>
    cin.close()
    ^^^^^^^^^
AttributeError: 'str' object has no attribute 'close'
KDreynolds commented 9 months ago

PR #1826 has been reviewed and is ready to merge to address this issue.