-
Notifications
You must be signed in to change notification settings - Fork 2
/
sniffers.yml
255 lines (216 loc) · 9.94 KB
/
sniffers.yml
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
---
# This playbook should be executed using ansible-playbook command
# Developed for ansible version >= 1.7
- hosts: localhost
connection: local
gather_facts: no
vars:
# this variable will be overridden from jenkins.
workspace_root: .
artifacts_file: commentinfo.md
webroot: http://localhost
webroot_lily: http://lily.localhost
webroot_upgrade: http://localhost
webroot_install: http://localhost
installation_profile_name: openy
installation_profile_path: "profiles/{{ installation_profile_name }}"
scan_security: false
phpcs_extensions: php,module,inc,install,test,profile,theme
phpcs_features_extensions: module
custom_modules_path: modules/custom/
custom_themes_path: themes/custom
features_path: modules/features
phpcs_modules_ignore:
- themes/custom/nonstandard
- profiles/openy/modules/contrib
- profiles/openy/themes/contrib
- profiles/openy/themes/*.css
- profiles/openy/libraries
- profiles/openy/vendor
- profiles/openy/build
- profiles/openy/docroot
phpcs_features_ignore:
- modules/features/nonstandard
phpcs_features_ignore_path: modules/features,*.pages_default.inc,*.panelizer.inc,*.features.menu_custom.inc,*.features.webform.inc,*.features.filter.inc,*.strongarm.inc,*.fpp_content_declarations.inc,*.panels_default.inc
composer_dir: /usr/share/composer
phpcs_bin: /usr/bin/phpcs
build_reports_dir: build_reports
composer_global_require:
- squizlabs/php_codesniffer=dev-master
- drupal/coder:8.2.*
git_repos:
- { branch: 'master', repo: 'https://github.com/podarok/phpcs-security-audit.git', name: 'Security' } #git clone --branch master https://github.com/podarok/phpcs-security-audit.git Security
- { branch: 'master', repo: 'https://github.com/podarok/Symfony2-coding-standard.git', name: 'Symfony2' }
phpcs_standards:
- { path: 'vendor/drupal/coder/coder_sniffer/Drupal', name: 'Drupal' } #/root/.composer/vendor/drupal/coder/coder_sniffer/Drupal Drupal
- { path: 'vendor/podarok/Security/Security', name: 'Security' } #/root/.composer/vendor/podarok/Security Security
npm_packages:
- jshint
gem_packages:
- scss-lint
sniffers_apt_repos:
- ppa:chris-lea/node.js
sniffers_apt_packages:
- ruby1.9.1
- ruby1.9.1-dev
- rubygems1.9.1
- irb1.9.1
- ri1.9.1
- rdoc1.9.1
- build-essential
- libopenssl-ruby1.9.1
- libssl-dev
- zlib1g-dev
- nodejs
jshint_folders:
- { name: 'custom_modules', path: "{{ installation_profile_path }}/modules/custom" }
- { name: 'custom_themes', path: "{{ installation_profile_path }}/themes/custom" }
- { name: 'openy_features', path: "{{ installation_profile_path }}/modules/openy_features" }
- { name: 'openy_themes', path: "{{ installation_profile_path }}/themes/openy_themes" }
scsslint_folders:
- { name: 'themes', path: 'themes/custom' }
sniffers_update: true
roles:
- { role: devops/roles/cibox-security-testing, when: scan_security == true }
pre_tasks:
- name: Was composer downloaded
become: yes
stat: path={{ composer_dir }}
register: is_composer_dir
when: sniffers_update == true
- name: Install apt repos
apt_repository: repo={{ item }}
loop: "{{ sniffers_apt_repos }}"
become: yes
when: sniffers_update == true
tags:
- nodejs
- name: Update apt cache
become: yes
apt: update_cache=yes
ignore_errors: yes
when: sniffers_update == true
- name: Install apt packages
apt: name={{ item }} state=present
loop: "{{ sniffers_apt_packages }}"
become: yes
when: sniffers_update == true
tags:
- sniffers
- composer
- git
- name: Prepare directory for global composer libs
become: yes
file: path={{ composer_dir }} state=directory
when: sniffers_update == true and is_composer_dir.stat.exists == false
tags:
- sniffers
- name: Ensure composer files are absent
become: yes
file:
path: "{{ composer_dir }}/{{ item }}"
state: absent
loop:
- composer.lock
- composer.json
- name: Install composer global requires
become: yes
shell: "cd {{ composer_dir }} && composer require --prefer-dist {{ item }}"
loop: "{{ composer_global_require }}"
when: sniffers_update == true
tags:
- sniffers
- composer
- git
- name: Install global git repos
become: yes
git: repo={{ item.repo }} dest={{ composer_dir }}/vendor/podarok/{{ item.name }} version={{ item.branch }}
loop: "{{ git_repos }}"
when: sniffers_update == true
tags:
- sniffers
- git
- name: Install php codesniffer standards
become: yes
file: src={{ composer_dir }}/{{ item.path }} dest={{ composer_dir }}/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/{{ item.name }} state=link
loop: "{{ phpcs_standards }}"
when: sniffers_update == true
tags:
- sniffers
- git
- name: Fix permissions for composer libs
become: yes
file: path={{ composer_dir }} state=directory mode=655 recurse=yes
when: sniffers_update == true
- name: Create symlink to phpcs binary
become: yes
file: src={{ composer_dir }}/vendor/bin/phpcs dest={{ phpcs_bin }} state=link mode=655 force=yes
when: sniffers_update == true
- name: Install nodejs packages
become: yes
npm: name={{ item }} global=yes
loop: "{{ npm_packages }}"
when: sniffers_update == true
- name: Update ruby alternatives for using ruby 1.9.1(3) version
become: yes
shell: "update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby1.9.1.1.gz --slave /usr/bin/ri ri /usr/bin/ri1.9.1 --slave /usr/bin/irb irb /usr/bin/irb1.9.1 --slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1"
when: sniffers_update == true and is_composer_dir.stat.exists == false
tags:
- sniffers
- ruby
- name: Install gem packages
shell: "gem install {{ item }}"
loop: "{{ gem_packages }}"
ignore_errors: yes
become: yes
when: sniffers_update == true
tags:
- sniffers
- gem
- ruby
tasks:
- name: Create directory for build reports
become: yes
file: path={{ build_reports_dir }} state=directory mode=0777
- name: PHP CodeSniffer run
shell: '{{ phpcs_bin }} --standard={{ item.name }} --extensions={{ phpcs_extensions }} -n {{ installation_profile_path }} --report-file={{ build_reports_dir }}/{{ item.name }}sniff.txt --ignore={{ phpcs_modules_ignore | join(",") }} || true'
loop: "{{ phpcs_standards }}"
- name: PHP CodeSniffer reports build
ignore_errors: yes
shell: 'if grep "FOUND" {{ build_reports_dir }}/{{ item.name }}sniff.txt; then echo "<strong>`grep -o "\<\| ERROR \|\>" {{ build_reports_dir }}/{{ item.name }}sniff.txt | wc -l`</strong> errors for CodeSniffer: {{ item.name }} standard file {{ webroot }}/{{ build_reports_dir }}/{{ item.name }}sniff.txt" >> {{ workspace_root }}/{{ artifacts_file }} && exit 1; fi;'
loop: "{{ phpcs_standards }}"
- name: JSHint run
shell: 'sudo jshint {{ item.path }} --exclude-path={{ installation_profile_path }}/.jshintignore > {{ build_reports_dir }}/{{ item.name }}jshint.txt || true'
loop: "{{ jshint_folders }}"
- name: JSHint build reports
ignore_errors: yes
shell: 'if [ -s {{ build_reports_dir }}/{{ item.name }}jshint.txt ]; then echo "<strong>`wc -l < {{ build_reports_dir }}/{{ item.name }}jshint.txt`</strong> JSHint: {{ item.name }} standard file {{ webroot }}/{{ build_reports_dir }}/{{ item.name }}jshint.txt" >> {{ workspace_root }}/{{ artifacts_file }} && exit 1; fi'
loop: "{{ jshint_folders }}"
#- name: SCSS lint run
# shell: 'find {{ item.path }} -name "*.scss" -print0 | xargs -0 -r scss-lint > {{ build_reports_dir }}/scsslint{{ item.name }}.txt || true'
# loop: scsslint_folders
#- name: SCSS lint build reports
# ignore_errors: yes
# shell: 'if grep -o "\<[E]\>" {{ build_reports_dir }}/scsslint{{ item.name }}.txt; then echo "<strong>`grep -o "\<[E]\>" {{ build_reports_dir }}/scsslint{{ item.name }}.txt | wc -l`</strong> errors for SCSS-lint {{ item.name }} standard file {{ webroot }}/{{ build_reports_dir }}/scsslint{{ item.name }}.txt" >> {{ workspace_root }}/{{ artifacts_file }} && exit 1; fi'
# loop: scsslint_folders
- name: Create response table
become: yes
lineinfile: dest={{ workspace_root }}/{{ artifacts_file }} line=" " create=yes state=present
- name: Create response table
become: yes
lineinfile: dest={{ workspace_root }}/{{ artifacts_file }} line="| Environment | Link |" create=yes state=present
- name: Create response table
become: yes
lineinfile: dest={{ workspace_root }}/{{ artifacts_file }} line="| ------------- | ------------- |" create=yes state=present
- name: Fresh OpenY based on profile - Rose
become: yes
lineinfile: dest={{ workspace_root }}/{{ artifacts_file }} line="| Fresh OpenY installation - Rose theme | {{ webroot }} |" create=yes state=present
- name: Fresh OpenY based on profile - Lily
become: yes
lineinfile: dest={{ workspace_root }}/{{ artifacts_file }} line="| Fresh OpenY installation - Lily theme | {{ webroot_lily }} |" create=yes state=present
- name: Upgraded(upgrade path) OpenY based on latest release
become: yes
lineinfile: dest={{ workspace_root }}/{{ artifacts_file }} line="| Upgraded(upgrade path) installation | {{ webroot_upgrade }} |" create=yes state=present
- name: Installation process
become: yes
lineinfile: dest={{ workspace_root }}/{{ artifacts_file }} line="| Installation process | {{ webroot_install }}/install.php |" create=yes state=present