Skip to content

Commit 280ffaf

Browse files
committed
Merge branch 'cherry-pick-57db7f98' into 'master_8.1.x'
CP V8.1 - Story #14820: Add security controls for production deployment. Story #14820: Add security controls for production deployment. See merge request vitam/vitam!10666 (cherry picked from commit 57db7f9) 1b46910 Story #14820: Add security controls for production deployment. Co-authored-by: Julien Georges <[email protected]> See merge request vitam/vitam!10680
2 parents f967b96 + 84bce0e commit 280ffaf

File tree

5 files changed

+103
-37
lines changed

5 files changed

+103
-37
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
3+
# Playbook to check compliance with deployment_mode: prod
4+
5+
- hosts: vitam
6+
roles:
7+
- checks
Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
---
22

3-
- name: Check if consul_disabled var is set for some servers
4-
fail:
5-
msg: "Consul is mandatory for server {{ ansible_hostname }} (consul_disabled var must not be equal to 'true'), please check your configuration"
6-
run_once: true
7-
when: consul_disabled is defined and
8-
consul_disabled |lower == "true" and
9-
(
10-
inventory_hostname in groups['zone_access'] or
11-
inventory_hostname in groups['zone_applicative'] or
12-
inventory_hostname in groups['zone_storage'] or
13-
inventory_hostname in groups['zone_data'] or
14-
inventory_hostname in groups['zone_admin']
15-
)
3+
- block:
4+
5+
- name: Check if consul_disabled var is set for some servers
6+
fail:
7+
msg: "Consul is mandatory for server {{ ansible_hostname }} (consul_disabled var must not be equal to 'true'), please check your configuration"
8+
when: consul_disabled is defined and
9+
consul_disabled | lower == "true" and
10+
(
11+
inventory_hostname in groups['zone_access'] or
12+
inventory_hostname in groups['zone_applicative'] or
13+
inventory_hostname in groups['zone_storage'] or
14+
inventory_hostname in groups['zone_data'] or
15+
inventory_hostname in groups['zone_admin']
16+
)
17+
18+
- name: Check consul_encrypt variable
19+
assert:
20+
fail_msg: "ERROR: You must generate a dedicated consul_encrypt key for production environments ! Please use the script: ./pki/scripts/generate_consul_key.sh to generate a proper key."
21+
success_msg: "consul_encrypt key is properly updated !"
22+
that: consul_encrypt != 'Biz14ohqN4HtvZmrXp3N4A=='
23+
ignore_errors: "{{ true if deployment_mode | default('prod') == 'dev' else false }}"
24+
25+
run_once: true

deployment/ansible-vitam-exploitation/roles/checks/tasks/check_dev_only_components.yml

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
---
22

3-
- name: Check deployment mode
4-
fail:
5-
msg: "Invalid deployment mode. Expected values are 'prod' (default) or 'dev'"
6-
when: deployment_mode | default('prod') not in ['prod','dev']
7-
run_once: true
8-
93
- block:
104

11-
- name: Ensure browser is disabled in production mode
12-
fail:
13-
msg: "browser deployment should not be enabled in production mode (browser.enabled must be set to false)"
14-
when: browser.enabled | default(false) | bool == true
5+
- name: Check deployment_mode
6+
assert:
7+
fail_msg: "ERROR: Invalid deployment_mode. Expected values are 'prod' (default) or 'dev'"
8+
success_msg: "{{ 'dev mode enabled, ignoring the following errors...' if deployment_mode | default('prod') == 'dev' else 'production mode enabled, execution will fail if errors are detected...' }}"
9+
that: deployment_mode | default('prod') in ['prod', 'dev']
10+
11+
- name: Ensure browser is disabled in production mode
12+
fail:
13+
msg: "browser deployment should not be enabled in production mode (browser.enabled must be set to false)"
14+
when: browser.enabled | default(false) | bool
15+
ignore_errors: "{{ true if deployment_mode | default('prod') == 'dev' else false }}"
1516

16-
- name: Ensure ihm-recette is disabled in production mode
17-
fail:
18-
msg: "Ihm-recette deployment should not be enabled in production mode (hosts_ihm_recette group should be empty)"
19-
when: groups['hosts_ihm_recette'] | length > 0
17+
- name: Ensure ihm-recette is disabled in production mode
18+
fail:
19+
msg: "Ihm-recette deployment should not be enabled in production mode (hosts_ihm_recette group should be empty)"
20+
when: groups['hosts_ihm_recette'] | length > 0
21+
ignore_errors: "{{ true if deployment_mode | default('prod') == 'dev' else false }}"
2022

21-
- name: Ensure kibana-data is disabled in production mode
22-
fail:
23-
msg: "Kibana-data deployment should not be enabled in production mode (hosts_kibana_data group should be empty)"
24-
when: groups['hosts_kibana_data'] | length > 0
23+
- name: Ensure kibana-data is disabled in production mode
24+
fail:
25+
msg: "Kibana-data deployment should not be enabled in production mode (hosts_kibana_data group should be empty)"
26+
when: groups['hosts_kibana_data'] | length > 0
27+
ignore_errors: "{{ true if deployment_mode | default('prod') == 'dev' else false }}"
2528

