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

TenableSC.scan_instances.import_scan does not fail clearly #722

Open
sjr0228 opened this issue Sep 19, 2023 · 0 comments
Open

TenableSC.scan_instances.import_scan does not fail clearly #722

sjr0228 opened this issue Sep 19, 2023 · 0 comments
Labels
backlog Issue Backlog bug This is a bug with the pyTenable library Tenable.sc Tenable.sc Package

Comments

@sjr0228
Copy link

sjr0228 commented Sep 19, 2023

Description

Calling sc.scan_instances.import_scan with str('filename') returns an empty string.
It appears that if the argument fileobj is a plain str instead of _io.TextIOWrapper than the string is simply added as the file content.

Reproduction

import json

from tenable.sc import TenableSC

keys = json.loads(open("keys.json").read())

def get_access_key():
    return keys["access_key"]

def get_secret_key():
    return keys["secret_key"]

sc = TenableSC(
    url = "https://tenablesc.localdomain",
    verify = False,
    access_key = get_access_key(),
    secret_key = get_secret_key(),
)

r = sc.scan_instances.import_scan('<file-that-does-not-exist>', 40)
assert r=='',"R is not empty"

Expected Behavior

I expected something like TypeError(f'{fileobj} is not of type <expected type>')

As defined in the Python Glossary file objects expose "a file-oriented API (with methods such as read() or write())" like the handle returned from calling open(). Since str does not implement read() or write() I argue that this function should raise TypeError.

Sysinfo

  • OS: Ubuntu20
  • Architecture x86_64
  • Version 1.4.13
  • Memory 32GiB
@SteveMcGrath SteveMcGrath added bug This is a bug with the pyTenable library backlog Issue Backlog Tenable.sc Tenable.sc Package labels Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issue Backlog bug This is a bug with the pyTenable library Tenable.sc Tenable.sc Package
Projects
None yet
Development

No branches or pull requests

2 participants