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

Fix tests after password encryption #466

Merged
merged 50 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2b177fe
Remove some old TODOs
cbaxley Oct 10, 2024
3b8db23
Don't remove the Azure resources at the end of the Linux only tests
cbaxley Oct 10, 2024
bcf92c5
Change the variables to work with the 2.0 pipeline
cbaxley Oct 11, 2024
df108a1
Run the cluster run workflow to debug the tests
cbaxley Oct 11, 2024
0e3b95d
Run ansible playbook to set fleet
cbaxley Oct 11, 2024
f9e986c
Log secrets in set_fleet.yml
cbaxley Oct 11, 2024
adf8557
Debug setting the environment variables in set_fleet.yml
cbaxley Oct 11, 2024
084b027
Set the debug mode in set_fleet.yml
cbaxley Oct 11, 2024
f526d9e
Log the Fleet API call details in set_fleet.yml
cbaxley Oct 11, 2024
a6d791c
Loop through Fleet API calls in set_fleet.yml
cbaxley Oct 11, 2024
e5c37d5
Change the Fleet API call to loop through attempts in set_fleet.yml
cbaxley Oct 11, 2024
754cf6c
Try to set the Fleet API with retries in set_fleet.yml
cbaxley Oct 11, 2024
a196563
Attempt to output the Fleet API call details in set_fleet.yml
cbaxley Oct 11, 2024
22ad2c1
A new way to handle the Fleet API call in set_fleet.yml
cbaxley Oct 11, 2024
de554ec
Export the check_fleet_api.yml file in set_fleet.yml
cbaxley Oct 11, 2024
832920d
Make sure the password is in the check_fleet_api.yml file
cbaxley Oct 11, 2024
0089796
Exit the loop if the Fleet API call succeeds in check_fleet_api.yml
cbaxley Oct 11, 2024
a6630e8
Wait a little longer for the results to be written to the index
cbaxley Oct 15, 2024
077cdfa
Update the cluster.yml workflow to wait a little longer for the resul…
cbaxley Oct 15, 2024
ac39458
Delay in a different way
cbaxley Oct 15, 2024
ff25324
Attempt a different looping method
cbaxley Oct 15, 2024
877e268
Remove the set-fleet script from the installer
cbaxley Oct 15, 2024
2fefce6
Reverts to old loop method
cbaxley Oct 15, 2024
d6fc98f
Check that fleet is ready in an external script
cbaxley Oct 15, 2024
f4cbd7a
Call the ansible playbook from the install script
cbaxley Oct 15, 2024
9ec8542
Get the CA fingerprint from the Elasticsearch container
cbaxley Oct 15, 2024
03ac6a9
Adds headers to the curl commands in the set_fleet.yml playbook
cbaxley Oct 15, 2024
5b603b9
Address the hosts and fleet API issues
cbaxley Oct 15, 2024
35e9121
Change the way we login to the Kibana API
cbaxley Oct 16, 2024
519bcf8
Increase the timeout for the Endpoint Policy API calls
cbaxley Oct 16, 2024
c9de1e1
Increase the timeout for the Endpoint Policy API calls
cbaxley Oct 16, 2024
05c5ad0
Increase the timeout for the Defend Policy API calls
cbaxley Oct 16, 2024
50e9cb5
Only print debug information if debug_mode is true
cbaxley Oct 16, 2024
3efbe3e
Keeps the azure resources on builds
cbaxley Oct 16, 2024
d924ea1
Fixing Error with certs where the permissions should only be on first
mreeve-snl Oct 16, 2024
4dd138a
Remove sysctl edits to lower privileged ports and add 443 to kibana c…
mreeve-snl Oct 16, 2024
7eb4e5d
Add notes on starting vms via azure cli to testing v2
mreeve-snl Oct 16, 2024
4a9109e
Fix ansible errors in checking for passwords that are created
mreeve-snl Oct 16, 2024
8bf0477
Add debugging commands, and remove references to 443 for kibana from
mreeve-snl Oct 16, 2024
d06c3f3
Update the cluster.yml file to use the new IP address for the Azure i…
cbaxley Oct 16, 2024
3d2fdef
Only allow the ip address of the host to connect to the azure instance
cbaxley Oct 16, 2024
b9801c6
remove unnecassary script
mreeve-snl Oct 17, 2024
18fb506
Move ansible files to the ansible directory
cbaxley Oct 17, 2024
2ea0568
Moving Upgrade Readme into upgrade directory
mreeve-snl Oct 17, 2024
a75bbb5
Merge branch 'cbaxley-fix-tests-after-password-encryption' of github.…
mreeve-snl Oct 17, 2024
b3610b6
Add upgrading docs and remove dev notes
mreeve-snl Oct 17, 2024
f96cde0
Update main readme docs:
mreeve-snl Oct 17, 2024
e26f0bc
Adding updated cloud docs and firewall explanation
mreeve-snl Oct 17, 2024
a9da11d
Update FAQ and Pre-requisites
mreeve-snl Oct 17, 2024
4e4706c
Merge branch 'release-2.0.0' into cbaxley-fix-tests-after-password-en…
cbaxley Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .github/workflows/cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
cd /home/lme-user/LME/testing/v2/installers && \
python3 ./azure/build_azure_linux_network.py \
-g pipe-${{ env.UNIQUE_ID }} \
-s 0.0.0.0/0 \
-s ${{ env.IP_ADDRESS }}/32 \
-vs Standard_D8_v4 \
-l centralus \
-ast 23:00 \
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
env:
ES_PASSWORD: ${{ env.ES_PASSWORD }}
run: |
sleep 120
sleep 360
cd testing/v2/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T pipeline bash -c "
ssh -o StrictHostKeyChecking=no lme-user@${{ env.AZURE_IP }} \
Expand All @@ -265,9 +265,7 @@ jobs:
run: |
cd testing/v2/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T pipeline bash -c "
cd /home/lme-user/LME/testing/v2/installers && \
IP_ADDRESS=\$(cat pipe-${{ env.UNIQUE_ID }}.ip.txt) && \
ssh lme-user@\$IP_ADDRESS 'cd /home/lme-user/LME/testing/tests && \
ssh lme-user@${{ env.AZURE_IP }} 'cd /home/lme-user/LME/testing/tests && \
echo ELASTIC_PASSWORD=\"$ES_PASSWORD\" >> .env && \
echo KIBANA_PASSWORD=\"$KIBANA_PASSWORD\" >> .env && \
echo elastic=\"$ES_PASSWORD\" >> .env && \
Expand All @@ -282,14 +280,12 @@ jobs:
run: |
cd testing/v2/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T pipeline bash -c "
cd /home/lme-user/LME/testing/v2/installers && \
IP_ADDRESS=\$(cat pipe-${{ env.UNIQUE_ID }}.ip.txt) && \
ssh lme-user@\$IP_ADDRESS 'cd /home/lme-user/LME/testing/tests && \
ssh lme-user@${{ env.AZURE_IP }} 'cd /home/lme-user/LME/testing/tests && \
echo ELASTIC_PASSWORD=\"$ES_PASSWORD\" >> .env && \
echo KIBANA_PASSWORD=\"$KIBANA_PASSWORD\" >> .env && \
echo elastic=\"$ES_PASSWORD\" >> .env && \
source venv/bin/activate && \
pytest -v selenium_tests/'
pytest -v selenium_tests/'
"

