Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
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
gitlab-ce
Commits
c6f68f89
Commit
c6f68f89
authored
Sep 23, 2021
by
Jonas Wälter
Committed by
Heinrich Lee Yu
Sep 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update help/instance_configuration: hide SSH keys if algorithm disabled
parent
d519789a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
app/models/instance_configuration.rb
app/models/instance_configuration.rb
+6
-1
spec/models/instance_configuration_spec.rb
spec/models/instance_configuration_spec.rb
+17
-0
No files found.
app/models/instance_configuration.rb
View file @
c6f68f89
...
...
@@ -22,7 +22,12 @@ class InstanceConfiguration
private
def
ssh_algorithms_hashes
SSH_ALGORITHMS
.
map
{
|
algo
|
ssh_algorithm_hashes
(
algo
)
}.
compact
SSH_ALGORITHMS
.
select
{
|
algo
|
ssh_algorithm_enabled?
(
algo
)
}.
map
{
|
algo
|
ssh_algorithm_hashes
(
algo
)
}.
compact
end
def
ssh_algorithm_enabled?
(
algorithm
)
algorithm_key_restriction
=
application_settings
[
"
#{
algorithm
.
downcase
}
_key_restriction"
]
algorithm_key_restriction
.
nil?
||
algorithm_key_restriction
!=
ApplicationSetting
::
FORBIDDEN_KEY_VALUE
end
def
host
...
...
spec/models/instance_configuration_spec.rb
View file @
c6f68f89
...
...
@@ -31,6 +31,23 @@ RSpec.describe InstanceConfiguration do
expect
(
result
.
size
).
to
eq
(
InstanceConfiguration
::
SSH_ALGORITHMS
.
size
)
end
it
'includes all algorithms'
do
stub_pub_file
(
pub_file
)
result
=
subject
.
settings
[
:ssh_algorithms_hashes
]
expect
(
result
.
map
{
|
a
|
a
[
:name
]
}).
to
match_array
(
%w(DSA ECDSA ED25519 RSA)
)
end
it
'does not include disabled algorithm'
do
Gitlab
::
CurrentSettings
.
current_application_settings
.
update!
(
dsa_key_restriction:
ApplicationSetting
::
FORBIDDEN_KEY_VALUE
)
stub_pub_file
(
pub_file
)
result
=
subject
.
settings
[
:ssh_algorithms_hashes
]
expect
(
result
.
map
{
|
a
|
a
[
:name
]
}).
to
match_array
(
%w(ECDSA ED25519 RSA)
)
end
def
pub_file
(
exist:
true
)
path
=
exist
?
'spec/fixtures/ssh_host_example_key.pub'
:
'spec/fixtures/ssh_host_example_key.pub.random'
...
...
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