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

indexer-security-init.sh - DNS/Domain Detection vs IP (isDNS vs isIP) #3068

Open
richevanscybermyte opened this issue Aug 3, 2024 · 0 comments

Comments

@richevanscybermyte
Copy link

|Wazuh version|Install type|Action performed|Platform|
|4.8.1|Indexer|Install|Rocky 8|

During installation of Wazuh manually (didn't not verify helper or ansible) I ran into an issue where the indexer-security-init.sh script was not detecting our DNS name as an isDNS. We use a couple of levels of sub domains to separate out our sites and zones. I found that the regex used in the script (line 68 I believe) does not detect my hostnames. I rewrote a new regex to handle my hosts.

^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$
or
^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z0-9]{2,})+$

or the full line 68 in the indexer-security-init.sh script:

                isDNS=$(echo "${HOST}" | grep -P "^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$")
                isDNS=$(echo "${HOST}" | grep -P "^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z0-9]{2,})+$")

the old line is:

                isDNS=$(echo "${2}" | grep -P "^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$")

I tested a bunch of different domain names and the only issue I can see is if the name is not in a FQDN format, it will not match the regex. i.e onwordname, node-01 or namewith-num01 will not match the expression. But it didn't seem like that worked with the other regex either.
I am not sure which regex is better. I modified the one in the current script and added a 0-9 but only after coming up with my own. I imagine it needs more testing to make sure it doesn't get tripped up on something.

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

No branches or pull requests

1 participant