mainframe.endpoints.report ========================== .. py:module:: mainframe.endpoints.report Attributes ---------- .. autoapisummary:: mainframe.endpoints.report.logger mainframe.endpoints.report.router Functions --------- .. autoapisummary:: mainframe.endpoints.report._lookup_package mainframe.endpoints.report._validate_inspector_url mainframe.endpoints.report._validate_pypi mainframe.endpoints.report.report_package Module Contents --------------- .. py:data:: logger :type: structlog.stdlib.BoundLogger .. py:data:: router .. py:function:: _lookup_package(name: str, version: str, session: sqlalchemy.orm.Session) -> mainframe.models.orm.Scan Checks if the package is valid according to our database. :returns: True if the package exists in the database. :raises HTTPException: 404 Not Found if the name was not found in the database, or the specified name and version was not found in the database. 409 Conflict if another version of the same package has already been reported. .. py:function:: _validate_inspector_url(name: str, version: str, body_url: Optional[str], scan_url: Optional[str]) -> str Coalesce inspector_urls from ReportPackageBody and Scan. :returns: The inspector_url for the package. :raises HTTPException: 400 Bad Request if the inspector_url was not passed in `body` and not found in the database. .. py:function:: _validate_pypi(name: str, version: str, http_client: httpx.Client) .. py:function:: report_package(body: mainframe.models.schemas.ReportPackageBody, session: Annotated[sqlalchemy.orm.Session, Depends(get_db)], auth: Annotated[mainframe.json_web_token.AuthenticationData, Depends(validate_token)], httpx_client: Annotated[httpx.Client, Depends(get_httpx_client)]) Report a package to PyPI. There are some restrictions on what packages can be reported. They must: - exist in the database - exist on PyPI - not already be reported `inspector_url` argument is required if the package has no matched rules. If `inspector_url` argument is not provided for a package with matched rules, the Inspector URL of the file with the highest total score will be used. If `inspector_url` argument is provided for a package with matched rules, the given Inspector URL will override the default one.