Class: Ci::SecureFile
Constant Summary
collapse
- FILE_SIZE_LIMIT =
5.megabytes.freeze
- CHECKSUM_ALGORITHM =
'sha256'
- PARSABLE_EXTENSIONS =
%w[cer p12 mobileprovision].freeze
Constants included
from Limitable
Limitable::GLOBAL_SCOPE
FileStoreMounter::ALLOWED_FILE_FIELDS
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Instance Method Summary
collapse
Methods included from Limitable
#exceeds_limits?
model_name, table_name_prefix
===, cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Instance Method Details
#checksum_algorithm ⇒ Object
34
35
36
|
# File 'app/models/ci/secure_file.rb', line 34
def checksum_algorithm
CHECKSUM_ALGORITHM
end
|
#file_extension ⇒ Object
38
39
40
|
# File 'app/models/ci/secure_file.rb', line 38
def file_extension
File.extname(name).delete_prefix('.').presence
end
|
42
43
44
|
# File 'app/models/ci/secure_file.rb', line 42
def metadata_parsable?
PARSABLE_EXTENSIONS.include?(file_extension)
end
|
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'app/models/ci/secure_file.rb', line 59
def update_metadata!
return unless metadata_parser
begin
parser = metadata_parser
self.metadata = parser.metadata
self.expires_at = parser.metadata[:expires_at]
save!
rescue StandardError => err
Gitlab::AppLogger.error("Secure File Parser Failure (#{id}): #{err.message} - #{parser.error}.")
nil
end
end
|