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

Fix various CodeQL alerts #1104

Merged
merged 5 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gvm/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def _ssh_authentication_input_loop(
save = input()
break
elif add == "no":
return sys.exit(
sys.exit(
"User denied key. Host key verification failed."
)
else:
Expand Down
2 changes: 1 addition & 1 deletion gvm/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(
*,
function: Optional[str] = None,
):
# pylint: disable=super-init-not-called
super().__init__(None)
self.argument = argument
self.function = function
self.arg_type = arg_type
Expand Down
2 changes: 1 addition & 1 deletion gvm/protocols/gmpv208/entities/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def create_filter(
)

cmd = XmlCommand("create_filter")
_xmlname = cmd.add_element("name", name)
cmd.add_element("name", name)

if comment:
cmd.add_element("comment", comment)
Expand Down
4 changes: 2 additions & 2 deletions gvm/protocols/gmpv208/entities/tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def clone_ticket(self, ticket_id: str) -> Any:

cmd = XmlCommand("create_ticket")

_copy = cmd.add_element("copy", ticket_id)
cmd.add_element("copy", ticket_id)

return self._send_xml_command(cmd)

Expand Down Expand Up @@ -114,7 +114,7 @@ def create_ticket(
_user = _assigned.add_element("user")
_user.set_attribute("id", assigned_to_user_id)

_note = cmd.add_element("open_note", note)
cmd.add_element("open_note", note)

if comment:
cmd.add_element("comment", comment)
Expand Down
8 changes: 3 additions & 5 deletions gvm/protocols/ospv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def create_vt_selection_element(_xmlvtselection, vt_selection):
_xmlvt.add_element("vt_value", value, attrs={"id": key})
elif vt_id == "vt_groups" and isinstance(vt_values, list):
for group in vt_values:
_xmlvt = _xmlvtselection.add_element(
_xmlvtselection.add_element(
"vt_group", attrs={"filter": group}
)
else:
Expand Down Expand Up @@ -252,9 +252,8 @@ def start_scan(
_xmltarget.add_element("hosts", hosts)
_xmltarget.add_element("ports", ports)
if credentials:
_xmlcredentials = _xmltarget.add_element("credentials")
_xmlcredentials = create_credentials_element(
_xmlcredentials, credentials
_xmltarget.add_element("credentials"), credentials
)
# Check target as attribute for legacy mode compatibility. Deprecated.
elif target:
Expand All @@ -267,9 +266,8 @@ def start_scan(
)

if vt_selection:
_xmlvtselection = cmd.add_element("vt_selection")
_xmlvtselection = create_vt_selection_element(
_xmlvtselection, vt_selection
cmd.add_element("vt_selection"), vt_selection
)

return self._send_xml_command(cmd)
Expand Down
3 changes: 3 additions & 0 deletions gvm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@
except KeyError:
print(logger)
logger.error("Not received an status code within the response.")
return False
except etree.Error as e:
logger.error("etree.XML(xml): %s", e)
return False

return False
Fixed Show fixed Hide fixed
timopollmeier marked this conversation as resolved.
Show resolved Hide resolved


def to_dotted_types_dict(types: List) -> TypesDict:
"""Create a dictionary accessible via dot notation"""
Expand Down
Loading