Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
5e98cfed
Commit
5e98cfed
authored
Nov 21, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share logic for checking key line validity
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
6654ca5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
weblate/trans/admin_views.py
weblate/trans/admin_views.py
+19
-4
No files found.
weblate/trans/admin_views.py
View file @
5e98cfed
...
...
@@ -45,6 +45,21 @@ KNOWN_HOSTS_FILE = os.path.expanduser('~/.ssh/known_hosts')
RSA_KEY_FILE
=
os
.
path
.
expanduser
(
'~/.ssh/id_rsa.pub'
)
def
is_key_line
(
key
):
"""
Checks whether this line looks like a valid known_hosts line.
"""
if
not
key
:
return
False
if
key
[
0
]
==
'#'
:
return
False
return
(
' ssh-rsa '
in
key
or
' ecdsa-sha2-nistp256 '
in
key
or
' ssh-ed25519 '
in
key
)
@
staff_member_required
def
report
(
request
):
"""
...
...
@@ -214,7 +229,8 @@ def get_host_keys():
result
=
[]
with
open
(
KNOWN_HOSTS_FILE
,
'r'
)
as
handle
:
for
line
in
handle
:
if
' ssh-rsa '
in
line
or
' ecdsa-sha2-nistp256 '
in
line
:
line
=
line
.
strip
()
if
is_key_line
(
line
):
result
.
append
(
parse_hosts_line
(
line
))
except
IOError
:
return
[]
...
...
@@ -293,9 +309,8 @@ def add_host_key(request):
)
keys
=
[]
for
key
in
output
.
splitlines
():
if
(
' ssh-rsa '
not
in
key
and
' ecdsa-sha2-nistp256 '
not
in
key
and
' ssh-ed25519 '
not
in
key
):
key
=
key
.
strip
()
if
not
is_key_line
(
key
):
continue
keys
.
append
(
key
)
host
,
keytype
,
fingerprint
=
parse_hosts_line
(
key
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment