Skip to content

Commit

Permalink
Remove email
Browse files Browse the repository at this point in the history
Remove the emailing feature, as it's now deprecated. All
reports must now go through the Observations API
  • Loading branch information
Robin5605 committed May 11, 2024
1 parent ea05813 commit a6f8a6f
Show file tree
Hide file tree
Showing 6 changed files with 329 additions and 1,091 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,
)
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 a6f8a6f

Please sign in to comment.