Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bcoles opened this issue Nov 4, 2023 · 1 comment
Open

Comments

@bcoles
Copy link
Contributor

bcoles commented Nov 4, 2023

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

spiderfoot/sfcli.py

Lines 1368 to 1379 in e84db07

# Load commands from a file
if args.e:
try:
with open(args.e, 'r') as f:
cin = f.read()
except BaseException as e:
print(f"Unable to open {args.e}: ({e})")
sys.exit(-1)
else:
cin = sys.stdin
s = SpiderFootCli(stdin=cin)
s.identchars += "$"

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 pushed a commit to KDreynolds/spiderfoot that referenced this issue Dec 5, 2023
@KDreynolds
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants