Skip to content

Commit

Permalink
Merge pull request #2 from ninoseki/refactoring
Browse files Browse the repository at this point in the history
fix: fix codefactor warnings
  • Loading branch information
ninoseki committed Apr 5, 2020
2 parents da11d9d + 1624959 commit 5a5b8ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
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

0 comments on commit 5a5b8ca

Please sign in to comment.