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

get_results returns TypeError: Expected str or file, got '<type 'Element'>' instead #17

Open
liuyoyi opened this issue Oct 9, 2017 · 3 comments

Comments

@liuyoyi
Copy link

liuyoyi commented Oct 9, 2017

openvas_results = scanner.get_report_id(scan_id)
print openvas_results

Returns

TypeError: Expected str or file, got '<type 'Element'>' instead

Why??????

@codenside
Copy link

I dig into the code actually report_parser expecting a file or string as argument, but the get_result method giving and Element object. so I comment it out the parse part

screenshot from 2018-05-16 20-53-39

and I wrote my own function to parse the result as follow

def parse(res):
    output = []
    results = res.getchildren()

    for result in results:
        children = result.getchildren()
        obj = {}
        for child in children:
            obj[child.tag] = child.text
        output.append(obj)
    return output

I can now call it like this

parse(scanner.get_results(scan_id))

which returns a python list contains all results

I don't know how to fix the original parse function, I believe they will patch it soon ❇️

@Geniussylvain
Copy link

Hello,
I would like to know where do you write this code in the init_.py file ?

Thanks

Sylvain

@thinksabin
Copy link

thinksabin commented May 21, 2019

i'm facing same issue:

File "/Users/openvas-stuffs/lib/python2.7/site-packages/openvas_lib/ompv7.py", line 1099, in get_report_xml
raise TypeError("Expected string, got %r instead" % type(report_id))
TypeError: Expected string, got <type 'NoneType'> instead

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

4 participants