You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/08/24 17:58:01 UTC

(tooling-trusted-releases) branch sbp updated: Add the OpenPGP certificate log table

This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/sbp by this push:
     new 0373fab1 Add the OpenPGP certificate log table
0373fab1 is described below

commit 0373fab1cd6a4ee36f816150ed88c862bac1989d
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Mon Aug 24 18:57:42 2026 +0100

    Add the OpenPGP certificate log table
---
 atr/db/__init__.py                              | 38 +++++++++++++++++
 atr/models/sql.py                               | 34 +++++++++++++++
 migrations/versions/0121_2026.08.21_fdda1630.py | 57 +++++++++++++++++++++++++
 3 files changed, 129 insertions(+)

diff --git a/atr/db/__init__.py b/atr/db/__init__.py
index 07e2543c..42e02b1f 100644
--- a/atr/db/__init__.py
+++ b/atr/db/__init__.py
@@ -481,6 +481,44 @@ class Session(sqlalchemy.ext.asyncio.AsyncSession):
         if commit is True:
             await self.commit()
 
+    def key_attestable(
+        self,
+        fingerprint: Opt[str] = NOT_SET,
+        seq: Opt[int] = NOT_SET,
+        operation: Opt[sql.KeyOperation] = NOT_SET,
+        source: Opt[str] = NOT_SET,
+        input: Opt[bytes | None] = NOT_SET,
+        deletions: Opt[bytes | None] = NOT_SET,
+        additions: Opt[bytes | None] = NOT_SET,
+        updated: Opt[datetime.datetime] = NOT_SET,
+        actor: Opt[str] = NOT_SET,
+        role: Opt[sql.KeyRole] = NOT_SET,
+    ) -> Query[sql.KeyAttestable]:
+        query = sqlmodel.select(sql.KeyAttestable)
+
+        if is_defined(fingerprint):
+            query = query.where(sql.KeyAttestable.fingerprint == fingerprint)
+        if is_defined(seq):
+            query = query.where(sql.KeyAttestable.seq == seq)
+        if is_defined(operation):
+            query = query.where(sql.KeyAttestable.operation == operation)
+        if is_defined(source):
+            query = query.where(sql.KeyAttestable.source == source)
+        if is_defined(input):
+            query = query.where(sql.KeyAttestable.input == input)
+        if is_defined(deletions):
+            query = query.where(sql.KeyAttestable.deletions == deletions)
+        if is_defined(additions):
+            query = query.where(sql.KeyAttestable.additions == additions)
+        if is_defined(updated):
+            query = query.where(sql.KeyAttestable.updated == updated)
+        if is_defined(actor):
+            query = query.where(sql.KeyAttestable.actor == actor)
+        if is_defined(role):
+            query = query.where(sql.KeyAttestable.role == role)
+
+        return Query(self, query)
+
     def personal_access_token(
         self,
         token_hash: Opt[str] = NOT_SET,
diff --git a/atr/models/sql.py b/atr/models/sql.py
index b0e97e3e..f086f149 100644
--- a/atr/models/sql.py
+++ b/atr/models/sql.py
@@ -171,6 +171,18 @@ class DistributionPlatform(enum.Enum):
     )
 
 
+class KeyOperation(enum.StrEnum):
+    DELETE = "delete"
+    RESTORE = "restore"
+    REVISE = "revise"
+
+
+class KeyRole(enum.StrEnum):
+    ADMIN = "admin"
+    SERVICE = "service"
+    USER = "user"
+
+
 class LicenseCheckMode(enum.StrEnum):
     BOTH = "Both"
     LIGHTWEIGHT = "Lightweight"
@@ -575,6 +587,10 @@ class UserPreferencesJSON(sqlalchemy.types.TypeDecorator):
 # SQL models
 
 
+def _enum_values(enum_class: type[enum.Enum]) -> list[str]:
+    return [member.value for member in enum_class]
+
+
 def example(value: Any) -> dict[Literal["schema_extra"], dict[str, Any]]:
     return {"schema_extra": {"json_schema_extra": {"examples": [value]}}}
 
@@ -632,6 +648,24 @@ class Banner(sqlmodel.SQLModel, table=True):
     )
 
 
+# KeyAttestable:
+class KeyAttestable(sqlmodel.SQLModel, table=True):
+    fingerprint: str = sqlmodel.Field(primary_key=True)
+    seq: int = sqlmodel.Field(primary_key=True)
+    operation: KeyOperation = sqlmodel.Field(
+        sa_column=sqlalchemy.Column(sqlalchemy.Enum(KeyOperation, values_callable=_enum_values), nullable=False)
+    )
+    source: str = sqlmodel.Field()
+    input: bytes | None = sqlmodel.Field(default=None)
+    deletions: bytes | None = sqlmodel.Field(default=None)
+    additions: bytes | None = sqlmodel.Field(default=None)
+    updated: datetime.datetime = sqlmodel.Field(sa_column=sqlalchemy.Column(UTCDateTime, nullable=False))
+    actor: str = sqlmodel.Field()
+    role: KeyRole = sqlmodel.Field(
+        sa_column=sqlalchemy.Column(sqlalchemy.Enum(KeyRole, values_callable=_enum_values), nullable=False)
+    )
+
+
 # KeyLink:
 class KeyLink(sqlmodel.SQLModel, table=True):
     committee_key: str = sqlmodel.Field(foreign_key="committee.key", primary_key=True)
diff --git a/migrations/versions/0121_2026.08.21_fdda1630.py b/migrations/versions/0121_2026.08.21_fdda1630.py
new file mode 100644
index 00000000..1dacc59b
--- /dev/null
+++ b/migrations/versions/0121_2026.08.21_fdda1630.py
@@ -0,0 +1,57 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Add the OpenPGP certificate log
+
+Revision ID: 0121_2026.08.21_fdda1630
+Revises: 0120_2026.08.11_b89e555b
+Create Date: 2026-08-21 15:31:42.118407+00:00
+"""
+
+from collections.abc import Sequence
+
+import sqlalchemy as sa
+from alembic import op
+
+import atr.models.sql as sql
+
+# Revision identifiers, used by Alembic
+revision: str = "0121_2026.08.21_fdda1630"
+down_revision: str | None = "0120_2026.08.11_b89e555b"
+branch_labels: str | Sequence[str] | None = None
+depends_on: str | Sequence[str] | None = None
+
+
+def upgrade() -> None:
+    op.create_table(
+        "keyattestable",
+        sa.Column("fingerprint", sa.String(), nullable=False),
+        sa.Column("seq", sa.Integer(), nullable=False),
+        sa.Column("operation", sa.Enum("delete", "restore", "revise", name="keyoperation"), nullable=False),
+        sa.Column("source", sa.String(), nullable=False),
+        sa.Column("input", sa.LargeBinary(), nullable=True),
+        sa.Column("deletions", sa.LargeBinary(), nullable=True),
+        sa.Column("additions", sa.LargeBinary(), nullable=True),
+        sa.Column("updated", sql.UTCDateTime(timezone=True), nullable=False),
+        sa.Column("actor", sa.String(), nullable=False),
+        sa.Column("role", sa.Enum("admin", "service", "user", name="keyrole"), nullable=False),
+        sa.PrimaryKeyConstraint("fingerprint", "seq", name=op.f("pk_keyattestable")),
+    )
+
+
+def downgrade() -> None:
+    op.drop_table("keyattestable")


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org