/usr/lib/ruby/vendor_ruby/diaspora_federation/validators/rules/public_key.rb is in ruby-diaspora-federation 0.1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | module Validation
module Rule
# Public key validation rule
#
# A valid key must:
# * start with "-----BEGIN PUBLIC KEY-----" and end with "-----END PUBLIC KEY-----"
# or
# * start with "-----BEGIN RSA PUBLIC KEY-----" and end with "-----END RSA PUBLIC KEY-----"
class PublicKey
# The error key for this rule
# @return [Symbol] error key
def error_key
:public_key
end
# Determines if value is a valid public key
def valid_value?(value)
!value.nil? && (
(value.strip.start_with?("-----BEGIN PUBLIC KEY-----") &&
value.strip.end_with?("-----END PUBLIC KEY-----")) ||
(value.strip.start_with?("-----BEGIN RSA PUBLIC KEY-----") &&
value.strip.end_with?("-----END RSA PUBLIC KEY-----"))
)
end
# This rule has no params.
# @return [Hash] params
def params
{}
end
end
end
end
|