Skip to content

Commit 8e224e1

Browse files
committed
ci: integrate Syft and Grype for SBOM management
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent cf69e3d commit 8e224e1

File tree

5 files changed

+96
-25
lines changed

5 files changed

+96
-25
lines changed

.github/DEVELOP.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [Linter](#linter)
2323
- [Formater](#formater)
2424
- [Dead code](#dead-code)
25+
- [Software Bill of Materials](#software-bill-of-materials)
2526
- [CI/CD](#cicd)
2627
- [Update 3rd parties](#update-3rd-parties)
2728

@@ -79,6 +80,14 @@ brew install xcodesorg/made/xcodes
7980
# For git-cliff (at least 2.8.0)
8081
brew install git-cliff
8182

83+
84+
# For Syft (at least 1.26.1)
85+
brew install syft
86+
87+
# For Grype (at least 0.92.2)
88+
brew tap anchore/grype
89+
brew install grype
90+
8291
# For LicensePlist (at least 3.27.1)
8392
brew install licenseplist
8493
```
@@ -483,6 +492,18 @@ And run:
483492
bundle exec fastlane check_dead_code
484493
```
485494

495+
## Software Bill of Materials
496+
497+
For software quality reasons, intellectual property compliance, users trust and legal oblgitations with Cyber Resilience Act (CRA) and NIS2, it it interesing or mandatory to keep updated a Software Bill Of Materials (SBOM). And with such file listing dependencies in several levels we are able to make scans of them and check if there are known vulnerabilities.
498+
499+
To do these operations, we use [Syft](https://github.com/anchore/syft) to generate a SBOM in CycloneDX format, which will processed by [Grype](https://github.com/anchore/grype) to check if there are known vulnerabilities.
500+
501+
These operations, triggered in CLI, are wrapped in a Fastlane command:
502+
503+
```shell
504+
bundle exec fastlane update_sbom
505+
```
506+
486507
## CI/CD
487508

488509
### GitHub Action

DesignToolbox/fastlane/Fastfile

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ platform :ios do
9191
# ------------------------------------------------------------
9292
# RUN PERIPHERY FOR DEAD CODE ANALYSIS
9393
# ------------------------------------------------------------
94-
desc "RUN PERIPHERY FOR DEAD CODE ANALYSIS"
94+
desc "Run Periphery to look dor dead code in the code base. Avoid strict mode because some false positive remains and command must be fine-tuned."
9595
lane :check_dead_code do
9696
puts "👉 Check dead code with Periphery"
9797

@@ -101,7 +101,7 @@ platform :ios do
101101
# ------------------------------------------------------------
102102
# RUN SWIFT FORMAT TO FORMAT SOURCES
103103
# ------------------------------------------------------------
104-
desc "RUN SWIFT FORMAT TO FORMAT SOURCES"
104+
desc "Run SwiftFormat to format Swift source files according to the local configuration."
105105
lane :format do
106106
puts "👉 Run Swift Format to format sources"
107107

@@ -112,7 +112,7 @@ platform :ios do
112112
# ------------------------------------------------------------
113113
# RUN SWIFT LINT TO CHECK SMELLS
114114
# ------------------------------------------------------------
115-
desc "RUN SWIFT LINT TO CHECK SMELLS"
115+
desc "Run SwiftLint in strict mode to detect code smells"
116116
lane :lint do
117117
puts "👉 Run Swift Lint for smells"
118118

@@ -123,7 +123,7 @@ platform :ios do
123123
# ------------------------------------------------------------
124124
# RUN LICENSE-PLSIT FOR 3RD PARTIES UPDATES
125125
# ------------------------------------------------------------
126-
desc "RUN LICENSEPLIST TO UPDATE LIST OF THIRD PARTIES"
126+
desc "Run LicensePlist to update list of third-parties"
127127
lane :update_3rd_parties do
128128
puts "👉 Run LicensePlist to update list of third-parties"
129129

@@ -141,14 +141,34 @@ platform :ios do
141141
# ------------------------------------------------------------
142142
# RUN GITLEAKS FOR SECET LEAKS SCAN
143143
# ------------------------------------------------------------
144-
desc "RUN GITLEAKS FOR SECET LEAKS SCAN"
144+
desc "Run GitLeaks to look for leaks of secrets in project and Git history"
145145
lane :check_leaks do
146146
puts "👉 Run Gitleaks for leaks scan"
147147

148148
# If there are violations, non 0 error be returned by swiftlint, making Fastlane fail (expected)
149149
sh "cd .. && gitleaks detect -v -l debug --source ."
150150
end
151151

152+
# ------------------------------------------------------------
153+
# RUN SYFT AND GRYPE TO BUILD AND ANALYSE SBOM
154+
# ------------------------------------------------------------
155+
desc "Generates a SBOM (Software Bill Of Materials) in CycloneDX format with Syft and analsye it with Grype to as to check for vulnerabilities"
156+
lane :update_sbom do
157+
puts "👉 Run Syft to generate the SBOM"
158+
159+
sbomFormat = "cyclonedx-json"
160+
# In { negligible, low, medium, high, critical }
161+
vulnerabilitiesTolerance = "negligible"
162+
163+
Dir.chdir "../.." do
164+
# Run the command to generate SBOM
165+
sh "syft . -o #{sbomFormat} > SBOM.json"
166+
167+
# Process the SBOM
168+
sh "grype sbom:./SBOM.json --fail-on #{vulnerabilitiesTolerance}"
169+
end
170+
end
171+
152172
# ------------------------------------------------------------
153173
# UPDATE BUILD NUMBER WITH TIMESTAMP
154174
# ------------------------------------------------------------
@@ -168,7 +188,7 @@ platform :ios do
168188
# -------------------
169189
# RUN SNAPSHOTS TESTS
170190
# -------------------
171-
desc "RUN SNAPSHOTS TESTS BY TRIGGERING THE TESTS PLANS OF THE PROJECT"
191+
desc "Run snapshots tests in the demo app to look for visual regressions of components defined in OUDS package"
172192
lane :test_snapshots do
173193
puts "👉 Run UI tests"
174194

@@ -199,7 +219,7 @@ platform :ios do
199219
# ------------
200220
# RUN UI TESTS
201221
# ------------
202-
desc "RUN UI TESTS BY TRIGGERING THE TESTS PLANS OF THE PROJECT"
222+
desc "Run UI tests in the demo app to check some specific components behaviors"
203223
lane :test_ui do
204224
puts "👉 Run UI tests"
205225

@@ -230,7 +250,7 @@ platform :ios do
230250
# ------------------------------------------------------------
231251
# BUILD DEBUG APP
232252
# ------------------------------------------------------------
233-
desc "BUILD DEBUG APP"
253+
desc "Build locally the demo app in debug mode without upload"
234254
lane :buildDebugApp do
235255
puts "👉 Build debug app"
236256

@@ -258,7 +278,7 @@ platform :ios do
258278
# ------------------------------------------------------------
259279
# BUILD & UPLOAD TO TESTFLIGHT ALPHA APP
260280
# ------------------------------------------------------------
261-
desc "BUILD & UPLOAD TO TESTFLIGHT ALPHA APP"
281+
desc "Build the demo app in alpha mode and upload to TestFlight"
262282
lane :alpha do |params|
263283
issues_numbers = params[:issueNumber]
264284
puts "👉 Alpha (commit hash = '#{params[:commitHash]}', issue number = '#{issues_numbers}')"
@@ -298,7 +318,7 @@ platform :ios do
298318
# ------------------------------------------------------------
299319
# BUILD & UPLOAD TO TESTFLIGHT BETA APP
300320
# ------------------------------------------------------------
301-
desc "BUILD & UPLOAD TO TESTFLIGHT BETA APP"
321+
desc "Build the demo app in neta mode and upload to TestFlight"
302322
lane :beta do |params|
303323
puts "👉 Beta (commit hash = '#{params[:commitHash]}')"
304324
Dir.chdir "../#{OUDS_PROJECT_NAME}/Resources/Assets.xcassets" do
@@ -335,7 +355,7 @@ platform :ios do
335355
# ------------------------------------------------------------
336356
# BUILD & UPLOAD TO STORE STABLE APP
337357
# ------------------------------------------------------------
338-
desc "BUILD & UPLOAD TO STORE (if set in options: upload) STABLE APP"
358+
desc "Build the demo app in stable mode and, if defined, upload to internal portal for App Store publication"
339359
lane :stable do |params|
340360
puts "👉 Stable"
341361

@@ -376,6 +396,7 @@ platform :ios do
376396
# -----------------------------------------------------------------------
377397
# PRIVATE LANE BUILD & UPLOAD (ALPHA / BETA is set by main lane)
378398
# -----------------------------------------------------------------------
399+
desc "Build the demo app in a defined mode and upload if needed to TestFlight or internal portal for App Store publication"
379400
private_lane :build_and_upload do |params|
380401
isAlpha = params[:isAlpha]
381402

@@ -420,7 +441,7 @@ platform :ios do
420441
# -----------------------------------------------------------------------
421442
# PRIVATE LANE BUILD (ALPHA / BETA / STABLE is set by main lane)
422443
# -----------------------------------------------------------------------
423-
desc "PRIVATE LANE BUILD (ALPHA / BETA / STABLE is set by main lane)"
444+
desc "Build the demo app"
424445
private_lane :build do
425446
puts "👉 Build"
426447

@@ -472,7 +493,7 @@ platform :ios do
472493
# --------------------------------------------------------------------------
473494
# PRIVATE LANE UPLOAD TO TESTFLIGHT (ALPHA / BETA is set by main lane)
474495
# ---------------------------------------------------------------------------
475-
desc "PRIVATE LANE UPLOAD TO TESTFLIGHT"
496+
desc "Upload the demo app to TestFlight"
476497
private_lane :upload_2_testflight do |params|
477498
puts "👉 Upload"
478499

@@ -525,7 +546,7 @@ platform :ios do
525546
# ----------------------------
526547
# PRIVATE LANE UPLOAD TO STORE
527548
# ----------------------------
528-
desc "PRIVATE LANE UPLOAD TO STORE"
549+
desc "Upload the demo app to the internal portal for the App Store publication"
529550
private_lane :upload_2_store do |params|
530551
puts "👉 Upload to store"
531552

DesignToolbox/fastlane/README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,47 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do
2121
[bundle exec] fastlane ios check_dead_code
2222
```
2323

24-
RUN PERIPHERY FOR DEAD CODE ANALYSIS
24+
Run Periphery to look dor dead code in the code base. Avoid strict mode because some false positive remains and command must be fine-tuned.
2525

2626
### ios format
2727

2828
```sh
2929
[bundle exec] fastlane ios format
3030
```
3131

32-
RUN SWIFT FORMAT TO FORMAT SOURCES
32+
Run SwiftFormat to format Swift source files according to the local configuration.
3333

3434
### ios lint
3535

3636
```sh
3737
[bundle exec] fastlane ios lint
3838
```
3939

40-
RUN SWIFT LINT TO CHECK SMELLS
40+
Run SwiftLint in strict mode to detect code smells
4141

4242
### ios update_3rd_parties
4343

4444
```sh
4545
[bundle exec] fastlane ios update_3rd_parties
4646
```
4747

48-
RUN LICENSEPLIST TO UPDATE LIST OF THIRD PARTIES
48+
Run LicensePlist to update list of third-parties
4949

5050
### ios check_leaks
5151

5252
```sh
5353
[bundle exec] fastlane ios check_leaks
5454
```
5555

56-
RUN GITLEAKS FOR SECET LEAKS SCAN
56+
Run GitLeaks to look for leaks of secrets in project and Git history
57+
58+
### ios update_sbom
59+
60+
```sh
61+
[bundle exec] fastlane ios update_sbom
62+
```
63+
64+
Generates a SBOM (Software Bill Of Materials) in CycloneDX format with Syft and analsye it with Grype to as to check for vulnerabilities
5765

5866
### ios update_build_number
5967

@@ -69,47 +77,47 @@ UPDATE BUILD NUMBER WITH TIMESTAMP
6977
[bundle exec] fastlane ios test_snapshots
7078
```
7179

72-
RUN SNAPSHOTS TESTS BY TRIGGERING THE TESTS PLANS OF THE PROJECT
80+
Run snapshots tests in the demo app to look for visual regressions of components defined in OUDS package
7381

7482
### ios test_ui
7583

7684
```sh
7785
[bundle exec] fastlane ios test_ui
7886
```
7987

80-
RUN UI TESTS BY TRIGGERING THE TESTS PLANS OF THE PROJECT
88+
Run UI tests in the demo app to check some specific components behaviors
8189

8290
### ios buildDebugApp
8391

8492
```sh
8593
[bundle exec] fastlane ios buildDebugApp
8694
```
8795

88-
BUILD DEBUG APP
96+
Build locally the demo app in debug mode without upload
8997

9098
### ios alpha
9199

92100
```sh
93101
[bundle exec] fastlane ios alpha
94102
```
95103

96-
BUILD & UPLOAD TO TESTFLIGHT ALPHA APP
104+
Build the demo app in alpha mode and upload to TestFlight
97105

98106
### ios beta
99107

100108
```sh
101109
[bundle exec] fastlane ios beta
102110
```
103111

104-
BUILD & UPLOAD TO TESTFLIGHT BETA APP
112+
Build the demo app in neta mode and upload to TestFlight
105113

106114
### ios stable
107115

108116
```sh
109117
[bundle exec] fastlane ios stable
110118
```
111119

112-
BUILD & UPLOAD TO STORE (if set in options: upload) STABLE APP
120+
Build the demo app in stable mode and, if defined, upload to internal portal for App Store publication
113121

114122
----
115123

THIRD_PARTY.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ Copyright (c) 2019 Zachary Rice
104104
*gitleaks* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT).
105105
You may download the source code on the [following website](https://github.com/gitleaks/gitleaks).
106106

107+
#### Grype
108+
<!-- (CI/CD, tools, etc.) -->
109+
110+
*Grype* is distributed under the terms and conditions of the [Apache 2.0 License](https://opensource.org/license/apache-2-0).
111+
You may download the source code on the [following website](https://github.com/anchore/grype).
112+
107113
#### Periphery
108114
<!-- Xcode target -->
109115

@@ -143,3 +149,9 @@ Copyright 2024 App Deco Studio Inc.
143149

144150
*SwiftPolyglot* is distributed under the terms and conditions of the [MIT License](http://opensource.org/licenses/MIT).
145151
You may download the source code on the [following website](https://github.com/appdecostudio/SwiftPolyglot).
152+
153+
### Syft
154+
<!-- (CI/CD, tools, etc.) -->
155+
156+
*Syft* is distributed under the terms and conditions of the [Apache 2.0 License](https://opensource.org/license/apache-2-0).
157+
You may download the source code on the [following website](https://github.com/anchore/syft).

docs_release/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ Keep in mind the internal GitLab runners use tricks to check if things evolved t
5252
bundle exec fastlane update_3rd_parties
5353
```
5454

55+
- Update the SBOM
56+
57+
```shell
58+
bundle exec fastlane update_sbom
59+
```
60+
61+
>[!IMPORTANT]
62+
> Keeping up-to-date the SBOM and check for vulnerabilities is important for both software quality, users trust and legal obligations like the Cyber Resilience Act or NIS2.
63+
5564
- Verify the changes mentioned above, then commit and push.
5665

5766
- Create a new pull request named `Prepare release X.Y.Z` on GitHub to merge your branch into `develop`.

0 commit comments

Comments
 (0)