8000 Update sshprep by william-stearns · Pull Request #45 · activecm/rita · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update sshprep #45

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

Merged
merged 2 commits into from
May 5, 2025
Merged

Update sshprep #45

merged 2 commits into from
May 5, 2025

Conversation

william-stearns
Copy link
Contributor

No description provided.

Co-Authored-By: William Stearns <3538265+william-stearns@users.noreply.github.com>
@0x6d6f7468 0x6d6f7468 changed the title Update sshprep (test PR for Bradley) Update sshprep Apr 30, 2025
ip4=$(dig +short ${2} A)
ip6=$(dig +short ${2} AAAA)
ip4=$(dig +nocomment +short ${2} A 2>/dev/null | sed -e 's/;;.*//' | grep -v '^$')
ip6=$(dig +nocomment +short ${2} AAAA 2>/dev/null | sed -e 's/;;.*//' | grep -v '^$')
Copy link
Contributor

Choose a reason for hiding this comment

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

A few things here:

  1. Should we handle cases where one hostname corresponds to multiple IP addresses? There are a few cases that I'm aware of in which this could happen and it might cause commands to fail. If for some reason we needed to treat each IP address as different, we could possibly handle it by iterating over the value of ip4 and ip6 variables. However, I think in most cases that this could happen, we would be better off just picking one IP address.
  2. To my knowledge, adding | sed -e 's/;;.*//' | grep -v '^$' is made redundant by the combination of +nocomment and +short dig arguments. Unless I'm mistaken, we could probably cut those.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. You are correct - the Hostname field where $ipv4 and/or $ipv6 are used only supports a single address. I agree, limiting this to a single IP makes sense. Would you please add | head -1 after the grep -v '^$' on both the ipv4 and ipv6 lines and before the right parenthesis?
  2. I thought that was true as well and that's why the first version did not have the sed and grep commands. Unfortunately I was wrong and these have to be part of the lookup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the file in the update-sshprep branch (to include head -1 for both the ipv4 and ipv6 variable assignments. It's not clear whether the change propagated to the PR or not.

Copy link
Contributor
@0x6d6f7468 0x6d6f7468 May 5, 2025

Choose a reason for hiding this comment

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

Thanks for making that change. For future reference, any pushes you make to a branch after PR will be associated with that PR. Makes for easy response to change requests (meaning that you did it correctly here).

Just curious, can you provide a scenario that you found during testing where having +nocomment +short still resulted in empty lines and comments (;;)? From the looks of it, +nocomment was added to the dig command at the same time as the sed and grep commands.

Thanks!

Add Bradley's suggestion of using head -1 to limit to a single address.
@william-stearns
Copy link
Contributor Author
william-stearns commented May 5, 2025 via email

@lisaSW lisaSW merged commit c67effa into config_update May 5, 2025
3 of 5 checks passed
@lisaSW lisaSW deleted the update-sshprep branch May 5, 2025 22:54
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.

4 participants
0