forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (99 loc) · 3.62 KB
/
windows.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
name: Windows Test
on: [pull_request]
jobs:
build:
name: Windows Test
runs-on: windows-2019
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Configure test environment
shell: cmd
if: always()
run: |
echo %PATH%
echo %GOPATH%
subst X: %CD%
mklink c:\Users\link c:\Windows
mkdir "C:\Program Files\Velociraptor"
mkdir c:\tmp
mkdir c:\adstest\test
echo "This is a test of a folder ADS! Its resident too!" > c:\adstest\test:test.txt
echo Hello > C:\hello.txt
echo HelloADS > C:\hello.txt:myads
fsutil file setshortname C:\hello.txt hi.txt
wevtutil.exe cl System
sc.exe create TestingDetection1 binPath="%COMSPEC% /Q /c echo 'COMSPEC testing 1"
echo "VSStest" > c:\Users\test.txt
echo "VSStest2" > c:\Users\test2.txt
regedit /S artifacts/testdata/windows/init.reg
- name: Build
if: always()
env:
CC: x86_64-w64-mingw32-gcc
shell: bash
run: |
go run make.go -v WindowsTest
- name: Prepare second stage
if: always()
shell: cmd
# We have to wait a short time between the service creation
# event to be flushed to disk. Hopefully building the test
# binary takes long enough.
# Creating a second service - in the end we have
# TestingDetection2 in current logs, TestingDetection1 in
# previously cleared logs (but in VSS).
run: |
vssadmin create shadow /for=c:
echo "VSStest2 with more data" > c:\Users\test2.txt
echo Clearing the event logs
wevtutil.exe cl System
echo Create second service.
sc.exe create TestingDetection2 binPath="%COMSPEC% /Q /c echo 'COMSPEC testing 2"
- name: Test
shell: bash
if: always()
env:
# Disable CGO for building tests - it takes too long and it is
# not needed (mainly disables Yara building again).
CGO_ENABLED: "0"
run: |
# Only run short tests on CI because the CI machines are slow
go test -short -v ./... --tags server_vql -p 2
- name: Test Golden Generic
shell: cmd
if: always()
# We depend on the second service logs to be flushed to disk -
# hopefulling the unit tests take long enough for this to
# happen.
# Create a second VSS right before testing - in most cases the
# second VSS is identical to C: and VSS artifacts should
# **always** prefer to emit C: based locations over VSS paths.
run: |
vssadmin create shadow /for=c:
echo Running OS generic tests.
output\velociraptor.exe -v golden X:\artifacts\testdata\server\testcases\ --env srcDir=X:\ --config X:\artifacts\testdata\windows\github_actions.config.yaml
- name: Test Golden Windows
shell: cmd
if: always()
run: |
echo Running windows specific tests.
output\velociraptor.exe -v golden X:\artifacts\testdata\windows\ --env srcDir=X:\ --config X:\artifacts\testdata\windows\github_actions.config.yaml
- name: Upload Build Artifacts
if: always()
shell: bash
run: |
mkdir -p artifact_output/windows/
cp artifacts/testdata/windows/*.out* artifact_output/windows/
mkdir -p artifact_output/server/
cp artifacts/testdata/server/testcases/*.out* artifact_output/server/
- uses: actions/upload-artifact@v3
if: always()
with:
name: artifact
path: artifact_output