- name: Cleanup Azure resources
Expand All @@ -311,4 +307,4 @@ jobs:
run: |
cd testing/v2/development
docker compose -p ${{ env.UNIQUE_ID }} down
docker system prune -af
docker system prune -af
6 changes: 5 additions & 1 deletion .github/workflows/linux_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
ES_PASSWORD: ""
KIBANA_PASSWORD: ""
AZURE_IP: ""
IP_ADDRESS: ""

steps:
- name: Checkout repository
Expand All @@ -26,6 +27,9 @@ jobs:
cd testing/v2/development
echo "HOST_UID=$(id -u)" > .env
echo "HOST_GID=$(id -g)" >> .env
PUBLIC_IP=$(curl -s https://api.ipify.org)
echo "IP_ADDRESS=$PUBLIC_IP" >> $GITHUB_ENV


- name: Start pipeline container
run: |
Expand Down Expand Up @@ -57,7 +61,7 @@ jobs:
cd /home/lme-user/LME/testing/v2/installers && \
python3 ./azure/build_azure_linux_network.py \
-g pipe-${{ env.UNIQUE_ID }} \
-s 0.0.0.0/0 \
-s ${{ env.IP_ADDRESS }}/32 \
-vs Standard_E4d_v4 \
-l westus \
-ast 23:00 \
Expand Down
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ Ubuntu 22.04 server running podman containers setup as podman quadlets controlle
### Required Ports:
Ports required are as follows:
- Elasticsearch: *9200*
- Kibana: 443
- Kibana: 443,5601
- Wazuh: *1514,1515,1516,55000,514*
- Agent: *8220*

**Kibana NOTE**: 5601 is the default port, and we've set kibana to listen on 443 as well

### Diagram:

Expand Down Expand Up @@ -106,7 +107,7 @@ You can run this installer to run the total install in ansible.
```bash
sudo apt update && sudo apt install -y ansible
# cd ~/LME-PRIV/lme-2-arch # Or path to your clone of this repo
ansible-playbook install_lme_local.yml
ansible-playbook ./scripts/install_lme_local.yml
```
This assumes that you have the repo in `~/LME/`.

Expand All @@ -116,7 +117,6 @@ ansible-playbook ./scripts/install_lme_local.yml -e "clone_dir=/path/to/clone/di
```

This also assumes your user can sudo without a password. If you need to input a password when you sudo, you can run it with the `-K` flag and it will prompt you for a password.
There is a step that will fail, this is expected, it is checking for podman secrets to see if they exist... on an intial install none will exist :)

#### Steps performed in automated install:
TODO finalize this with more words
Expand All @@ -133,9 +133,7 @@ TODO finalize this with more words

1. `/opt/lme` will be owned by the lmed user, all lme services will run and execute as lmed, and this ensures least privilege in lmed's execution because lmed is a non-admin,unprivileged user.

3. [this script](/scripts/set_sysctl_limits.sh) is executed via ansible AND will change unprivileged ports to start at 80, to allow kibana to listen on 443 from a user run container. If this is not desired, we will be publishing steps to setup firewall rules using ufw//iptables to manage the firewall on this host at a later time.

4. the master password will be stored at `/etc/lme/pass.sh` and owned by root, while service user passwords will be stored at `/etc/lme/vault/`
2. the master password will be stored at `/etc/lme/pass.sh` and owned by root, while service user passwords will be stored at `/etc/lme/vault/`


### Verification post install:
Expand All @@ -156,15 +154,13 @@ sudo -i journalctl -xu lme.service
#try resetting failed:
sudo -i systemctl reset-failed lme*
sudo -i systemctl restart lme.service
```

2. Check you can connect to elasticsearch
```bash
#substitute your password below:
curl -k -u elastic:$(sudo -i ansible-vault view /etc/lme/vault/$(sudo -i podman secret ls | grep elastic | awk '{print $1}') | tr -d '\n') https://localhost:9200
#also try inspecting container logs:
#CONTAINER_NAME=lme-elasticsearch
sudo -i podman logs -f $CONTAINER_NAME
```

3. Check conatiners are running:
2. Check conatiners are running and healthy:
```bash
sudo -i podman ps --format "{{.Names}} {{.Status}}"
```
Expand All @@ -176,11 +172,19 @@ lme-kibana Up 2 hours (healthy)
lme-wazuh-manager Up About an hour
lme-fleet-server Up 50 minutes
```
We are working on getting health check commands for wazuh and fleet, currently they are not integrated

3. Check you can connect to elasticsearch
```bash
#substitute your password below:
curl -k -u elastic:$(sudo -i ansible-vault view /etc/lme/vault/$(sudo -i podman secret ls | grep elastic | awk '{print $1}') | tr -d '\n') https://localhost:9200
```

4. Check you can connect to kibana
You can use an ssh proxy to forward a local port to the remote linux host
```bash
#connect via ssh
ssh -L 8080:localhost:443 [YOUR-LINUX-SERVER]
#connect via ssh if you need to
ssh -L 8080:localhost:5601 [YOUR-LINUX-SERVER]
#go to browser:
#https://localhost:8080
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@
set_fact:
ansible_env: "{{ ansible_env | combine({'PATH': ansible_env.PATH ~ ':/nix/var/nix/profiles/default/bin'}) }}"


- name: Update PATH in user's profile
lineinfile:
path: "~/.profile"
Expand Down Expand Up @@ -291,7 +290,9 @@
args:
executable: /bin/bash
ignore_errors: true

#only fail on a real error
failed_when: result.rc != 0 and (result.rc == 1 and result.changed == false)

- name: Set podman secret passwords
shell: |
source /root/.profile
Expand All @@ -306,7 +307,8 @@
- wazuh_api
- wazuh
become: yes
when: result is failed
## only run this when
when: result.rc == 1

- name: Install Quadlets
hosts: localhost
Expand Down
Loading
Loading