mainframe.models.schemas

Classes

ServerMetadata

Server metadata

Error

Error

Package

Model representing a package queried from the database.

PackageSpecifier

Model used to specify a package by name and version

ReportPackageBody

Model used to specify a package by name and version

ObservationKind

Create a collection of name/value pairs.

ObservationReport

Model for a report using the PyPI Observation Api

PackageScanResult

Client payload to server containing the results of a package scan

PackageScanResultFail

The client's reason as to why scanning a package failed

JobResult

Package information of a requested job.

GetRules

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

NoJob

Returned when no available jobs were found.

QueuePackageResponse

Returned after queueing a package. Contains the UUID

StatsResponse

Recent system statistics

Module Contents

class mainframe.models.schemas.ServerMetadata(/, **data: Any)[source]

Bases: pydantic.BaseModel

Server metadata

server_commit: str[source]
rules_commit: str[source]
class mainframe.models.schemas.Error(/, **data: Any)[source]

Bases: pydantic.BaseModel

Error

detail: str[source]
class mainframe.models.schemas.Package(/, **data: Any)[source]

Bases: pydantic.BaseModel

Model representing a package queried from the database.

scan_id: str[source]
name: str[source]
version: str | None[source]
status: str | None[source]
score: int | None[source]
inspector_url: str | None[source]
rules: list[str] = [][source]
download_urls: list[str] = [][source]
queued_at: datetime.datetime | None[source]
queued_by: str | None[source]
reported_at: datetime.datetime | None[source]
reported_by: str | None[source]
pending_at: datetime.datetime | None[source]
pending_by: str | None[source]
finished_at: datetime.datetime | None[source]
finished_by: str | None[source]
commit_hash: str | None[source]
classmethod from_db(scan: mainframe.models.orm.Scan)[source]
serialize_dt(dt: datetime.datetime | None, _info)[source]
class mainframe.models.schemas.PackageSpecifier(/, **data: Any)[source]

Bases: pydantic.BaseModel

Model used to specify a package by name and version

name: A str of the name of the package to be scanned version: A str of the package version to scan.

model_config[source]

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str[source]
version: str[source]
class mainframe.models.schemas.ReportPackageBody(/, **data: Any)[source]

Bases: PackageSpecifier

Model used to specify a package by name and version

name: A str of the name of the package to be scanned version: A str of the package version to scan.

inspector_url: str | None[source]
additional_information: str[source]
class mainframe.models.schemas.ObservationKind(*args, **kwds)[source]

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

DependencyConfusion = 'is_dependency_confusion'[source]
Malware = 'is_malware'[source]
Spam = 'is_spam'[source]
Other = 'something_else'[source]
class mainframe.models.schemas.ObservationReport(/, **data: Any)[source]

Bases: pydantic.BaseModel

Model for a report using the PyPI Observation Api

kind: ObservationKind[source]
summary: str[source]
inspector_url: str | None[source]
extra: dict[str, Any][source]
class mainframe.models.schemas.PackageScanResult(/, **data: Any)[source]

Bases: PackageSpecifier

Client payload to server containing the results of a package scan

commit: str[source]
score: int = 0[source]
inspector_url: str | None = None[source]
rules_matched: list[str] = [][source]
class mainframe.models.schemas.PackageScanResultFail(/, **data: Any)[source]

Bases: PackageSpecifier

The client’s reason as to why scanning a package failed

reason: str[source]
class mainframe.models.schemas.JobResult(/, **data: Any)[source]

Bases: pydantic.BaseModel

Package information of a requested job.

name: str[source]
version: str[source]
distributions: list[str][source]
hash: str[source]
class mainframe.models.schemas.GetRules(/, **data: Any)[source]

Bases: pydantic.BaseModel

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

__class_vars__[source]

The names of the class variables defined on the model.

__private_attributes__[source]

Metadata about the private attributes of the model.

__signature__[source]

The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__[source]

Whether model building is completed, or if there are still undefined fields.

__pydantic_core_schema__[source]

The core schema of the model.

__pydantic_custom_init__[source]

Whether the model has a custom __init__ function.

__pydantic_decorators__[source]

Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.

__pydantic_generic_metadata__[source]

Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.

__pydantic_parent_namespace__[source]

Parent namespace of the model, used for automatic rebuilding of models.

__pydantic_post_init__[source]

The name of the post-init method for the model, if defined.

__pydantic_root_model__[source]

Whether the model is a [RootModel][pydantic.root_model.RootModel].

__pydantic_serializer__[source]

The pydantic-core SchemaSerializer used to dump instances of the model.

__pydantic_validator__[source]

The pydantic-core SchemaValidator used to validate instances of the model.

__pydantic_extra__[source]

A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.

__pydantic_fields_set__[source]

The names of fields explicitly set during instantiation.

__pydantic_private__[source]

Values of private attributes set on the model instance.

hash: str[source]
rules: dict[str, str][source]
class mainframe.models.schemas.NoJob(/, **data: Any)[source]

Bases: pydantic.BaseModel

Returned when no available jobs were found.

detail: str[source]
class mainframe.models.schemas.QueuePackageResponse(/, **data: Any)[source]

Bases: pydantic.BaseModel

Returned after queueing a package. Contains the UUID

id: str[source]
class mainframe.models.schemas.StatsResponse(/, **data: Any)[source]

Bases: pydantic.BaseModel

Recent system statistics

ingested: int[source]
average_scan_time: float[source]
failed: int[source]