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: fix codefactor warnings #2

Merged
merged 1 commit into from
Apr 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 15 additions & 14 deletions iocingestor/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ def _match_expression(self, pattern: str):
for condition in conditions:
if condition.lstrip(NOT) not in URL.__dict__:
raise ValueError("not a condition expression")
else:
result = URL.__dict__[condition.lstrip(NOT)](self)
if condition.startswith(NOT) and result:
return False
elif not condition.startswith(NOT) and not result:
return False

result = URL.__dict__[condition.lstrip(NOT)](self)
if condition.startswith(NOT) and result:
return False
if not condition.startswith(NOT) and not result:
return False

return True

def match(self, pattern: str):
Expand Down Expand Up @@ -246,10 +247,10 @@ def ipaddress(self):
version = self.version
if version == 4:
return ipaddress.IPv4Address(self._stringify())
elif version == 6:
if version == 6:
return ipaddress.IPv6Address(self._stringify())
else:
raise ValueError("Invalid IP address '{ip}'".format(ip=self.artifact))

raise ValueError("Invalid IP address '{ip}'".format(ip=self.artifact))


class Domain(Artifact):
Expand Down Expand Up @@ -295,14 +296,14 @@ def hash_type(self):
"""Return the hash type as a string, or None."""
if len(self.artifact) == 32:
return self.MD5
elif len(self.artifact) == 40:
if len(self.artifact) == 40:
return self.SHA1
elif len(self.artifact) == 64:
if len(self.artifact) == 64:
return self.SHA256
elif len(self.artifact) == 128:
if len(self.artifact) == 128:
return self.SHA512
else:
return None

return None


class Task(Artifact):
Expand Down
7 changes: 3 additions & 4 deletions iocingestor/extras/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def list_view(table):
if table == "index":
return tables

elif table and table in tables:
if table and table in tables:
cursor.execute(f"SELECT * FROM {table}")

data = []
Expand All @@ -95,11 +95,10 @@ def list_view(table):

return data

elif table:
if table:
return f"No table {table}"

else:
return tables
return tables


@hug.get("/{table}", output=hug.output_format.html)
Expand Down