1
1
name : CodeQL (Swift) - SAST
2
2
3
3
on :
4
- pull_request :
5
- push :
6
- workflow_dispatch :
4
+ workflow_call :
5
+ inputs :
6
+ scheme :
7
+ description : ' xcodebuild scheme arg'
8
+ required : true
9
+ type : string
10
+ project :
11
+ description : ' xcodebuild project arg'
12
+ required : true
13
+ type : string
14
+ workspace :
15
+ description : ' Optional xcodebuild workspace arg'
16
+ required : false
17
+ type : string
18
+ command :
19
+ description : ' Optional application build command, overrides build-scheme and build-workspace'
20
+ required : false
21
+ type : string
22
+ timeout-minutes :
23
+ description : ' Optional override for larger builds'
24
+ required : false
25
+ default : 30
26
+ type : number
27
+
28
+ permissions :
29
+ security-events : write
30
+ # required to fetch internal or private CodeQL packs
31
+ packages : read
32
+ actions : read
33
+ contents : read
34
+
35
+ defaults :
36
+ run :
37
+ shell : bash
7
38
8
39
jobs :
9
- analyze :
10
- name : Code Scanning - CodeQL
11
- runs-on : ubuntu-latest
12
- timeout-minutes : 25
13
- permissions :
14
- security-events : write
15
- packages : read
16
- actions : read
17
- contents : read
40
+ code-scanning :
41
+ name : Code Scanning
42
+ runs-on : macos-15
43
+ timeout-minutes : ${{ inputs.timeout-minutes }}
18
44
strategy :
19
45
fail-fast : false
20
- steps :
21
- - uses : hyperwallet/public-security-workflows/codeql@main
46
+
47
+ steps :
48
+ - name : Checkout
49
+ uses : actions/checkout@v4
50
+
51
+ - name : Setup Xcode
52
+ uses : maxim-lobanov/setup-xcode@v1
53
+ with :
54
+ xcode-version : ' ${{ matrix.xcode_version }}'
55
+
56
+ - name : Carthage [Setup cache]
57
+ uses : actions/cache@v3
22
58
with :
23
- language : swift
24
- build-mode : ' manual'
25
- timeout-minutes : 25
59
+ path : Carthage
60
+ key : ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
61
+ restore-keys : |
62
+ ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
63
+
64
+ - name : Carthage [Install dependencies]
65
+ run : carthage bootstrap
66
+ --platform ios
67
+ --cache-builds
68
+ --use-xcframeworks
69
+ --no-use-binaries
26
70
71
+ - name : Initialize CodeQL
72
+ uses : github/codeql-action/init@v3
73
+ with :
74
+ languages : swift
75
+ build-mode : manual
76
+ debug : true
77
+
78
+ - name : xcodebuild (default)
79
+ if : ${{ inputs.build-command == '' }}
80
+ run : |
81
+ project=${{ inputs.project }}
82
+ os_version=17.5
83
+ device="iPhone 15 Pro"
84
+ destination="platform=iOS Simulator,name=${device},OS=${os_version}"
85
+
86
+ scheme=${{ inputs.scheme }}
87
+ build_dir=${HOME}/Library/Developer/Xcode/DerivedData/${scheme}
88
+ source_packages=${build_dir}/SourcePackages
89
+
90
+ args=(
91
+ "-configuration Debug"
92
+ "-scheme ${scheme}"
93
+ "-project ${project}"
94
+ "-destination '${destination}'"
95
+ "-derivedDataPath ${build_dir}"
96
+ "-clonedSourcePackagesDirPath ${source_packages}"
97
+ "-disableAutomaticPackageResolution"
98
+ "-scmProvider system"
99
+ )
100
+
101
+ if [[ -n "${{ inputs.build-workspace }}" ]]; then
102
+ args+=("-workspace ${{ inputs.build-workspace }}")
103
+ fi
104
+
105
+ args+=("clean")
106
+ args+=("build")
107
+
108
+ build_cmd="xcodebuild ${args[*]}"
109
+ echo "${build_cmd}"
110
+ eval "${build_cmd}"
111
+
112
+ - name : xcodebuild (custom)
113
+ if : ${{ inputs.build-command != '' }}
114
+ run : |
115
+ ${{ inputs.build-command }}
116
+
117
+ - name : Perform CodeQL Analysis
118
+ uses : github/codeql-action/analyze@v3
119
+ with :
120
+ category : " /language:swift"
0 commit comments