-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathindustrial-edge-insights-time-series-scans.yml
More file actions
889 lines (806 loc) · 40.1 KB
/
industrial-edge-insights-time-series-scans.yml
File metadata and controls
889 lines (806 loc) · 40.1 KB
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
---
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
name: "[Industrial Edge Insights Multimodal and Time Series] SDLe Scans"
run-name: "[Industrial Edge Insights Multimodal and Time Series] SDLe Scans workflow (by @${{ github.actor }} via ${{ github.event_name }})"
# Only run at most 1 workflow concurrently per PR, unlimited for branches
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
on:
workflow_dispatch:
inputs:
target:
description: 'Which Scans to run'
type: choice
options:
- all-scans
- trivy-fs-scan
- trivy-image-scan
- trivy-config-scan
- trivy-dockerfile-scan
- trivy-helm-scan
- bandit-scan
- virus-scan
- dbs-scan
- codeql-scan
application:
description: 'Which application to scan (time-series, multimodal or both)'
type: choice
options:
- both
- time-series
- multimodal
default: both
workflow_call:
inputs:
target:
description: 'Which Scans to run'
required: false
type: string
application:
description: 'Which application to scan (time-series, multimodal, or both)'
required: false
type: string
default: both
jobs:
trivy-fs-scan:
if: ${{ (inputs.target == 'trivy-fs-scan') || (inputs.target == 'all-scans') }}
permissions:
contents: read
packages: read # needed for actions/checkout
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Trivy from Aqua Security APT repo
run: |
sudo apt-get update
sudo apt-get install -y gnupg lsb-release wget apt-transport-https curl jq
curl -fsSL https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo gpg --dearmor -o /usr/share/keyrings/trivy.gpg
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/trivy.list > /dev/null
sudo apt-get update
sudo apt-get install -y trivy
- name: Trivy filesystem/repo scan
continue-on-error: true
shell: bash
run: |
pwd
CWD=$(pwd)
trivy --version
which trivy
trivy image --download-db-only
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
cat << 'EOF' > csv.tpl
{{ range . }}
Trivy Vulnerability Scan Results ({{- .Target -}})
VulnerabilityID,Severity,CVSS Score,Title,Library,Vulnerable Version,Fixed Version,Information URL,Triage Information
{{ range .Vulnerabilities }}
{{- .VulnerabilityID }},
{{- .Severity }},
{{- range $key, $value := .CVSS }}
{{- if (eq $key "nvd") }}
{{- .V3Score -}}
{{- end }}
{{- end }},
{{- quote .Title }},
{{- quote .PkgName }},
{{- quote .InstalledVersion }},
{{- quote .FixedVersion }},
{{- .PrimaryURL }}
{{ else -}}
No vulnerabilities found at this time.
{{ end }}
Trivy Dependency Scan Results ({{ .Target }})
ID,Name,Version,Notes
{{ range .Packages -}}
{{- quote .ID }},
{{- quote .Name }},
{{- quote .Version }}
{{ else -}}
No dependencies found at this time.
{{ end }}
{{ end }}
EOF
# Use the downloaded template
if [[ "${{ inputs.application }}" == "time-series" || "${{ inputs.application }}" == "both" ]]; then
cd $CWD/manufacturing-ai-suite/industrial-edge-insights-time-series/
trivy fs . --format template --template "@$CWD/trivy-html.tpl" -o "trivy_timeseries_fs_full_report_code_scan.html"
trivy fs --list-all-pkgs --format template --template "@$CWD/csv.tpl" --output trivy-timeseries-fs-full-report.csv .
trivy fs --ignore-unfixed . | tee trivy-timeseries-fs-full-report-ignore-unfixed.txt
fi
if [[ "${{ inputs.application }}" == "multimodal" || "${{ inputs.application }}" == "both" ]]; then
cd $CWD/manufacturing-ai-suite/industrial-edge-insights-multimodal/
trivy fs . --format template --template "@$CWD/trivy-html.tpl" -o "trivy_multimodal_fs_full_report_code_scan.html"
trivy fs --list-all-pkgs --format template --template "@$CWD/csv.tpl" --output trivy-multimodal-fs-full-report.csv .
trivy fs --ignore-unfixed . | tee trivy-multimodal-fs-full-report-ignore-unfixed.txt
fi
- name: Upload Trivy FS Scan Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Trivy Report - Filesystem Scan
path: |
manufacturing-ai-suite/industrial-edge-insights-time-series/trivy*
manufacturing-ai-suite/industrial-edge-insights-multimodal/trivy*
trivy-image-scan:
if: ${{ (inputs.target == 'trivy-image-scan') || (inputs.target == 'all-scans') }}
permissions:
contents: read
packages: read # needed for actions/checkout
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Trivy from Aqua Security APT repo
run: |
sudo apt-get update
sudo apt-get install -y gnupg lsb-release wget apt-transport-https curl jq
curl -fsSL https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo gpg --dearmor -o /usr/share/keyrings/trivy.gpg
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/trivy.list > /dev/null
sudo apt-get update
sudo apt-get install -y trivy
- name: Install Trivy
continue-on-error: true
shell: bash
run: |
pwd
CWD=$(pwd)
trivy --version
which trivy
trivy image --download-db-only
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
cat << 'EOF' > csv.tpl
{{ range . }}
Trivy Vulnerability Scan Results ({{- .Target -}})
VulnerabilityID,Severity,CVSS Score,Title,Library,Vulnerable Version,Fixed Version,Information URL,Triage Information
{{ range .Vulnerabilities }}
{{- .VulnerabilityID }},
{{- .Severity }},
{{- range $key, $value := .CVSS }}
{{- if (eq $key "nvd") }}
{{- .V3Score -}}
{{- end }}
{{- end }},
{{- quote .Title }},
{{- quote .PkgName }},
{{- quote .InstalledVersion }},
{{- quote .FixedVersion }},
{{- .PrimaryURL }}
{{ else -}}
No vulnerabilities found at this time.
{{ end }}
Trivy Dependency Scan Results ({{ .Target }})
ID,Name,Version,Notes
{{ range .Packages -}}
{{- quote .ID }},
{{- quote .Name }},
{{- quote .Version }}
{{ else -}}
No dependencies found at this time.
{{ end }}
{{ end }}
EOF
- name: Trivy Image Scan
continue-on-error: true
shell: bash
run: |
pwd
CWD=$(pwd)
if [[ "${{ inputs.application }}" == "time-series" || "${{ inputs.application }}" == "both" ]]; then
echo "Building Time Series Sample app and scanning docker images"
cd $CWD/manufacturing-ai-suite/industrial-edge-insights-time-series/
make down
OPC_UA_SERVER_IMAGE=$(grep '^OPC_UA_SERVER_IMAGE=' .env | cut -d'=' -f2)
MQTT_PUBLISHER_IMAGE=$(grep '^MQTT_PUBLISHER_IMAGE=' .env | cut -d'=' -f2)
IMAGE_SUFFIX=$(grep '^IMAGE_SUFFIX=' .env | cut -d'=' -f2 | tr -d '"')
if [ -n "$IMAGE_SUFFIX" ]; then
OPC_UA_SERVER_IMAGE="${OPC_UA_SERVER_IMAGE}-${IMAGE_SUFFIX}"
MQTT_PUBLISHER_IMAGE="${MQTT_PUBLISHER_IMAGE}-${IMAGE_SUFFIX}"
fi
make build
declare -A IMAGE_MAP
IMAGE_MAP[$OPC_UA_SERVER_IMAGE]="opcua-server"
IMAGE_MAP[$MQTT_PUBLISHER_IMAGE]="mqtt-publisher"
# Loop through images and perform Trivy scans
for IMAGE in "${!IMAGE_MAP[@]}"; do
PREFIX="${IMAGE_MAP[$IMAGE]}"
echo "Scanning image: $IMAGE"
# All scan types
trivy image "$IMAGE" --ignore-unfixed --format template --template "@$CWD/trivy-html.tpl" -o "trivy-image-scan-${PREFIX}-ignore-unfixed.html"
trivy image "$IMAGE" --ignore-unfixed --format template --template "@$CWD/csv.tpl" -o "trivy-image-scan-${PREFIX}-ignore-unfixed.csv"
trivy image --quiet --format spdx-json --output "trivy-image-scan-${PREFIX}.spdx.json" "$IMAGE"
trivy image --list-all-pkgs --format template --template "@$CWD/csv.tpl" --output "trivy-image-scan-${PREFIX}-list-all-pkgs.csv" "$IMAGE"
trivy image --ignore-unfixed "$IMAGE" | tee "trivy-image-scan-${PREFIX}-ignore-unfixed.txt"
echo "Completed scanning $IMAGE"
done
echo "completed Time Series Sample App Image scanning"
fi
if [[ "${{ inputs.application }}" == "multimodal" || "${{ inputs.application }}" == "both" ]]; then
echo "Building Multimodal Weld Defect Detection Sample app and scanning docker images"
cd $CWD/manufacturing-ai-suite/industrial-edge-insights-multimodal/
make down
WELD_SIMULATOR_IMAGE=$(grep '^WELD_SIMULATOR_IMAGE=' .env | cut -d'=' -f2)
FUSION_MODULE_IMAGE=$(grep '^FUSION_MODULE_IMAGE=' .env | cut -d'=' -f2)
IMAGE_SUFFIX=$(grep '^IMAGE_SUFFIX=' .env | cut -d'=' -f2 | tr -d '"')
if [ -n "$IMAGE_SUFFIX" ]; then
WELD_SIMULATOR_IMAGE="${WELD_SIMULATOR_IMAGE}-${IMAGE_SUFFIX}"
FUSION_MODULE_IMAGE="${FUSION_MODULE_IMAGE}-${IMAGE_SUFFIX}"
fi
make build
declare -A IMAGE_MAP
IMAGE_MAP[$WELD_SIMULATOR_IMAGE]="weld-simulator"
IMAGE_MAP[$FUSION_MODULE_IMAGE]="fusion-analytics"
# Loop through images and perform Trivy scans
for IMAGE in "${!IMAGE_MAP[@]}"; do
PREFIX="${IMAGE_MAP[$IMAGE]}"
echo "Scanning image: $IMAGE"
# All scan types
trivy image "$IMAGE" --ignore-unfixed --format template --template "@$CWD/trivy-html.tpl" -o "trivy-image-scan-${PREFIX}-ignore-unfixed.html"
trivy image "$IMAGE" --ignore-unfixed --format template --template "@$CWD/csv.tpl" -o "trivy-image-scan-${PREFIX}-ignore-unfixed.csv"
trivy image --quiet --format spdx-json --output "trivy-image-scan-${PREFIX}.spdx.json" "$IMAGE"
trivy image --list-all-pkgs --format template --template "@$CWD/csv.tpl" --output "trivy-image-scan-${PREFIX}-list-all-pkgs.csv" "$IMAGE"
trivy image --ignore-unfixed "$IMAGE" | tee "trivy-image-scan-${PREFIX}-ignore-unfixed.txt"
echo "Completed scanning $IMAGE"
done
echo "completed Multimodal Weld Defect Detection Sample App Image scanning"
fi
- name: Upload Trivy Image Scan Report
continue-on-error: true
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Trivy Report - Image Scan
path: |
manufacturing-ai-suite/industrial-edge-insights-time-series/trivy-image-scan*
manufacturing-ai-suite/industrial-edge-insights-multimodal/trivy-image-scan*
trivy-config-helm-scan:
if: ${{ (inputs.target == 'trivy-config-scan') || (inputs.target == 'trivy-helm-scan') || (inputs.target == 'all-scans') }}
permissions:
contents: read
packages: read # needed for actions/checkout
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install Trivy from Aqua Security APT repo
run: |
sudo apt-get update
sudo apt-get install -y gnupg lsb-release wget apt-transport-https curl jq
curl -fsSL https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo gpg --dearmor -o /usr/share/keyrings/trivy.gpg
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/trivy.list > /dev/null
sudo apt-get update
sudo apt-get install -y trivy
- name: Install Trivy
continue-on-error: true
shell: bash
run: |
pwd
trivy --version
which trivy
trivy image --download-db-only
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html.tpl
cat << 'EOF' > csv.tpl
{{ range . }}
Trivy Vulnerability Scan Results ({{- .Target -}})
VulnerabilityID,Severity,CVSS Score,Title,Library,Vulnerable Version,Fixed Version,Information URL,Triage Information
{{ range .Vulnerabilities }}
{{- .VulnerabilityID }},
{{- .Severity }},
{{- range $key, $value := .CVSS }}
{{- if (eq $key "nvd") }}
{{- .V3Score -}}
{{- end }}
{{- end }},
{{- quote .Title }},
{{- quote .PkgName }},
{{- quote .InstalledVersion }},
{{- quote .FixedVersion }},
{{- .PrimaryURL }}
{{ else -}}
No vulnerabilities found at this time.
{{ end }}
Trivy Dependency Scan Results ({{ .Target }})
ID,Name,Version,Notes
{{ range .Packages -}}
{{- quote .ID }},
{{- quote .Name }},
{{- quote .Version }}
{{ else -}}
No dependencies found at this time.
{{ end }}
{{ end }}
EOF
- name: Trivy config scan for helm charts
run: |
if [[ "${{ inputs.application }}" == "time-series" || "${{ inputs.application }}" == "both" ]]; then
cd manufacturing-ai-suite/industrial-edge-insights-time-series/
make gen_helm_charts
cd helm
INFLUXDB_USERNAME=$(cat /dev/urandom | tr -dc 'a-zA-Z' | head -c 8)
INFLUXDB_PASSWORD=$(openssl rand -hex 10)
VISUALIZER_GRAFANA_USER=$(cat /dev/urandom | tr -dc 'a-zA-Z' | head -c 8)
VISUALIZER_GRAFANA_PASSWORD=$(openssl rand -hex 10)
sed -i "s/INFLUXDB_USERNAME:.*/INFLUXDB_USERNAME: ${INFLUXDB_USERNAME}/g" values.yaml
sed -i "s/INFLUXDB_PASSWORD:.*/INFLUXDB_PASSWORD: ${INFLUXDB_PASSWORD}/g" values.yaml
sed -i "s/VISUALIZER_GRAFANA_USER:.*/VISUALIZER_GRAFANA_USER: ${VISUALIZER_GRAFANA_USER}/g" values.yaml
sed -i "s/VISUALIZER_GRAFANA_PASSWORD:.*/VISUALIZER_GRAFANA_PASSWORD: ${VISUALIZER_GRAFANA_PASSWORD}/g" values.yaml
trivy config . >> trivy-timeseries-mqtt-helm.txt
sed -i "s/TELEGRAF_INPUT_PLUGIN:.*/TELEGRAF_INPUT_PLUGIN: opcua/g" values.yaml
trivy config . >> trivy-timeseries-opcua-helm.txt
fi
- name: Upload Scan artifact to Github
uses: actions/upload-artifact@v4
with:
name: Trivy Report - Config scan for Helm
path: |
manufacturing-ai-suite/industrial-edge-insights-time-series/helm/trivy-timeseries-*.txt
trivy-config-time-series-dockerfile-scan:
if: ${{ ((inputs.target == 'trivy-config-scan') || (inputs.target == 'trivy-dockerfile-scan') || (inputs.target == 'all-scans')) && ((inputs.application == 'time-series') || (inputs.application == 'both')) }}
permissions:
contents: read
packages: read # needed for actions/checkout
name: Scan Dockerfiles (OPCUA & mqttpublisher)
strategy:
fail-fast: false
matrix:
include:
- dockerfile-path: manufacturing-ai-suite/industrial-edge-insights-time-series/simulator/opcua-server/Dockerfile
output-report-path: trivy-opcua-dockerfile.json
scan-name: Time Series OPCUA Dockerfile
- dockerfile-path: manufacturing-ai-suite/industrial-edge-insights-time-series/simulator/mqtt-publisher/Dockerfile
output-report-path: trivy-mqttpublisher-dockerfile.json
scan-name: Time Series mqttpublisher Dockerfile
uses: open-edge-platform/edge-ai-libraries/.github/workflows/trivy-config-mode.yaml@e6e04af3dbca805db9118b85a22ad2998f7eec39
with:
dockerfile-path: ${{ matrix.dockerfile-path }}
trivy-report-format: 'json'
severity-levels: 'HIGH,CRITICAL'
output-report-path: ${{ matrix.output-report-path }}
name: ${{ matrix.scan-name }}
trivy-config-multimodal-dockerfile-scan:
if: ${{ ((inputs.target == 'trivy-config-scan') || (inputs.target == 'trivy-dockerfile-scan') || (inputs.target == 'all-scans')) && ((inputs.application == 'multimodal') || (inputs.application == 'both')) }}
permissions:
contents: read
packages: read # needed for actions/checkout
name: Scan Dockerfiles (weld data simulator & fusion module)
strategy:
fail-fast: false
matrix:
include:
- dockerfile-path: manufacturing-ai-suite/industrial-edge-insights-multimodal/weld-data-simulator/Dockerfile
output-report-path: trivy-weld-simulator-dockerfile.json
scan-name: Multimodal Weld Data Simulator Dockerfile
- dockerfile-path: manufacturing-ai-suite/industrial-edge-insights-multimodal/fusion-analytics/Dockerfile
output-report-path: trivy-fusion-analytics-dockerfile.json
scan-name: Multimodal Fusion Analytics Dockerfile
uses: open-edge-platform/edge-ai-libraries/.github/workflows/trivy-config-mode.yaml@e6e04af3dbca805db9118b85a22ad2998f7eec39
with:
dockerfile-path: ${{ matrix.dockerfile-path }}
trivy-report-format: 'json'
severity-levels: 'HIGH,CRITICAL'
output-report-path: ${{ matrix.output-report-path }}
name: ${{ matrix.scan-name }}
bandit-scans:
if: ${{ (inputs.target == 'bandit-scan') || (inputs.target == 'all-scans') }}
permissions:
contents: read
packages: read # needed for actions/checkout
name: Run Bandit Scan
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- ubuntu_version: ubuntu24
steps:
- name: Check out edge-ai-suites repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Run Bandit Scan
run: |
mkdir -p reports
docker pull ghcr.io/pycqa/bandit/bandit
echo "### Bandit Scan Results" >> $GITHUB_STEP_SUMMARY
if [[ "${{ inputs.application }}" == "time-series" || "${{ inputs.application }}" == "both" ]]; then
docker run --rm -v "${{ github.workspace }}:/src" ghcr.io/pycqa/bandit/bandit -r /src/manufacturing-ai-suite/industrial-edge-insights-time-series/ -f json -o /src/reports/bandit-timeseries-report.json || true >> $GITHUB_STEP_SUMMARY
echo "Please find full report in bandit-timeseries-report.txt" >> $GITHUB_STEP_SUMMARY
fi
if [[ "${{ inputs.application }}" == "multimodal" || "${{ inputs.application }}" == "both" ]]; then
docker run --rm -v "${{ github.workspace }}:/src" ghcr.io/pycqa/bandit/bandit -r /src/manufacturing-ai-suite/industrial-edge-insights-multimodal/ -f json -o /src/reports/bandit-multimodal-report.json || true >> $GITHUB_STEP_SUMMARY
echo "Please find full report in bandit-multimodal-report.txt" >> $GITHUB_STEP_SUMMARY
fi
ls -al
pwd
- name: Convert JSON to CSV
run: |
cat > convert_json_to_csv.py << 'EOF'
import json
import csv
import glob
# Find all bandit report JSON files
json_files = glob.glob("reports/bandit-*-report.json")
for json_file in json_files:
print(f"Processing {json_file}")
with open(json_file) as f:
data = json.load(f)
csv_file = json_file.replace(".json", ".csv")
with open(csv_file, "w", newline="") as csvfile:
fieldnames = ["filename", "line_number", "issue_text", "severity", "confidence", "test_name"]
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for issue in data.get("results", []):
writer.writerow({
"filename": issue["filename"],
"line_number": issue["line_number"],
"issue_text": issue["issue_text"],
"severity": issue["issue_severity"],
"confidence": issue["issue_confidence"],
"test_name": issue["test_name"]
})
EOF
python3 convert_json_to_csv.py
- name: Upload Scan Reports
uses: actions/upload-artifact@v4
with:
name: bandit-report
path: |
reports/bandit*.json
reports/bandit-*.csv
virus-scans:
if: ${{ (inputs.target == 'virus-scan') || (inputs.target == 'all-scans') }}
permissions:
contents: read
packages: read # needed for actions/checkout
name: Run Virus Scan
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- ubuntu_version: ubuntu24
steps:
- name: Check out edge-ai-libraries repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Run Virus Scan
run: |
mkdir -p reports
docker pull clamav/clamav
echo "### Virus Scan Results" >> $GITHUB_STEP_SUMMARY
if [[ "${{ inputs.application }}" == "time-series" || "${{ inputs.application }}" == "both" ]]; then
docker run --rm -v "${{ github.workspace }}:/src" clamav/clamav clamscan -r /src/manufacturing-ai-suite/industrial-edge-insights-time-series/ > ./reports/clamav-timeseries-report.txt || true
echo "Please find full report in clamav-timeseries-report.txt" >> $GITHUB_STEP_SUMMARY
fi
if [[ "${{ inputs.application }}" == "multimodal" || "${{ inputs.application }}" == "both" ]]; then
docker run --rm -v "${{ github.workspace }}:/src" clamav/clamav clamscan -r /src/manufacturing-ai-suite/industrial-edge-insights-multimodal/ > ./reports/clamav-multimodal-report.txt || true
echo "Please find full report in clamav-multimodal-report.txt" >> $GITHUB_STEP_SUMMARY
fi
- name: Upload Scan Reports
uses: actions/upload-artifact@v4
with:
name: virus-reports
path: |
reports/clamav-timeseries-report.txt
reports/clamav-multimodal-report.txt
DBS_job:
if: ${{ (inputs.target == 'dbs-scan') || (inputs.target == 'all-scans') }}
runs-on: ubuntu-24.04
permissions:
contents: read
packages: read # needed for actions/checkout
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: check the system
run: |
docker ps &&
uname -a &&
docker version &&
git version &&
docker compose version
- name: Checkout docker/docker-bench-security (master)
uses: actions/checkout@v4
with:
repository: docker/docker-bench-security
ref: master
path: docker-bench-security
persist-credentials: false
- name: Build Docker Bench Security
run: |
cd docker-bench-security
docker build --no-cache -t docker-bench-security .
- name: Checkout Time Series Analytics microservice (edge-ai-libraries)
uses: actions/checkout@v4
with:
repository: open-edge-platform/edge-ai-libraries
ref: main
path: edge-ai-libraries
persist-credentials: false
- name: Building Time Series Analytics microservices
run: |
cd ./edge-ai-libraries/microservices/time-series-analytics/docker
docker compose down -v
docker compose build
- name: Deploy Time Series Wind Turbine Sample App
if: ${{ (inputs.application == 'time-series') || (inputs.application == 'both') }}
run: |
cd manufacturing-ai-suite/industrial-edge-insights-time-series/
make down
# Generate random values for sensitive environment variables
INFLUXDB_USERNAME=$(cat /dev/urandom | tr -dc 'a-zA-Z' | head -c 8)
INFLUXDB_PASSWORD=$(openssl rand -hex 10)
VISUALIZER_GRAFANA_USER=$(cat /dev/urandom | tr -dc 'a-zA-Z' | head -c 8)
VISUALIZER_GRAFANA_PASSWORD=$(openssl rand -hex 10)
sed -i "s/INFLUXDB_USERNAME=.*/INFLUXDB_USERNAME=${INFLUXDB_USERNAME}/g" .env
sed -i "s/INFLUXDB_PASSWORD=.*/INFLUXDB_PASSWORD=${INFLUXDB_PASSWORD}/g" .env
sed -i "s/VISUALIZER_GRAFANA_USER=.*/VISUALIZER_GRAFANA_USER=${VISUALIZER_GRAFANA_USER}/g" .env
sed -i "s/VISUALIZER_GRAFANA_PASSWORD=.*/VISUALIZER_GRAFANA_PASSWORD=${VISUALIZER_GRAFANA_PASSWORD}/g" .env
make build
echo "Deploying using opcua ingestion"
make up_opcua_ingestion app=wind-turbine-anomaly-detection
- name: DBS download and scan for Time Series Wind Turbine Sample App
if: ${{ (inputs.application == 'time-series') || (inputs.application == 'both') }}
run: |
cd manufacturing-ai-suite/industrial-edge-insights-time-series/
docker run --rm --net host --pid host --userns host --cap-add audit_control \
-e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
-v /etc:/etc:ro \
-v /usr/bin/containerd:/usr/bin/containerd:ro \
-v /usr/bin/runc:/usr/bin/runc:ro \
-v /usr/lib/systemd:/usr/lib/systemd:ro \
-v /var/lib:/var/lib:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--label docker_bench_security \
docker-bench-security > dbs_scan_windturbine_sample_app.txt
- name: Undeploy Time Series Analytics microservice
if: ${{ (inputs.application == 'time-series') || (inputs.application == 'both') }}
run: |
cd manufacturing-ai-suite/industrial-edge-insights-time-series/
make down
- name: Deploy Time Series Weld Anomaly Detection Sample App
if: ${{ (inputs.application == 'time-series') || (inputs.application == 'both') }}
run: |
cd manufacturing-ai-suite/industrial-edge-insights-time-series/
make down
# Generate random values for sensitive environment variables
INFLUXDB_USERNAME=$(cat /dev/urandom | tr -dc 'a-zA-Z' | head -c 8)
INFLUXDB_PASSWORD=$(openssl rand -hex 10)
VISUALIZER_GRAFANA_USER=$(cat /dev/urandom | tr -dc 'a-zA-Z' | head -c 8)
VISUALIZER_GRAFANA_PASSWORD=$(openssl rand -hex 10)
sed -i "s/INFLUXDB_USERNAME=.*/INFLUXDB_USERNAME=${INFLUXDB_USERNAME}/g" .env
sed -i "s/INFLUXDB_PASSWORD=.*/INFLUXDB_PASSWORD=${INFLUXDB_PASSWORD}/g" .env
sed -i "s/VISUALIZER_GRAFANA_USER=.*/VISUALIZER_GRAFANA_USER=${VISUALIZER_GRAFANA_USER}/g" .env
sed -i "s/VISUALIZER_GRAFANA_PASSWORD=.*/VISUALIZER_GRAFANA_PASSWORD=${VISUALIZER_GRAFANA_PASSWORD}/g" .env
make build
echo "Deploying using mqtt ingestion"
make up_mqtt_ingestion app=weld-anomaly-detection
- name: DBS download and scan for Time Series Weld Anomaly Detection Sample App
if: ${{ (inputs.application == 'time-series') || (inputs.application == 'both') }}
run: |
cd manufacturing-ai-suite/industrial-edge-insights-time-series/
docker run --rm --net host --pid host --userns host --cap-add audit_control \
-e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
-v /etc:/etc:ro \
-v /usr/bin/containerd:/usr/bin/containerd:ro \
-v /usr/bin/runc:/usr/bin/runc:ro \
-v /usr/lib/systemd:/usr/lib/systemd:ro \
-v /var/lib:/var/lib:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--label docker_bench_security \
docker-bench-security > dbs_scan_weld_anomaly_detection_sample_app.txt
- name: Undeploy Time Series Analytics microservice
if: ${{ (inputs.application == 'time-series') || (inputs.application == 'both') }}
run: |
cd manufacturing-ai-suite/industrial-edge-insights-time-series/
make down
- name: Upload Scan artifact to Github
if: ${{ (inputs.application == 'time-series') || (inputs.application == 'both') }}
uses: actions/upload-artifact@v4
with:
name: DBS_time-series-analytics
path: manufacturing-ai-suite/industrial-edge-insights-time-series/dbs_scan_*
- name: Deploy Multimodal Weld Defect Detection Sample App
if: ${{ (inputs.application == 'multimodal') || (inputs.application == 'both') }}
run: |
cd manufacturing-ai-suite/industrial-edge-insights-multimodal/
make down
# Generate random values for sensitive environment variables
INFLUXDB_USERNAME=$(cat /dev/urandom | tr -dc 'a-zA-Z' | head -c 8)
INFLUXDB_PASSWORD=$(openssl rand -hex 10)
VISUALIZER_GRAFANA_USER=$(cat /dev/urandom | tr -dc 'a-zA-Z' | head -c 8)
VISUALIZER_GRAFANA_PASSWORD=$(openssl rand -hex 10)
MTX_WEBRTCICESERVERS2_0_USERNAME=$(cat /dev/urandom | tr -dc 'a-zA-Z' | head -c 8)
MTX_WEBRTCICESERVERS2_0_PASSWORD=$(openssl rand -hex 10)
HOST_IP=$(hostname -I | awk '{print $1}')
sed -i "s/INFLUXDB_USERNAME=.*/INFLUXDB_USERNAME=${INFLUXDB_USERNAME}/g" .env
sed -i "s/INFLUXDB_PASSWORD=.*/INFLUXDB_PASSWORD=${INFLUXDB_PASSWORD}/g" .env
sed -i "s/VISUALIZER_GRAFANA_USER=.*/VISUALIZER_GRAFANA_USER=${VISUALIZER_GRAFANA_USER}/g" .env
sed -i "s/VISUALIZER_GRAFANA_PASSWORD=.*/VISUALIZER_GRAFANA_PASSWORD=${VISUALIZER_GRAFANA_PASSWORD}/g" .env
sed -i "s/MTX_WEBRTCICESERVERS2_0_USERNAME=.*/MTX_WEBRTCICESERVERS2_0_USERNAME=${MTX_WEBRTCICESERVERS2_0_USERNAME}/g" .env
sed -i "s/MTX_WEBRTCICESERVERS2_0_PASSWORD=.*/MTX_WEBRTCICESERVERS2_0_PASSWORD=${MTX_WEBRTCICESERVERS2_0_PASSWORD}/g" .env
sed -i "s/HOST_IP=.*/HOST_IP=${HOST_IP}/g" .env
make build
echo "Deploying using mqtt ingestion"
make up
- name: DBS download and scan for Multimodal Weld Defect Detection Sample App
if: ${{ (inputs.application == 'multimodal') || (inputs.application == 'both') }}
run: |
cd manufacturing-ai-suite/industrial-edge-insights-multimodal/
docker run --rm --net host --pid host --userns host --cap-add audit_control \
-e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
-v /etc:/etc:ro \
-v /usr/bin/containerd:/usr/bin/containerd:ro \
-v /usr/bin/runc:/usr/bin/runc:ro \
-v /usr/lib/systemd:/usr/lib/systemd:ro \
-v /var/lib:/var/lib:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--label docker_bench_security \
docker-bench-security > dbs_scan_multimodal_weld_defect_detection_sample_app.txt
- name: Undeploy Multimodal Weld Defect Detection Sample App
if: ${{ (inputs.application == 'multimodal') || (inputs.application == 'both') }}
run: |
cd manufacturing-ai-suite/industrial-edge-insights-multimodal/
make down
- name: Upload Scan artifact to Github
if: ${{ (inputs.application == 'multimodal') || (inputs.application == 'both') }}
uses: actions/upload-artifact@v4
with:
name: DBS_multimodal_weld_defect_detection
path: manufacturing-ai-suite/industrial-edge-insights-multimodal/dbs_scan_*
codeql-timeseries-job:
name: CodeQL Scan - Time Series Python
if: ${{ ((inputs.target == 'codeql-scan') || (inputs.target == 'all-scans')) && ((inputs.application == 'time-series') || (inputs.application == 'both')) }}
runs-on: ubuntu-24.04
permissions:
security-events: write
packages: read
actions: read
contents: read
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Initialize CodeQL
uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
with:
languages: 'python'
source-root: manufacturing-ai-suite/industrial-edge-insights-time-series/
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
with:
category: "/language:python"
upload: "never"
output: results-timeseries
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install reportlab
- name: Convert SARIF to PDF
run: |
python - <<EOF
import json
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
def parse_sarif(sarif_file):
with open(sarif_file, 'r') as file:
data = json.load(file)
return data
def generate_pdf(data, output_file):
c = canvas.Canvas(output_file, pagesize=letter)
width, height = letter
c.drawString(100, height - 100, "SARIF Report - Time Series")
y_position = height - 150
for run in data.get('runs', []):
for result in run.get('results', []):
message = result.get('message', {}).get('text', 'No message')
severity = result.get('level', 'Unknown')
location = result.get('locations', [{}])[0].get('physicalLocation', {}).get('artifactLocation', {}).get('uri', 'Unknown location')
c.drawString(100, y_position, f"Message: {message}")
c.drawString(100, y_position - 20, f"Severity: {severity}")
c.drawString(100, y_position - 40, f"Location: {location}")
y_position -= 80
if y_position < 100:
c.showPage()
y_position = height - 100
c.save()
sarif_data = parse_sarif('results-timeseries/python.sarif')
generate_pdf(sarif_data, 'sarif_timeseries_report.pdf')
EOF
- name: Create ZIP File
run: |
zip codeql_timeseries_reports.zip results-timeseries/python.sarif sarif_timeseries_report.pdf
- name: Upload ZIP Artifact
uses: actions/upload-artifact@v4
with:
name: Time Series Sample app CodeQL Reports
path: codeql_timeseries_reports.zip
codeql-multimodal-job:
name: CodeQL Scan - Multimodal Python
if: ${{ ((inputs.target == 'codeql-scan') || (inputs.target == 'all-scans')) && ((inputs.application == 'multimodal') || (inputs.application == 'both')) }}
runs-on: ubuntu-24.04
permissions:
security-events: write
packages: read
actions: read
contents: read
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Initialize CodeQL
uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
with:
languages: 'python'
source-root: manufacturing-ai-suite/industrial-edge-insights-multimodal/
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
with:
category: "/language:python"
upload: "never"
output: results-multimodal
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install reportlab
- name: Convert SARIF to PDF
run: |
python - <<EOF
import json
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
def parse_sarif(sarif_file):
with open(sarif_file, 'r') as file:
data = json.load(file)
return data
def generate_pdf(data, output_file):
c = canvas.Canvas(output_file, pagesize=letter)
width, height = letter
c.drawString(100, height - 100, "SARIF Report - Multimodal")
y_position = height - 150
for run in data.get('runs', []):
for result in run.get('results', []):
message = result.get('message', {}).get('text', 'No message')
severity = result.get('level', 'Unknown')
location = result.get('locations', [{}])[0].get('physicalLocation', {}).get('artifactLocation', {}).get('uri', 'Unknown location')
c.drawString(100, y_position, f"Message: {message}")
c.drawString(100, y_position - 20, f"Severity: {severity}")
c.drawString(100, y_position - 40, f"Location: {location}")
y_position -= 80
if y_position < 100:
c.showPage()
y_position = height - 100
c.save()
sarif_data = parse_sarif('results-multimodal/python.sarif')
generate_pdf(sarif_data, 'sarif_multimodal_report.pdf')
EOF
- name: Create ZIP File
run: |
zip codeql_multimodal_reports.zip results-multimodal/python.sarif sarif_multimodal_report.pdf
- name: Upload ZIP Artifact
uses: actions/upload-artifact@v4
with:
name: Multimodal Weld Defect Detection Sample app CodeQL Reports
path: codeql_multimodal_reports.zip