Commit 3710372c authored by Darby Frey's avatar Darby Frey

Adding Secure Files upload limit

Secure Files are now limited to 100 per project.

Changelog: changed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82858
parent a25994af
......@@ -3,10 +3,14 @@
module Ci
class SecureFile < Ci::ApplicationRecord
include FileStoreMounter
include Limitable
FILE_SIZE_LIMIT = 5.megabytes.freeze
CHECKSUM_ALGORITHM = 'sha256'
self.limit_scope = :project
self.limit_name = 'project_ci_secure_files'
belongs_to :project, optional: false
validates :file, presence: true, file_size: { maximum: FILE_SIZE_LIMIT }
......
# frozen_string_literal: true
class AddProjectCiSecureFilesToPlanLimits < Gitlab::Database::Migration[1.0]
def change
add_column(:plan_limits, :project_ci_secure_files, :integer, default: 100, null: false)
end
end
2dad53754682d9d4e8338978336807255503746b82795afb812b3b65b7335ca8
\ No newline at end of file
......@@ -18611,7 +18611,8 @@ CREATE TABLE plan_limits (
external_audit_event_destinations integer DEFAULT 5 NOT NULL,
dotenv_variables integer DEFAULT 20 NOT NULL,
dotenv_size integer DEFAULT 5120 NOT NULL,
pipeline_triggers integer DEFAULT 25000 NOT NULL
pipeline_triggers integer DEFAULT 25000 NOT NULL,
project_ci_secure_files integer DEFAULT 100 NOT NULL
);
CREATE SEQUENCE plan_limits_id_seq
......@@ -17,6 +17,10 @@ RSpec.describe Ci::SecureFile do
it_behaves_like 'having unique enum values'
it_behaves_like 'includes Limitable concern' do
subject { build(:ci_secure_file, project: create(:project)) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:checksum) }
it { is_expected.to validate_presence_of(:file_store) }
......
......@@ -23,7 +23,7 @@ RSpec.shared_examples 'includes Limitable concern' do
context 'with an existing model' do
before do
subject.dup.save!
subject.clone.save!
end
it 'cannot create new models exceeding the plan limits' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment