Skip to content

Commit

Permalink
Merge pull request #31 from vipyrsec/remove-email
Browse files Browse the repository at this point in the history
Remove email
  • Loading branch information
Robin5605 authored May 11, 2024
2 parents a130549 + 5bbffd5 commit 8591a5e
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 1,114 deletions.
1,291 changes: 328 additions & 963 deletions pdm.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ dependencies = [
"httpx>=0.27.0",
"pydantic-settings>=2.2.1",
"uvicorn[standard]>=0.27.1",
"azure-identity>=1.15.0",
"msgraph-sdk>=1.0.0",
"sentry-sdk[fastapi]>=1.40.6",
]
requires-python = ">=3.11"
Expand Down
29 changes: 1 addition & 28 deletions src/reporter/app.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import logging
from typing import Annotated
from fastapi import Depends, FastAPI, HTTPException
from msgraph import GraphServiceClient
from reporter.schemas import ReportPayload
from reporter.constants import Mail
from fastapi import FastAPI, HTTPException
import sentry_sdk

from reporter.constants import GIT_SHA, Sentry
from reporter.pypi_client import ObservationsAPIFailure, PyPIClientDependency
from reporter.models import Observation, ServerMetadata, EchoResponse

from reporter.dependencies import build_graph_client
from reporter.mailer import build_report_email_content, send_mail

log = logging.getLogger(__name__)

sentry_sdk.init(
Expand Down Expand Up @@ -50,23 +43,3 @@ async def report_endpoint(project_name: str, observation: Observation, pypi_clie
sentry_sdk.capture_exception(exc)
log.error(f"PyPI Observations API failed with response code {exc.response.status_code}: {exc.response.text}")
raise HTTPException(400, detail="PyPI Observations API failed")


@app.post("/report/email")
async def report_email_endpoint(
payload: ReportPayload, graph_client: Annotated[GraphServiceClient, Depends(build_graph_client)]
):
content = build_report_email_content(
name=payload.name,
version=payload.version,
inspector_url=payload.inspector_url,
rules_matched=payload.rules_matched,
additional_information=payload.additional_information,
)
await send_mail(
graph_client,
to_addresses=[payload.recipient or Mail.recipient],
bcc_addresses=[],
subject=f"Automated PyPI Malware Report: {payload.name}@{payload.version}",
content=content,
)
23 changes: 0 additions & 23 deletions src/reporter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,3 @@ class _PyPI(EnvConfig, env_prefix="pypi_"): # pyright: ignore


PyPI = _PyPI()


class _Mail(EnvConfig, env_prefix="mail_"): # pyright: ignore
"""Environment variables that are core to the app itself."""

reply_to: str = "[email protected]"
sender: str = "[email protected]"
recipient: str = "[email protected]"


Mail = _Mail()


class _Microsoft(EnvConfig, env_prefix="microsoft_"): # pyright: ignore
"""Environment variables for Microsoft."""

tenant_id: str = ""
client_id: str = ""
client_secret: str = ""
scopes: list[str] = ["https://graph.microsoft.com/.default"]


Microsoft = _Microsoft()
7 changes: 0 additions & 7 deletions src/reporter/dependencies/__init__.py

This file was deleted.

16 changes: 0 additions & 16 deletions src/reporter/dependencies/microsoft_graph_dependencies.py

This file was deleted.

75 changes: 0 additions & 75 deletions src/reporter/mailer.py

This file was deleted.

0 comments on commit 8591a5e

Please sign in to comment.