-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #204 from ninoseki/introduce-returns
refactor: introduce returns
- Loading branch information
Showing
86 changed files
with
1,746 additions
and
4,155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .clients.emailrep import EmailRep # noqa: F401 | ||
from .clients.inquest import InQuest # noqa: F401 | ||
from .clients.spamassasin import SpamAssassin # noqa: F401 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import vt | ||
|
||
from .emailrep import EmailRep # noqa: F401 | ||
from .inquest import InQuest # noqa: F401 | ||
from .spamassasin import SpamAssassin # noqa: F401 | ||
from .urlscan import UrlScan # noqa: F401 | ||
|
||
VirusTotal = vt.Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import httpx | ||
|
||
from backend import schemas | ||
|
||
|
||
class EmailRep(httpx.AsyncClient): | ||
def __init__(self) -> None: | ||
super().__init__(base_url="https://emailrep.io") | ||
|
||
async def lookup(self, email: str) -> schemas.EmailRepLookup: | ||
r = await self.get(f"/{email}") | ||
r.raise_for_status() | ||
return schemas.EmailRepLookup.model_validate(r.json()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import io | ||
|
||
import httpx | ||
from starlette.datastructures import Secret | ||
|
||
from backend import schemas | ||
|
||
|
||
class InQuest(httpx.AsyncClient): | ||
def __init__(self, api_key: Secret) -> None: | ||
super().__init__( | ||
base_url="https://labs.inquest.net", | ||
headers={"Authorization": f"Basic: {api_key}"}, | ||
) | ||
|
||
async def lookup(self, sha256: str) -> schemas.InQuestLookup: | ||
r = await self.get("/api/dfi/details", params={"sha256": sha256}) | ||
r.raise_for_status() | ||
return schemas.InQuestLookup.model_validate(r.json()) | ||
|
||
async def submit(self, f: io.BytesIO) -> schemas.SubmissionResult: | ||
r = await self.post("/api/dfi/upload", files={"file": f}) | ||
r.raise_for_status() | ||
data = r.json()["data"] | ||
return schemas.SubmissionResult( | ||
reference_url=f"https://labs.inquest.net/dfi/sha256/{data}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from urllib.parse import urlparse | ||
|
||
import httpx | ||
from starlette.datastructures import Secret | ||
|
||
from backend import schemas | ||
|
||
|
||
class UrlScan(httpx.AsyncClient): | ||
def __init__(self, api_key: Secret) -> None: | ||
super().__init__( | ||
base_url="https://urlscan.io", headers={"api-key": str(api_key)} | ||
) | ||
|
||
async def lookup( | ||
self, | ||
url: str, | ||
) -> schemas.UrlScanLookup: | ||
parsed = urlparse(url) | ||
params = { | ||
"q": f'task.url:"{url}" AND task.domain:"{parsed.hostname}" AND verdicts.malicious:true', | ||
"size": 1, | ||
} | ||
r = await self.get("/api/v1/search/", params=params) | ||
r.raise_for_status() | ||
return schemas.UrlScanLookup.model_validate(r.json()) |
Empty file.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.