-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (91 loc) · 2.6 KB
/
dotnet-security-scan.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
# Copyright (c) Omar Boukli-Hacene. All rights reserved.
# Distributed under an MIT-style license that can be
# found in the LICENSE file.
# SPDX-License-Identifier: MIT
name: Security and package checks
on:
pull_request:
branches:
- main
paths:
- src/**
- test/**
push:
branches:
- main
paths:
- src/**
- test/**
schedule:
- cron: 10 22 * * 3
workflow_dispatch:
permissions: {}
jobs:
lint:
name: Security scan
runs-on: ubuntu-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
permissions:
contents: read
steps:
- name: Check out code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up .NET SDK
uses: actions/setup-dotnet@v4
with:
cache: true
cache-dependency-path: |-
src/**/packages.lock.json
test/**/packages.lock.json
global-json-file: global.json
- name: Install scanner
run: >-
dotnet tool install security-scan
--global
- name: Run dotnet security-scan
run: >-
security-scan Aktabook.sln
nuget:
name: NuGet security check
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up .NET SDK
uses: actions/setup-dotnet@v4
with:
cache: true
cache-dependency-path: |-
src/**/packages.lock.json
test/**/packages.lock.json
global-json-file: global.json
- name: Restores dependencies
env:
DOTNET_NUGET_SIGNATURE_VERIFICATION: true
run: dotnet restore --locked-mode
- name: Run NuGet security check
run: |-
dotnet list package --vulnerable 2>&1 | tee packages.txt
if grep --quiet --ignore-case "has the following vulnerable packages" packages.txt; then
echo "Found NuGet security advisory."
exit 1
else
echo "Success. No NuGet security advisory found."
fi
- name: Run NuGet security check for transitive packages
continue-on-error: true
run: |-
dotnet list package --vulnerable --include-transitive 2>&1 | tee transitive.txt
if grep --quiet --ignore-case "has the following vulnerable packages" transitive.txt; then
echo "Found NuGet security advisory."
exit 1
else
echo "Success. No NuGet security advisory found."
fi