-
Notifications
You must be signed in to change notification settings - Fork 44
/
appveyor.yml
190 lines (182 loc) · 9.52 KB
/
appveyor.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
---
version: 0.1.x.{build}
skip_commits:
message: /^\(?doc|travis\)?.*/
clone_depth: 10
init:
- SET
- 'echo System architecture: %PLATFORM%'
- 'echo %APPVEYOR_REPO_NAME%'
environment:
winrm_user: winrm_test_user
winrm_password: WinRM_test_Pass@w0rd1
APPVEYOR_RDP_PASSWORD: WinRM_test_Pass@w0rd1
user_cert: c:\projects\ansible-harden-windows\user.pem
user_key: c:\projects\ansible-harden-windows\key.pem
user_pfx: c:\projects\ansible-harden-windows\user.pfx
CYGWIN: winsymlinks:nativestrict
matrix:
- SUITE: default
ANSIBLE_VERSION: 5.3.0
ANSIBLE_EXTRA_VARS:
TARGET: cygwin64
CYG_ROOT: C:\cygwin64
CYG_SETUP: C:\cygwin64\setup-x86_64.exe
CYG_CACHE: C:\cygwin64\var\cache\setup
CYG_BASH: C:\cygwin64\bin\sh
- SUITE: default
ANSIBLE_VERSION: 4.10.0
ANSIBLE_EXTRA_VARS:
TARGET: cygwin64
CYG_ROOT: C:\cygwin64
CYG_SETUP: C:\cygwin64\setup-x86_64.exe
CYG_CACHE: C:\cygwin64\var\cache\setup
CYG_BASH: C:\cygwin64\bin\sh
- SUITE: default-HEAD
ANSIBLE_VERSION: 5.3.0
ANSIBLE_EXTRA_VARS:
TARGET: cygwin64
CYG_ROOT: C:\cygwin64
CYG_SETUP: C:\cygwin64\setup-x86_64.exe
CYG_CACHE: C:\cygwin64\var\cache\setup
CYG_BASH: C:\cygwin64\bin\sh
- SUITE: full
ANSIBLE_VERSION: 5.3.0
ANSIBLE_EXTRA_VARS:
TARGET: cygwin64
CYG_ROOT: C:\cygwin64
CYG_SETUP: C:\cygwin64\setup-x86_64.exe
CYG_CACHE: C:\cygwin64\var\cache\setup
CYG_BASH: C:\cygwin64\bin\sh
matrix:
fast_finish: true
install:
# setup winrm
- ps: net user /Y /add $env:winrm_user $env:winrm_password
- ps: net localgroup administrators $env:winrm_user /add
- ps: $env:PATH="C:\OpenSSL-Win64\bin;$env:PATH"
- ps: Import-Module $env:APPVEYOR_BUILD_FOLDER\test\appveyor\WinrmAppveyor.psm1
- ps: New-ClientCertificate $env:winrm_user $env:APPVEYOR_BUILD_FOLDER
- ps: $env:user_cert_thumb = (Import-pfxCertificate -FilePath $env:user_pfx -CertStoreLocation Cert:\LocalMachine\root).Thumbprint
- ps: Import-pfxCertificate -FilePath $env:user_pfx -CertStoreLocation Cert:\LocalMachine\TrustedPeople
- ps: $env:winrm_cert = (New-SelfSignedCertificate -DnsName localhost -CertStoreLocation cert:\localmachine\my).Thumbprint
- ps: winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname=`"localhost`";CertificateThumbprint=`"$($env:winrm_cert)`"}"
- ps: winrm set winrm/config/client/auth '@{Basic="true"}'
- ps: winrm set winrm/config/service/auth '@{Basic="true"}'
- ps: winrm set winrm/config/service/auth '@{Certificate="true"}'
- ps: winrm set winrm/config/service/auth '@{CbtHardeningLevel="Strict"}'
- ps: winrm set winrm/config/service '@{AllowUnencrypted="true"}'
- ps: New-WinrmUserCertificateMapping $env:user_cert_thumb
- ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
- ps: Write-Host $env:PATH
- ps: ($pwd).path
- ps: |
Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
# [Cygwin setup.exe update #3820](https://github.com/appveyor/ci/issues/3820)
# download installer
- ps: |
New-Item -Path C:\cygwin -ItemType Directory -Force
$exePath = "C:\cygwin\setup-x86.exe"
(New-Object Net.WebClient).DownloadFile('https://cygwin.com/setup-x86.exe', $exePath)
# install cygwin
- cmd: |
"C:\cygwin\setup-x86.exe" -qnNdO -R C:/cygwin -s http://cygwin.mirror.constant.com -l C:/cygwin/var/cache/setup -P mingw64-i686-gcc-g++ -P mingw64-x86_64-gcc-g++ -P gcc-g++ -P autoconf -P automake -P bison -P libtool -P make -P python2 -P python -P python38 -P gettext-devel -P intltool -P libiconv -P pkg-config -P wget -P curl -P libssl-devel -P python2-devel -P python3-devel -P python-jinja -P python-crypto -P python-openssl -P python-setuptools -P git -P libffi -P libffi-devel -P libcrypt-devel -P openssl-devel -P python38-cryptography"
C:\Cygwin\bin\bash -lc true
C:\cygwin\bin\cygcheck -c | C:\cygwin\bin\grep cygwin
C:\cygwin\bin\gcc --version
# setup ansible
- cmd: "%CYG_BASH% -lc 'openssl version'"
- cmd: "%CYG_BASH% -lc 'uname -a'"
- cmd: "%CYG_BASH% -lc 'python -m ensurepip'"
- cmd: "%CYG_BASH% -lc 'python3 -m ensurepip'"
- cmd: "%CYG_BASH% -lc 'python3 -m pip install cryptography==3.3.2'"
- cmd: "%CYG_BASH% -lc 'python3 -m pip install --upgrade pip'"
- cmd: "%CYG_BASH% -lc 'python3 -m pip install pywinrm'"
- cmd: "%CYG_BASH% -lc 'python3 -m pip install ansible==%ANSIBLE_VERSION%'"
- cmd: "%CYG_BASH% -lc 'ansible --version'"
- cmd: "%CYG_BASH% -lc 'echo localhost ansible_user=$winrm_user ansible_password=$winrm_password ansible_connection=winrm'"
# - cmd: "%CYG_BASH% -lc 'echo localhost ansible_user=$winrm_user ansible_password=$winrm_password ansible_connection=winrm > inventory'"
# - cmd: "%CYG_BASH% -lc 'cat inventory'"
# - cmd: "%CYG_BASH% -lc 'echo localhost ansible_user=$winrm_user ansible_password=$winrm_password ansible_connection=winrm | tee inventory'"
# - cmd: "%CYG_BASH% -lc 'cat inventory'"
# - ps: echo "localhost ansible_user=$env:winrm_user ansible_password=$env:winrm_password ansible_connection=winrm" | Out-file c:\inventory
# - ps: Get-ChildItem -Path c:\
# - ps: Get-Content -Path c:\inventory
# - ps: |
# $filepath = "C:\inventory"
# $Acl = Get-ACL $filepath
# $AccessRule= New-Object System.Security.AccessControl.FileSystemAccessRule("everyone","full","none","none","Allow")
# $Acl.AddAccessRule($AccessRule)
# Set-Acl $filepath $Acl
- cmd: "%CYG_BASH% -lc 'ls /'"
- cmd: "%CYG_BASH% -lc 'ls -l /cygdrive/c/'"
# - cmd: "%CYG_BASH% -lc 'cat /cygdrive/c/inventory'"
- cmd: "%CYG_BASH% -lc 'ls -l /cygdrive/c/projects/ansible-harden-windows'"
- cmd: "%CYG_BASH% -lc pwd"
# - cmd: "%CYG_BASH% -lc env"
# - cmd: "%CYG_BASH% -lc 'find -ls'"
- cmd: "%CYG_BASH% -lc 'ansible -i /cygdrive/c/projects/ansible-harden-windows/test/appveyor/inventory -m win_ping -vvv localhost'"
# NOK
# - cmd: "%CYG_BASH% -lc 'ln -s /cygdrive/c/projects/ansible-harden-windows /etc/ansible/roles/juju4.harden-windows'"
- cmd: "%CYG_BASH% -lc 'mkdir -p /etc/ansible/roles'"
- cmd: "%CYG_BASH% -lc 'cp /cygdrive/c/projects/ansible-harden-windows/test/appveyor/ansible.cfg /etc/ansible'"
- cmd: "%CYG_BASH% -lc 'cp -R /cygdrive/c/projects/ansible-harden-windows /etc/ansible/roles/juju4.harden-windows'"
- cmd: "%CYG_BASH% -lc 'sh -x /cygdrive/c/projects/ansible-harden-windows/get-dependencies.sh'"
build: off
test_script:
- cmd: "%CYG_BASH% -lc 'ansible-playbook /cygdrive/c/projects/ansible-harden-windows/test/integration/$SUITE/default.yml --syntax-check'"
- cmd: "%CYG_BASH% -lc 'ansible-playbook -i /cygdrive/c/projects/ansible-harden-windows/test/appveyor/inventory /cygdrive/c/projects/ansible-harden-windows/test/integration/$SUITE/default.yml -vvv $ANSIBLE_EXTRA_VARS'"
for:
- matrix:
only:
- SUITE: default
after_test:
# Test idempotence
# %CYG_BASH% -lc 'ansible-playbook -i /cygdrive/c/projects/ansible-harden-windows/test/appveyor/inventory /cygdrive/c/projects/ansible-harden-windows/test/integration/$SUITE/default.yml $ANSIBLE_EXTRA_VARS | tee /tmp/idempotency.log | grep -q "changed=0.*failed=0" && (echo "Idempotence test: pass" && exit 0) || (echo "Idempotence test: fail" && cat /tmp/idempotency.log && exit 0)'
- cmd: |
%CYG_BASH% -lc 'ansible-playbook -i /cygdrive/c/projects/ansible-harden-windows/test/appveyor/inventory /cygdrive/c/projects/ansible-harden-windows/test/integration/$SUITE/default.yml $ANSIBLE_EXTRA_VARS'
- cmd: cinst -y notepadplusplus
on_failure:
# - ps: |
# Get-Content -Path C:\windows\TEMP\chocolatey\KB3035131.Install.evt
# True
# - ps: |
# Get-Content -Path C:\windows\Logs\CBS\CBS.log
# True
# - ps: |
# Get-Content -Path C:\ProgramData\chocolatey\logs\chocolatey.log
# True
# - ps: Get-ChildItem -Recurse -Path "c:\Program Files\ansible"
- ps: |
Get-WinEvent -LogName 'Microsoft-Windows-AppLocker/EXE and DLL' | Where { $_.ID -eq 8004 }
True
- cmd: "%CYG_BASH% -lc 'ansible -i /cygdrive/c/projects/ansible-harden-windows/test/appveyor/inventory -m setup -vvv localhost'"
on_finish:
- ps: |
Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.hta" -Recurse
- ps: |
Get-PSDrive -PSProvider Registry
New-PSDrive -Name HKCR -PSProvider Registry -Root Registry::HKEY_CLASSES_ROOT
Get-ChildItem -Path "HKCR:\htafile\shell\open\command" -Recurse
- ps: |
Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
- ps: |
New-PSDrive -Name HKU -PSProvider Registry -Root Registry::HKEY_USERS
Get-ChildItem -Path "HKU:\*\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.hta" -Recurse
- ps: |
#Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\COM Compatibility\{0002CE02-0000- 0000-C000-000000000046}"
Get-ChildItem -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server"
#Get-Eventlog -LogName security -Newest 100 -EntryType FailureAudit
True
- ps: |
Get-Content -Path c:\ProgramData\ansible\log\densityscout-results.txt
True
- cmd: c:\opscode\inspec\bin\inspec.bat --chef-license accept || exit 0
- cmd: c:\opscode\inspec\bin\inspec.bat exec %APPVEYOR_BUILD_FOLDER%\test\inspec --attrs %APPVEYOR_BUILD_FOLDER%\test\inspec\profile-attributes-Windows.yml | tee c:\inspec.log || exit 0
notifications:
- provider: Email
to:
- nobody@nowhere.com
on_build_success: false
on_build_failure: false
on_build_status_changed: false