mainframe.endpoints.report¶
Attributes¶
Functions¶
|
Checks if the package is valid according to our database. |
|
Coalesce inspector_urls from ReportPackageBody and Scan. |
|
|
|
Report a package to PyPI. |
Module Contents¶
- mainframe.endpoints.report._lookup_package(name: str, version: str, session: sqlalchemy.orm.Session) mainframe.models.orm.Scan [source]¶
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.
- mainframe.endpoints.report._validate_inspector_url(name: str, version: str, body_url: str | None, scan_url: str | None) str [source]¶
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.
- mainframe.endpoints.report._validate_pypi(name: str, version: str, http_client: httpx.Client)[source]¶
- mainframe.endpoints.report.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)])[source]¶
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.