From 6995153f6a2b6533abf9e0c3852fa2f0a25f1a2e Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Mon, 12 Aug 2024 08:49:30 +0200 Subject: [PATCH] fix: change ulid regex to validate correct range --- .../connected_services/apispec.py | 4 ++-- .../renku_data_services/namespace/apispec.py | 6 +++--- .../renku_data_services/project/apispec.py | 4 ++-- .../repositories/apispec.py | 4 ++-- .../renku_data_services/secrets/apispec.py | 4 ++-- .../renku_data_services/storage/api.spec.yaml | 18 ++++++++--------- .../renku_data_services/storage/apispec.py | 20 +++++++++---------- .../renku_data_services/users/apispec.py | 4 ++-- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/components/renku_data_services/connected_services/apispec.py b/components/renku_data_services/connected_services/apispec.py index 884edbf5b..519a07ec3 100644 --- a/components/renku_data_services/connected_services/apispec.py +++ b/components/renku_data_services/connected_services/apispec.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: api.spec.yaml -# timestamp: 2024-08-06T05:55:35+00:00 +# timestamp: 2024-08-12T06:46:18+00:00 from __future__ import annotations @@ -153,7 +153,7 @@ class Connection(BaseAPISpec): description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]{26}$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) provider_id: str = Field( ..., diff --git a/components/renku_data_services/namespace/apispec.py b/components/renku_data_services/namespace/apispec.py index cb7162856..a28579b87 100644 --- a/components/renku_data_services/namespace/apispec.py +++ b/components/renku_data_services/namespace/apispec.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: api.spec.yaml -# timestamp: 2024-08-06T08:46:00+00:00 +# timestamp: 2024-08-12T06:46:16+00:00 from __future__ import annotations @@ -29,7 +29,7 @@ class NamespaceResponse(BaseAPISpec): description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]{26}$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) name: Optional[str] = Field( None, @@ -93,7 +93,7 @@ class GroupResponse(BaseAPISpec): description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]{26}$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) name: str = Field( ..., diff --git a/components/renku_data_services/project/apispec.py b/components/renku_data_services/project/apispec.py index 7e01ab2b1..c9b57db17 100644 --- a/components/renku_data_services/project/apispec.py +++ b/components/renku_data_services/project/apispec.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: api.spec.yaml -# timestamp: 2024-08-06T05:55:31+00:00 +# timestamp: 2024-08-12T06:46:15+00:00 from __future__ import annotations @@ -112,7 +112,7 @@ class Project(BaseAPISpec): description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]{26}$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) name: str = Field( ..., diff --git a/components/renku_data_services/repositories/apispec.py b/components/renku_data_services/repositories/apispec.py index 13dccc8bf..e8e651f29 100644 --- a/components/renku_data_services/repositories/apispec.py +++ b/components/renku_data_services/repositories/apispec.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: api.spec.yaml -# timestamp: 2024-08-06T05:55:37+00:00 +# timestamp: 2024-08-12T06:46:19+00:00 from __future__ import annotations @@ -61,6 +61,6 @@ class RepositoryProviderMatch(BaseAPISpec): description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]{26}$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) repository_metadata: Optional[RepositoryMetadata] = None diff --git a/components/renku_data_services/secrets/apispec.py b/components/renku_data_services/secrets/apispec.py index 672c60fdf..812598384 100644 --- a/components/renku_data_services/secrets/apispec.py +++ b/components/renku_data_services/secrets/apispec.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: api.spec.yaml -# timestamp: 2024-08-06T05:55:34+00:00 +# timestamp: 2024-08-12T06:46:17+00:00 from __future__ import annotations @@ -20,7 +20,7 @@ class Ulid(RootModel[str]): description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]{26}$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) diff --git a/components/renku_data_services/storage/api.spec.yaml b/components/renku_data_services/storage/api.spec.yaml index 514edb7ab..dcef7e952 100644 --- a/components/renku_data_services/storage/api.spec.yaml +++ b/components/renku_data_services/storage/api.spec.yaml @@ -16,7 +16,7 @@ paths: name: storage_id required: true schema: - $ref: "#/components/schemas/UlidId" + $ref: "#/components/schemas/Ulid" description: the id of the storage get: summary: get cloud storage details @@ -73,7 +73,7 @@ paths: additionalProperties: false properties: project_id: - $ref: "#/components/schemas/UlidId" + $ref: "#/components/schemas/Ulid" required: - project_id responses: @@ -122,7 +122,7 @@ paths: name: storage_id required: true schema: - $ref: "#/components/schemas/UlidId" + $ref: "#/components/schemas/Ulid" description: the id of the storage get: summary: get cloud storage details @@ -331,7 +331,7 @@ components: project_id: oneOf: - $ref: "#/components/schemas/GitlabProjectId" - - $ref: "#/components/schemas/UlidId" + - $ref: "#/components/schemas/Ulid" required: - project_id example: @@ -413,7 +413,7 @@ components: project_id: oneOf: - $ref: "#/components/schemas/GitlabProjectId" - - $ref: "#/components/schemas/UlidId" + - $ref: "#/components/schemas/Ulid" storage_type: $ref: "#/components/schemas/StorageType" name: @@ -437,7 +437,7 @@ components: - storage_id properties: storage_id: - $ref: "#/components/schemas/UlidId" + $ref: "#/components/schemas/Ulid" CloudStorageGet: type: object description: Get response for a cloud storage. Contains storage and information about fields that are required if the storage is private. @@ -532,12 +532,12 @@ components: type: string description: data type of option value. RClone has more options but they map to the ones listed here. enum: ["int", "bool", "string", "Time"] - UlidId: - description: ULID identifier of an object + Ulid: + description: ULID identifier type: string minLength: 26 maxLength: 26 - pattern: "^[A-Z0-9]+$" + pattern: "^[0-7][0-9A-HJKMNP-TV-Z]{25}$" # This is case-insensitive GitlabProjectId: description: Project id of a gitlab project (only int project id allowed, encoded as string for future-proofing) type: string diff --git a/components/renku_data_services/storage/apispec.py b/components/renku_data_services/storage/apispec.py index 1ee806776..ae78d3b91 100644 --- a/components/renku_data_services/storage/apispec.py +++ b/components/renku_data_services/storage/apispec.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: api.spec.yaml -# timestamp: 2024-08-09T12:39:58+00:00 +# timestamp: 2024-08-12T07:20:07+00:00 from __future__ import annotations @@ -76,13 +76,13 @@ class RCloneOption(BaseAPISpec): ) -class UlidId(RootModel[str]): +class Ulid(RootModel[str]): root: str = Field( ..., - description="ULID identifier of an object", + description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]+$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) @@ -113,10 +113,10 @@ class StorageV2Params(BaseAPISpec): ) project_id: str = Field( ..., - description="ULID identifier of an object", + description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]+$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) @@ -154,7 +154,7 @@ class StorageSchemaObscurePostRequest(BaseAPISpec): class GitRequest(BaseAPISpec): - project_id: Union[GitlabProjectId, UlidId] + project_id: Union[GitlabProjectId, Ulid] class CloudStorageUrl(GitRequest): @@ -197,7 +197,7 @@ class CloudStorage(GitRequest): class CloudStoragePatch(BaseAPISpec): - project_id: Optional[Union[GitlabProjectId, UlidId]] = None + project_id: Optional[Union[GitlabProjectId, Ulid]] = None storage_type: Optional[str] = Field( None, description="same as rclone prefix/ rclone config type. Ignored in requests, but returned in responses for convenience.", @@ -229,10 +229,10 @@ class CloudStoragePatch(BaseAPISpec): class CloudStorageWithId(CloudStorage): storage_id: str = Field( ..., - description="ULID identifier of an object", + description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]+$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) diff --git a/components/renku_data_services/users/apispec.py b/components/renku_data_services/users/apispec.py index 9c1697bc1..4d7f9f2ab 100644 --- a/components/renku_data_services/users/apispec.py +++ b/components/renku_data_services/users/apispec.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: api.spec.yaml -# timestamp: 2024-08-06T11:43:01+00:00 +# timestamp: 2024-08-12T06:46:14+00:00 from __future__ import annotations @@ -149,7 +149,7 @@ class SecretWithId(BaseAPISpec): description="ULID identifier", max_length=26, min_length=26, - pattern="^[A-Z0-9]{26}$", + pattern="^[0-7][0-9A-HJKMNP-TV-Z]{25}$", ) name: str = Field( ...,