-
Notifications
You must be signed in to change notification settings - Fork 141
142 lines (119 loc) · 3.83 KB
/
test-secure.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
######## Secure test cases. All of these use secure packages, and shouldn't fail. Easier than our insecure
######## case, as we don't need anything else. We test against Safety and its deps here; if these tests
######## fail, the pinned version might need to be updated.
name: Safety Action Secure Tests
on:
push:
branches: [main, develop]
jobs:
matrix:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- id: set-matrix
run: |
TASKS=$(echo $(cat .github/workflows/gh-action-integration-matrix.json) | sed 's/ //g' )
echo "::set-output name=matrix::$TASKS"
##### Auto mode tests
### File scanning
# Scans a requirements.txt in the repo; the simplest case. We contort one into existing for this test
# case, to avoid confusion
test-auto-requirements-txt-secure:
needs: [ matrix ]
runs-on: ubuntu-20.04
environment: main
strategy:
matrix:
safety: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ matrix.safety.version }}
- run: cp tests/action/requirements.txt-secure requirements.txt
- uses: ./
id: scan-1
args: -i 51358
with:
api-key: ${{ secrets.SAFETY_API_KEY }}
# Same as above, but for a poetry lock file
test-auto-poetry-secure:
needs: [ matrix ]
runs-on: ubuntu-20.04
environment: main
strategy:
matrix:
safety: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ matrix.safety.version }}
- run: cp tests/action/poetry.lock-secure poetry.lock && cp tests/action/pyproject.toml-secure pyproject.toml
- uses: ./
id: scan-2
args: -i 51358
with:
api-key: ${{ secrets.SAFETY_API_KEY }}
# Same as above, but for a Pipfile.lock
test-auto-pipfile-secure:
needs: [ matrix ]
runs-on: ubuntu-20.04
environment: main
strategy:
matrix:
safety: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ matrix.safety.version }}
- run: cp tests/action/Pipfile.lock-secure Pipfile.lock
- uses: ./
id: scan-3
args: -i 51358
with:
api-key: ${{ secrets.SAFETY_API_KEY }}
### Env scanning:
### Scans the runner environment. Here, the Github action `actions/setup-python@v3` actually
### installs things in the root VM that the action runs on; this is what gets scanned.
test-auto-environment-secure:
needs: [ matrix ]
runs-on: ubuntu-20.04
environment: main
strategy:
matrix:
safety: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ matrix.safety.version }}
- uses: actions/setup-python@v3
with:
python-version: '3.10'
architecture: 'x64'
- run: python -m pip install -r tests/action/requirements.txt-secure
- uses: ./
id: scan-4
args: -i 51358
with:
api-key: ${{ secrets.SAFETY_API_KEY }}
### Docker scanning:
### Scans a recently built Docker container. This uses a few heuristics, defined in entrypoint.sh
test-auto-docker-secure:
needs: [ matrix ]
runs-on: ubuntu-20.04
environment: main
strategy:
matrix:
safety: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ matrix.safety.version }}
- name: Build image
run: DOCKER_BUILDKIT=1 docker build -t my-secure-image tests/action/docker-secure
- uses: ./
id: scan-5
args: -i 51358
with:
api-key: ${{ secrets.SAFETY_API_KEY }}