@@ -57,7 +57,13 @@ const yargsConfig = {
57
57
//evidence: false,
58
58
//'include-crypto': false,
59
59
//'include-formulation': false,
60
- //'install-deps': true,
60
+
61
+ // Default 'install-deps' to `false` and 'lifecycle' to 'pre-build' to
62
+ // sidestep arbitrary code execution during a cdxgen scan.
63
+ // https://github.com/CycloneDX/cdxgen/issues/1328
64
+ 'install-deps' : false ,
65
+ lifecycle : 'pre-build' ,
66
+
61
67
//output: 'bom.json',
62
68
//profile: 'generic',
63
69
//'project-version': '',
@@ -103,6 +109,7 @@ const yargsConfig = {
103
109
] ,
104
110
string : [
105
111
'api-key' ,
112
+ 'lifecycle' ,
106
113
'output' ,
107
114
'parent-project-id' ,
108
115
'profile' ,
@@ -131,7 +138,7 @@ function argvToArray(argv: {
131
138
} else if ( value === true ) {
132
139
result . push ( `--${ key } ` )
133
140
} else if ( typeof value === 'string' ) {
134
- result . push ( `--${ key } = ${ value } ` )
141
+ result . push ( `--${ key } ` , String ( value ) )
135
142
} else if ( Array . isArray ( value ) ) {
136
143
result . push ( `--${ key } ` , ...value . map ( String ) )
137
144
}
@@ -149,7 +156,6 @@ export const cdxgen: CliSubcommand = {
149
156
__proto__ : null ,
150
157
...yargsParse ( < string [ ] > argv_ , yargsConfig )
151
158
}
152
-
153
159
const unknown : string [ ] = yargv . _
154
160
const { length : unknownLength } = unknown
155
161
if ( unknownLength ) {
@@ -159,7 +165,6 @@ export const cdxgen: CliSubcommand = {
159
165
process . exitCode = 1
160
166
return
161
167
}
162
-
163
168
let cleanupPackageLock = false
164
169
if (
165
170
yargv . type !== 'yarn' &&
@@ -182,11 +187,9 @@ export const cdxgen: CliSubcommand = {
182
187
} catch { }
183
188
}
184
189
}
185
-
186
190
if ( yargv . output === undefined ) {
187
191
yargv . output = 'socket-cdx.json'
188
192
}
189
-
190
193
await spawn (
191
194
execPath ,
192
195
[ await fs . realpath ( cdxgenBinPath ) , ...argvToArray ( yargv ) ] ,
@@ -201,7 +204,6 @@ export const cdxgen: CliSubcommand = {
201
204
stdio : 'inherit'
202
205
}
203
206
)
204
-
205
207
if ( cleanupPackageLock ) {
206
208
try {
207
209
await fs . unlink ( './package-lock.json' )
0 commit comments