summaryrefslogtreecommitdiff
path: root/test/integration/targets/win_audit_rule/tasks/modify.yml
blob: 1db07e2b4ae0c7be3131abaeac02e95b9eda6dee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#########################
### modify check mode ###
#########################
- name: check mode modify audit policy directory
  win_audit_rule:
    path: "{{ test_audit_rule_folder }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    state: present
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: directory
  check_mode: yes

- name: check mode modify audit policy file
  win_audit_rule:
    path: "{{ test_audit_rule_file }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    state: present
    audit_flags: "{{ test_audit_rule_audit_flags }}"
    inheritance_flags: none
  register: file
  check_mode: yes

- name: check mode modify audit policy registry
  win_audit_rule:
    path: "{{ test_audit_rule_registry }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    state: present
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: registry
  check_mode: yes

- name: check mode modify get directory rule results
  test_get_audit_rule:
    path: "{{ test_audit_rule_folder }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: directory_results

- name: check mode modify get file rule results
  test_get_audit_rule:
    path: "{{ test_audit_rule_file }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    audit_flags: "{{ test_audit_rule_audit_flags }}"
    inheritance_flags: none
  register: file_results

- name: check mode modify get REGISTRY rule results
  test_get_audit_rule:
    path: "{{ test_audit_rule_registry }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: registry_results

- name: check mode modify assert that change is needed but rights still equal the original rights and not test_audit_rule_new_rights
  assert:
    that:
    - directory is changed
    - file is changed
    - registry is changed
    - not directory_results.matching_rule_found and directory_results.path_type == 'directory'
    - not file_results.matching_rule_found and file_results.path_type == 'file'
    - not registry_results.matching_rule_found and registry_results.path_type == 'registry'

##############
### modify ###
##############
- name: modify audit policy directory
  win_audit_rule:
    path: "{{ test_audit_rule_folder }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    state: present
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: directory

- name: modify audit policy file
  win_audit_rule:
    path: "{{ test_audit_rule_file }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    state: present
    audit_flags: "{{ test_audit_rule_audit_flags }}"
    inheritance_flags: none
  register: file

- name: modify audit policy registry
  win_audit_rule:
    path: "{{ test_audit_rule_registry }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    state: present
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: registry

- name: modify get directory rule results
  test_get_audit_rule:
    path: "{{ test_audit_rule_folder }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: directory_results

- name: modify get file rule results
  test_get_audit_rule:
    path: "{{ test_audit_rule_file }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    audit_flags: "{{ test_audit_rule_audit_flags }}"
    inheritance_flags: none
  register: file_results

- name: modify get REGISTRY rule results
  test_get_audit_rule:
    path: "{{ test_audit_rule_registry }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: registry_results

- name: modify assert that the rules were modified and a change is detected
  assert:
    that:
    - directory is changed
    - file is changed
    - registry is changed
    - directory_results.matching_rule_found and directory_results.path_type == 'directory'
    - file_results.matching_rule_found and file_results.path_type == 'file'
    - registry_results.matching_rule_found and registry_results.path_type == 'registry'

#####################################
### idempotent test modify a rule ###
#####################################
- name: idempotent modify audit policy directory
  win_audit_rule:
    path: "{{ test_audit_rule_folder }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    state: present
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: directory

- name: idempotent modify audit policy file
  win_audit_rule:
    path: "{{ test_audit_rule_file }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    state: present
    audit_flags: "{{ test_audit_rule_audit_flags }}"
    inheritance_flags: none
  register: file

- name: idempotent modify audit policy registry
  win_audit_rule:
    path: "{{ test_audit_rule_registry }}"
    user: "{{ test_audit_rule_user }}"
    rights: "{{ test_audit_rule_new_rights }}"
    state: present
    audit_flags: "{{ test_audit_rule_audit_flags }}"
  register: registry

- name: idempotent modify assert that and a change is not detected
  assert:
    that:
    - directory is not changed and directory.path_type == 'directory'
    - file is not changed and file.path_type == 'file'
    - registry is not changed and registry.path_type == 'registry'