Cross Reference: fingerprint.rb
xref
: /
ontohub
/
app
/
models
/
key
/
fingerprint.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
fingerprint.rb revision 664a966954a0d661e25577d2e7f74c12bcb67c9f
280
N/A
module
Key
::
Fingerprint
280
N/A
extend
ActiveSupport
::
Concern
280
N/A
280
N/A
included
do
280
N/A
before_validation
:
generate_fingerpint
280
N/A
validates
:
fingerprint
,
uniqueness
:
true
280
N/A
end
280
N/A
280
N/A
280
N/A
def
generate_fingerpint
280
N/A
self.fingerprint
=
nil
280
N/A
return
unless
key
?
280
N/A
280
N/A
output
=
''
280
N/A
Tempfile.open
(
'ssh_key_file'
)
do
|
file
|
280
N/A
file.puts
key
280
N/A
file.rewind
280
N/A
output
=
Subprocess.run
'ssh-keygen'
,
'-lf'
,
file.path
280
N/A
end
280
N/A
output.gsub
/
([\d\h]{
2
}:)
+[\d\h]{
2
}/
do
|
match
|
280
N/A
self.fingerprint
=
match.gsub
(
":"
,
""
)
280
N/A
end
280
N/A
rescue
Subprocess
::
Error
=> e
280
N/A
errors
[:
key
] <<
e.output.split
(
"\n"
)
.last.split
(
" "
,
2
)
.
last
280
N/A
end
280
N/A
280
N/A
end