26-
- name: Ensure dev tools is disabled in production mode
27-
fail:
28-
msg: "Dev tools (mongo-express / elasticsearch head plugins) deployment should not be enabled in production mode (hosts_dev_tools group should be empty)"
29-
when: groups['hosts_dev_tools'] | length > 0
29+
- name: Ensure dev tools is disabled in production mode
30+
fail:
31+
msg: "Dev tools (mongo-express / elasticsearch head plugins) deployment should not be enabled in production mode (hosts_dev_tools group should be empty)"
32+
when: groups['hosts_dev_tools'] | length > 0
33+
ignore_errors: "{{ true if deployment_mode | default('prod') == 'dev' else false }}"
3034

3135
run_once: true
32-
when: deployment_mode | default('prod') != "dev"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
3+
- block:
4+
5+
- name: Determine which offers to check based on vitam_strategy
6+
set_fact:
7+
offers_to_check: "{{ offers_to_check | default([]) + [item.name] }}"
8+
loop: "{{ vitam_strategy }}"
9+
when: item.distant | default(false) != true
10+
11+
- name: Build list of password checks for offers
12+
set_fact:
13+
offer_password_checks: "{{ offer_password_checks | default([]) + [{'key': 'mongodb[' + item + '].admin.password', 'value': mongodb[item].admin.password}, {'key': 'mongodb[' + item + '].localadmin.password', 'value': mongodb[item].localadmin.password}, {'key': 'mongodb[' + item + '].system.password', 'value': mongodb[item].system.password}, {'key': 'mongodb[' + item + '].offer.password', 'value': mongodb[item].offer.password}] }}"
14+
loop: "{{ offers_to_check }}"
15+
16+
- name: Check for weak passwords in mongo-data and collect failing keys
17+
set_fact:
18+
weak_password_keys: "{{ weak_password_keys | default([]) + ([item.key] if (item.value is search('(changeit|azerty|qwerty|1234$)')) else []) }}"
19+
loop:
20+
- { key: "mongodb[mongo-data].admin.password", value: "{{ mongodb['mongo-data'].admin.password }}" }
21+
- { key: "mongodb[mongo-data].localadmin.password", value: "{{ mongodb['mongo-data'].localadmin.password }}" }
22+
- { key: "mongodb[mongo-data].system.password", value: "{{ mongodb['mongo-data'].system.password }}" }
23+
- { key: "mongodb[mongo-data].metadata.password", value: "{{ mongodb['mongo-data'].metadata.password }}" }
24+
- { key: "mongodb[mongo-data].logbook.password", value: "{{ mongodb['mongo-data'].logbook.password }}" }
25+
- { key: "mongodb[mongo-data].report.password", value: "{{ mongodb['mongo-data'].report.password }}" }
26+
- { key: "mongodb[mongo-data].functionalAdmin.password", value: "{{ mongodb['mongo-data'].functionalAdmin.password }}" }
27+
- { key: "mongodb[mongo-data].securityInternal.password", value: "{{ mongodb['mongo-data'].securityInternal.password }}" }
28+
- { key: "mongodb[mongo-data].collect.password", value: "{{ mongodb['mongo-data'].collect.password }}" }
29+
- { key: "mongodb[mongo-data].metadataCollect.password", value: "{{ mongodb['mongo-data'].metadataCollect.password }}" }
30+
no_log: "{{ hide_passwords_during_deploy }}"
31+
32+
- name: Check for weak passwords in configured offers and collect failing keys
33+
set_fact:
34+
weak_password_keys: "{{ weak_password_keys | default([]) + ([item.key] if (item.value is search('(changeit|azerty|qwerty|1234$)')) else []) }}"
35+
loop: "{{ offer_password_checks }}"
36+
no_log: "{{ hide_passwords_during_deploy }}"
37+
38+
- name: Fail if any weak passwords are found
39+
fail:
40+
msg: "The following passwords are not properly updated for production deployment: {{ weak_password_keys | join(', ') }}"
41+
when: weak_password_keys | length > 0
42+
ignore_errors: "{{ true if deployment_mode | default('prod') == 'dev' else false }}"
43+
44+
run_once: true

deployment/ansible-vitam-exploitation/roles/checks/tasks/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
- import_tasks: check_ip.yml
88

9+
- import_tasks: check_passwords.yml
10+
911
- import_tasks: check_groups.yml
1012
when: ansible_virtualization_type not in ['docker', 'container']
1113

1214
- import_tasks: check_single_vm.yml
1315

1416
- include_tasks: check_consul.yml
15-
when: inventory_hostname in groups['vitam']
17+
when: inventory_hostname in groups['vitam']
1618

1719
- include_tasks: check_offers.yml
1820
when: inventory_hostname in groups['hosts_storage_offer_default']

0 commit comments

Comments
 (0)