Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/write-ssh-key-fingerprints: do not display empty header/footer #817

Merged
merged 2 commits into from
Mar 25, 2021

Conversation

dermotbradley
Copy link
Contributor

When console output of SSH info is disabled show no headers/footers.

Prevent risk of message text being interpreted as "logger" option by
appending "--" to logger options.

Correct syslog output that was tagged with "ec2" regardless of DataSource
in use. Now use "cloud-init" tag instead.

Various "shellcheck" corrections.

Add testcase for disabled output of SSH host keys.

LP: #1915460

Provides alternative solution to #811.

Test Steps

In user-data config add either, or both, of the following lines:

ssh_fp_console_blacklist: [ 'ssh-dsa', 'ssh-dss', 'ssh-rsa', 'ssh-ed25519' ]
ssh_key_console_blacklist: [ 'ssh-dsa', 'ssh-dss', 'ssh-rsa', 'ssh-ed25519' ]

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this change looks good. Might be worth making a function out of the shellcheck comment and the logger options to cleanup the calls to logger.

I appreciate the additional cloud tests, but unfortunately these tests are deprecated now. Docs for the new test framework are here, but the TLDR for this PR would be to add a test to test_keys_to_console.py with a full blacklist in the cloud-config and assert there's no headers/footers (similar to the bottom two tests in the file)

@dermotbradley
Copy link
Contributor Author

dermotbradley commented Mar 3, 2021

@TheRealFalcon Hi there

I'll find some time in the next few days to work on this.

Regarding the correction of the 'ec2' string - @OddBloke mentioned on IRC that there might be some stuff out there (Subquity?) relying on that value and he would look into it further. I can drop this portion of the PR if its likely to cause problems.

@github-actions
Copy link

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging mitechie, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag mitechie to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label Mar 18, 2021
@dermotbradley dermotbradley force-pushed the fix-console-ssh-silence branch 3 times, most recently from 4f288dc to 89f2e63 Compare March 19, 2021 00:42
@dermotbradley
Copy link
Contributor Author

Overall, this change looks good. Might be worth making a function out of the shellcheck comment and the logger options to cleanup the calls to logger.

Done.

the TLDR for this PR would be to add a test to test_keys_to_console.py with a full blacklist in the cloud-config and assert there's no headers/footers (similar to the bottom two tests in the file)

Done.

@dermotbradley
Copy link
Contributor Author

@mitechie ping!

@mitechie mitechie removed the stale-pr Pull request is stale; will be auto-closed soon label Mar 23, 2021
@mitechie
Copy link
Contributor

pong! I've cleared the tag and we'll get another round of reviews going. Thanks for the ping.

Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Just a couple changes the integration test needed

tests/integration_tests/modules/test_keys_to_console.py Outdated Show resolved Hide resolved
tests/integration_tests/modules/test_keys_to_console.py Outdated Show resolved Hide resolved
When output of SSH host keys and/or SSH fingerprints are disabled for
all keys do not display headers and footers.

Prevent risk of message text being interpreted as "logger" option by
appending "--" to logger options.

Correct syslog output that was tagged with "ec2" regardless of DataSource
in use. Now use "cloud-init" tag instead.

Various "shellcheck" corrections.

Add testcase for disabled output of SSH host keys.
@dermotbradley dermotbradley force-pushed the fix-console-ssh-silence branch from 89f2e63 to a3c5ec1 Compare March 25, 2021 02:39
Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TheRealFalcon TheRealFalcon merged commit 13606a1 into canonical:master Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants