Skip to content

Commit 1a4c2fc

Browse files
committed
feat: added limits for hostname and endpoint
1 parent 8333bcd commit 1a4c2fc

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

app/models/runtime_module_definition.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
class RuntimeModuleDefinition < ApplicationRecord
44
belongs_to :runtime_module, inverse_of: :runtime_module_definitions
55

6-
validates :host, :endpoint, presence: true
6+
validates :host, presence: true, length: { maximum: 253 }
7+
validates :endpoint, presence: true, length: { maximum: 2048 }
78
validates :port, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 65_535 }
89
end

db/migrate/20260607220000_add_runtime_module_definition.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ class AddRuntimeModuleDefinition < Code0::ZeroTrack::Database::Migration[1.0]
44
def change
55
create_table :runtime_module_definitions do |t|
66
t.references :runtime_module, null: false, foreign_key: { on_delete: :cascade }
7-
t.text :host, null: false
7+
t.text :host, null: false, limit: 253
88
t.bigint :port, null: false
9-
t.text :endpoint, null: false
9+
t.text :endpoint, null: false, limit: 2048
1010

1111
t.timestamps_with_timezone
1212
end

db/structure.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,9 @@ CREATE TABLE runtime_module_definitions (
929929
port bigint NOT NULL,
930930
endpoint text NOT NULL,
931931
created_at timestamp with time zone NOT NULL,
932-
updated_at timestamp with time zone NOT NULL
932+
updated_at timestamp with time zone NOT NULL,
933+
CONSTRAINT check_5328b69b6f CHECK ((char_length(host) <= 253)),
934+
CONSTRAINT check_5a8231f609 CHECK ((char_length(endpoint) <= 2048))
933935
);
934936

935937
CREATE SEQUENCE runtime_module_definitions_id_seq

0 commit comments

Comments
 (0)