dart-decimate 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -1
- package/Cargo.toml +2 -4
- package/README.md +48 -15
- package/package.json +1 -1
- package/src/baseline.rs +17 -12
- package/src/changed_scope.rs +98 -5
- package/src/cli/audit_run.rs +2 -1
- package/src/cli/common_args.rs +13 -2
- package/src/cli/decision_surface_run.rs +149 -11
- package/src/cli/default_command.rs +304 -6
- package/src/cli/error.rs +4 -1
- package/src/cli/error_output.rs +10 -2
- package/src/cli/fix_run.rs +6 -11
- package/src/cli/html_open.rs +240 -0
- package/src/cli/inspect_run.rs +3 -0
- package/src/cli/output_format.rs +3 -0
- package/src/cli/scope_args.rs +14 -1
- package/src/cli/security_args.rs +4 -1
- package/src/cli/tests.rs +90 -0
- package/src/cli/trace_run.rs +12 -0
- package/src/cli.rs +88 -9
- package/src/config/rule_aliases.rs +8 -0
- package/src/config/rules.rs +9 -4
- package/src/config.rs +1 -0
- package/src/explain.rs +1 -0
- package/src/manifest/mcp.rs +9 -0
- package/src/manifest.rs +31 -10
- package/src/mcp/cli_args.rs +4 -1
- package/src/mcp/tools.rs +9 -0
- package/src/output/html.rs +691 -0
- package/src/output/human.rs +503 -10
- package/src/output/human_details.rs +449 -0
- package/src/output/next_steps.rs +11 -0
- package/src/output/security_findings.rs +5 -1
- package/src/output/types.rs +7 -0
- package/src/output.rs +3 -0
- package/src/report_schema/inventory.rs +1 -0
- package/src/security/detect.rs +724 -11
- package/src/security/tests.rs +390 -1
- package/src/security.rs +6 -0
- package/src/security_gate.rs +7 -2
package/src/security/tests.rs
CHANGED
|
@@ -77,7 +77,7 @@ fn skips_comments_generated_tests_and_placeholders() -> Result<(), Box<dyn std::
|
|
|
77
77
|
"lib/main.dart",
|
|
78
78
|
"// const accessToken = 'dart_decimate_fixture_value_1234567890';
|
|
79
79
|
const apiKey = 'YOUR_API_KEY';
|
|
80
|
-
const firebase = FirebaseOptions(apiKey: '
|
|
80
|
+
const firebase = FirebaseOptions(apiKey: 'REDACTED_FIREBASE_API_KEY');
|
|
81
81
|
final uri = Uri.parse('http://localhost:8080');
|
|
82
82
|
Future<void> run() => Process.run('git', ['status']);
|
|
83
83
|
Future<void> query(dynamic db, String id) => db.rawQuery('SELECT * FROM users WHERE id = ?', [id]);
|
|
@@ -103,6 +103,395 @@ Future<void> query(dynamic db, String id) => db.rawQuery('SELECT * FROM users WH
|
|
|
103
103
|
Ok(())
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
#[test]
|
|
107
|
+
fn skips_password_named_non_secret_literals() -> Result<(), Box<dyn std::error::Error>> {
|
|
108
|
+
let fixture = tempfile::tempdir()?;
|
|
109
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
110
|
+
write(
|
|
111
|
+
&fixture,
|
|
112
|
+
"lib/main.dart",
|
|
113
|
+
"import 'package:example/features/auth/password_form_field.dart';
|
|
114
|
+
|
|
115
|
+
class Routes {
|
|
116
|
+
static const String forgotPassword = '/forgot-password';
|
|
117
|
+
static const String resetPassword = '/reset-password';
|
|
118
|
+
static const String passwordRecoveryRedirectUrl = 'https://example.invalid/reset-password';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
class Copy {
|
|
122
|
+
String get settingsSecurityChangePassword => 'Change Password';
|
|
123
|
+
static const String invalidCredentials = 'Invalid email or password';
|
|
124
|
+
}
|
|
125
|
+
",
|
|
126
|
+
)?;
|
|
127
|
+
|
|
128
|
+
let project = scan_project(fixture.path())?;
|
|
129
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
130
|
+
|
|
131
|
+
assert!(report.candidates.is_empty());
|
|
132
|
+
assert_eq!(report.total_occurrences, 0);
|
|
133
|
+
|
|
134
|
+
Ok(())
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#[test]
|
|
138
|
+
fn reports_secret_named_urls_with_concrete_secret_parameters()
|
|
139
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
140
|
+
let fixture = tempfile::tempdir()?;
|
|
141
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
142
|
+
write(
|
|
143
|
+
&fixture,
|
|
144
|
+
"lib/main.dart",
|
|
145
|
+
"class Routes {
|
|
146
|
+
static const String resetPassword = '/reset-password?next=/settings';
|
|
147
|
+
static const String resetPasswordSuccess = '/reset-password/success-page';
|
|
148
|
+
static const String resetPasswordToken = '/reset-password?token=dartdecimate12345';
|
|
149
|
+
static const String recoveryAccessToken = 'https://auth.invalid/reset-password#access_token=dartdecimate67890';
|
|
150
|
+
static const String resetPasswordPathToken = 'https://auth.invalid/reset-password/dartdecimate12345';
|
|
151
|
+
}
|
|
152
|
+
",
|
|
153
|
+
)?;
|
|
154
|
+
|
|
155
|
+
let project = scan_project(fixture.path())?;
|
|
156
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
157
|
+
|
|
158
|
+
assert_eq!(report.total_occurrences, 3);
|
|
159
|
+
assert_eq!(
|
|
160
|
+
report.candidates[0].rule_id,
|
|
161
|
+
"dart-decimate/security-hardcoded-secret"
|
|
162
|
+
);
|
|
163
|
+
assert_eq!(report.candidates[0].occurrences.len(), 3);
|
|
164
|
+
|
|
165
|
+
Ok(())
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#[test]
|
|
169
|
+
fn classifies_firebase_options_api_key_separately() -> Result<(), Box<dyn std::error::Error>> {
|
|
170
|
+
let fixture = tempfile::tempdir()?;
|
|
171
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
172
|
+
write(
|
|
173
|
+
&fixture,
|
|
174
|
+
"lib/firebase_options.dart",
|
|
175
|
+
"const options = FirebaseOptions(
|
|
176
|
+
apiKey: 'DartDecimateFirebaseKeyValue123456789',
|
|
177
|
+
appId: '1:123:web:abc',
|
|
178
|
+
messagingSenderId: '123',
|
|
179
|
+
projectId: 'example-project',
|
|
180
|
+
);
|
|
181
|
+
",
|
|
182
|
+
)?;
|
|
183
|
+
|
|
184
|
+
let project = scan_project(fixture.path())?;
|
|
185
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
186
|
+
|
|
187
|
+
assert_eq!(report.total_occurrences, 1);
|
|
188
|
+
assert_eq!(
|
|
189
|
+
report.candidates[0].rule_id,
|
|
190
|
+
"dart-decimate/security-firebase-api-key"
|
|
191
|
+
);
|
|
192
|
+
assert_eq!(report.candidates[0].sink, "firebase-api-key");
|
|
193
|
+
|
|
194
|
+
Ok(())
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
#[test]
|
|
198
|
+
fn skips_dynamic_firebase_options_api_key() -> Result<(), Box<dyn std::error::Error>> {
|
|
199
|
+
let fixture = tempfile::tempdir()?;
|
|
200
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
201
|
+
write(
|
|
202
|
+
&fixture,
|
|
203
|
+
"lib/firebase_options.dart",
|
|
204
|
+
"const options = FirebaseOptions(
|
|
205
|
+
apiKey: '$firebaseApiKey',
|
|
206
|
+
appId: '1:123:web:abc',
|
|
207
|
+
);
|
|
208
|
+
const emptyOptions = FirebaseOptions(apiKey: '', appId: '1:123:web:def');
|
|
209
|
+
",
|
|
210
|
+
)?;
|
|
211
|
+
|
|
212
|
+
let project = scan_project(fixture.path())?;
|
|
213
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
214
|
+
|
|
215
|
+
assert!(report.candidates.is_empty());
|
|
216
|
+
assert_eq!(report.total_occurrences, 0);
|
|
217
|
+
|
|
218
|
+
Ok(())
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#[test]
|
|
222
|
+
fn classifies_compact_firebase_options_literals_by_argument()
|
|
223
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
224
|
+
let fixture = tempfile::tempdir()?;
|
|
225
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
226
|
+
write(
|
|
227
|
+
&fixture,
|
|
228
|
+
"lib/firebase_options.dart",
|
|
229
|
+
"const options = FirebaseOptions(apiKey: 'DartDecimateFirebaseKeyValue123456789', appId: '1:123:web:abc', clientSecret: 'dart_decimate_fixture_value_1234567890');\n",
|
|
230
|
+
)?;
|
|
231
|
+
|
|
232
|
+
let project = scan_project(fixture.path())?;
|
|
233
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
234
|
+
let mut rules = report
|
|
235
|
+
.candidates
|
|
236
|
+
.iter()
|
|
237
|
+
.map(|candidate| candidate.rule_id.as_str())
|
|
238
|
+
.collect::<Vec<_>>();
|
|
239
|
+
rules.sort_unstable();
|
|
240
|
+
|
|
241
|
+
assert_eq!(report.total_occurrences, 2);
|
|
242
|
+
assert_eq!(
|
|
243
|
+
rules,
|
|
244
|
+
vec![
|
|
245
|
+
"dart-decimate/security-firebase-api-key",
|
|
246
|
+
"dart-decimate/security-hardcoded-secret"
|
|
247
|
+
]
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
Ok(())
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
#[test]
|
|
254
|
+
fn classifies_newline_firebase_options_api_key_by_argument()
|
|
255
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
256
|
+
let fixture = tempfile::tempdir()?;
|
|
257
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
258
|
+
write(
|
|
259
|
+
&fixture,
|
|
260
|
+
"lib/firebase_options.dart",
|
|
261
|
+
"const options = FirebaseOptions(apiKey:
|
|
262
|
+
'DartDecimateFirebaseKeyValue123456789', appId: '1:123:web:abc', clientSecret: 'dart_decimate_fixture_value_1234567890');\n",
|
|
263
|
+
)?;
|
|
264
|
+
|
|
265
|
+
let project = scan_project(fixture.path())?;
|
|
266
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
267
|
+
let mut rules = report
|
|
268
|
+
.candidates
|
|
269
|
+
.iter()
|
|
270
|
+
.map(|candidate| candidate.rule_id.as_str())
|
|
271
|
+
.collect::<Vec<_>>();
|
|
272
|
+
rules.sort_unstable();
|
|
273
|
+
|
|
274
|
+
assert_eq!(report.total_occurrences, 2);
|
|
275
|
+
assert_eq!(
|
|
276
|
+
rules,
|
|
277
|
+
vec![
|
|
278
|
+
"dart-decimate/security-firebase-api-key",
|
|
279
|
+
"dart-decimate/security-hardcoded-secret"
|
|
280
|
+
]
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
Ok(())
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
#[test]
|
|
287
|
+
fn classifies_newline_firebase_options_secret_argument() -> Result<(), Box<dyn std::error::Error>> {
|
|
288
|
+
let fixture = tempfile::tempdir()?;
|
|
289
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
290
|
+
write(
|
|
291
|
+
&fixture,
|
|
292
|
+
"lib/firebase_options.dart",
|
|
293
|
+
"const options = FirebaseOptions(
|
|
294
|
+
apiKey: 'DartDecimateFirebaseKeyValue123456789',
|
|
295
|
+
appId: '1:123:web:abc',
|
|
296
|
+
clientSecret:
|
|
297
|
+
'dart_decimate_fixture_value_1234567890',
|
|
298
|
+
projectId: 'example-project',
|
|
299
|
+
);
|
|
300
|
+
",
|
|
301
|
+
)?;
|
|
302
|
+
|
|
303
|
+
let project = scan_project(fixture.path())?;
|
|
304
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
305
|
+
let mut rules = report
|
|
306
|
+
.candidates
|
|
307
|
+
.iter()
|
|
308
|
+
.map(|candidate| candidate.rule_id.as_str())
|
|
309
|
+
.collect::<Vec<_>>();
|
|
310
|
+
rules.sort_unstable();
|
|
311
|
+
|
|
312
|
+
assert_eq!(report.total_occurrences, 2);
|
|
313
|
+
assert_eq!(
|
|
314
|
+
rules,
|
|
315
|
+
vec![
|
|
316
|
+
"dart-decimate/security-firebase-api-key",
|
|
317
|
+
"dart-decimate/security-hardcoded-secret"
|
|
318
|
+
]
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
Ok(())
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
#[test]
|
|
325
|
+
fn locates_javascript_password_autofill_at_assignment_literal()
|
|
326
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
327
|
+
let fixture = tempfile::tempdir()?;
|
|
328
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
329
|
+
write(
|
|
330
|
+
&fixture,
|
|
331
|
+
"lib/main.dart",
|
|
332
|
+
"const loginJs = '''
|
|
333
|
+
var inputs = document.querySelectorAll('input');
|
|
334
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
335
|
+
if (inputs[i].type === 'password')
|
|
336
|
+
inputs[i].value = 'dart_decimate_fixture_password_value_12345';
|
|
337
|
+
}
|
|
338
|
+
''';
|
|
339
|
+
",
|
|
340
|
+
)?;
|
|
341
|
+
|
|
342
|
+
let project = scan_project(fixture.path())?;
|
|
343
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
344
|
+
|
|
345
|
+
assert_eq!(report.total_occurrences, 1);
|
|
346
|
+
assert_eq!(
|
|
347
|
+
report.candidates[0].rule_id,
|
|
348
|
+
"dart-decimate/security-hardcoded-secret"
|
|
349
|
+
);
|
|
350
|
+
assert_eq!(report.candidates[0].occurrences[0].location.line, 5);
|
|
351
|
+
|
|
352
|
+
Ok(())
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
#[test]
|
|
356
|
+
fn skips_javascript_password_autofill_when_assignment_is_not_literal()
|
|
357
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
358
|
+
let fixture = tempfile::tempdir()?;
|
|
359
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
360
|
+
write(
|
|
361
|
+
&fixture,
|
|
362
|
+
"lib/main.dart",
|
|
363
|
+
"const loginJs = '''
|
|
364
|
+
if (input.type === 'password') input.value = token || 'dart_decimate_fixture_password_value_12345';
|
|
365
|
+
''';
|
|
366
|
+
",
|
|
367
|
+
)?;
|
|
368
|
+
|
|
369
|
+
let project = scan_project(fixture.path())?;
|
|
370
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
371
|
+
|
|
372
|
+
assert!(report.candidates.is_empty());
|
|
373
|
+
assert_eq!(report.total_occurrences, 0);
|
|
374
|
+
|
|
375
|
+
Ok(())
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
#[test]
|
|
379
|
+
fn skips_javascript_password_autofill_when_password_hint_is_unrelated()
|
|
380
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
381
|
+
let fixture = tempfile::tempdir()?;
|
|
382
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
383
|
+
write(
|
|
384
|
+
&fixture,
|
|
385
|
+
"lib/main.dart",
|
|
386
|
+
"const loginJs = '''
|
|
387
|
+
if (input.type === 'password' && passwordResetForm.email) passwordResetForm.email.value = 'alice@company.invalid';
|
|
388
|
+
''';
|
|
389
|
+
",
|
|
390
|
+
)?;
|
|
391
|
+
|
|
392
|
+
let project = scan_project(fixture.path())?;
|
|
393
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
394
|
+
|
|
395
|
+
assert!(report.candidates.is_empty());
|
|
396
|
+
assert_eq!(report.total_occurrences, 0);
|
|
397
|
+
|
|
398
|
+
Ok(())
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
#[test]
|
|
402
|
+
fn skips_javascript_password_autofill_when_value_target_is_unrelated()
|
|
403
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
404
|
+
let fixture = tempfile::tempdir()?;
|
|
405
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
406
|
+
write(
|
|
407
|
+
&fixture,
|
|
408
|
+
"lib/main.dart",
|
|
409
|
+
"const loginJs = '''
|
|
410
|
+
if (input.type === 'password') email.value = 'alice@company.invalid';
|
|
411
|
+
''';
|
|
412
|
+
",
|
|
413
|
+
)?;
|
|
414
|
+
|
|
415
|
+
let project = scan_project(fixture.path())?;
|
|
416
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
417
|
+
|
|
418
|
+
assert!(report.candidates.is_empty());
|
|
419
|
+
assert_eq!(report.total_occurrences, 0);
|
|
420
|
+
|
|
421
|
+
Ok(())
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
#[test]
|
|
425
|
+
fn skips_javascript_password_autofill_when_password_hint_is_negative()
|
|
426
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
427
|
+
let fixture = tempfile::tempdir()?;
|
|
428
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
429
|
+
write(
|
|
430
|
+
&fixture,
|
|
431
|
+
"lib/main.dart",
|
|
432
|
+
"const loginJs = '''
|
|
433
|
+
if (input.type !== 'password') input.value = 'alice@company.invalid';
|
|
434
|
+
if (input.matches(':not([type=password])')) input.value = 'alice@company.invalid';
|
|
435
|
+
''';
|
|
436
|
+
",
|
|
437
|
+
)?;
|
|
438
|
+
|
|
439
|
+
let project = scan_project(fixture.path())?;
|
|
440
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
441
|
+
|
|
442
|
+
assert!(report.candidates.is_empty());
|
|
443
|
+
assert_eq!(report.total_occurrences, 0);
|
|
444
|
+
|
|
445
|
+
Ok(())
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
#[test]
|
|
449
|
+
fn skips_javascript_password_autofill_when_target_selector_is_negative()
|
|
450
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
451
|
+
let fixture = tempfile::tempdir()?;
|
|
452
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
453
|
+
write(
|
|
454
|
+
&fixture,
|
|
455
|
+
"lib/main.dart",
|
|
456
|
+
"const loginJs = '''
|
|
457
|
+
document.querySelector('input:not([type=password])').value = 'alice@company.invalid';
|
|
458
|
+
''';
|
|
459
|
+
",
|
|
460
|
+
)?;
|
|
461
|
+
|
|
462
|
+
let project = scan_project(fixture.path())?;
|
|
463
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
464
|
+
|
|
465
|
+
assert!(report.candidates.is_empty());
|
|
466
|
+
assert_eq!(report.total_occurrences, 0);
|
|
467
|
+
|
|
468
|
+
Ok(())
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
#[test]
|
|
472
|
+
fn skips_javascript_password_autofill_when_only_parent_target_is_password_named()
|
|
473
|
+
-> Result<(), Box<dyn std::error::Error>> {
|
|
474
|
+
let fixture = tempfile::tempdir()?;
|
|
475
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
476
|
+
write(
|
|
477
|
+
&fixture,
|
|
478
|
+
"lib/main.dart",
|
|
479
|
+
"const loginJs = '''
|
|
480
|
+
passwordResetForm.email.value = 'alice@company.invalid';
|
|
481
|
+
if (passwordResetForm.email) passwordResetForm.email.value = 'alice@company.invalid';
|
|
482
|
+
''';
|
|
483
|
+
",
|
|
484
|
+
)?;
|
|
485
|
+
|
|
486
|
+
let project = scan_project(fixture.path())?;
|
|
487
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
488
|
+
|
|
489
|
+
assert!(report.candidates.is_empty());
|
|
490
|
+
assert_eq!(report.total_occurrences, 0);
|
|
491
|
+
|
|
492
|
+
Ok(())
|
|
493
|
+
}
|
|
494
|
+
|
|
106
495
|
#[test]
|
|
107
496
|
fn skips_flutter_commands_logs_and_interpolated_bearer_headers()
|
|
108
497
|
-> Result<(), Box<dyn std::error::Error>> {
|
package/src/security.rs
CHANGED
|
@@ -58,6 +58,8 @@ pub struct SecurityCandidate {
|
|
|
58
58
|
pub enum SecurityCategory {
|
|
59
59
|
/// Secret-shaped literal or secret-named assignment.
|
|
60
60
|
HardcodedSecret,
|
|
61
|
+
/// Firebase client API key in `FirebaseOptions`.
|
|
62
|
+
FirebaseApiKey,
|
|
61
63
|
/// Remote cleartext HTTP transport.
|
|
62
64
|
InsecureTransport,
|
|
63
65
|
/// TLS validation bypass.
|
|
@@ -76,6 +78,7 @@ impl SecurityCategory {
|
|
|
76
78
|
const fn rule_id(self) -> &'static str {
|
|
77
79
|
match self {
|
|
78
80
|
Self::HardcodedSecret => "dart-decimate/security-hardcoded-secret",
|
|
81
|
+
Self::FirebaseApiKey => "dart-decimate/security-firebase-api-key",
|
|
79
82
|
Self::InsecureTransport => "dart-decimate/security-insecure-transport",
|
|
80
83
|
Self::TlsBypass => "dart-decimate/security-tls-bypass",
|
|
81
84
|
Self::WebViewRisk => "dart-decimate/security-webview-risk",
|
|
@@ -348,6 +351,9 @@ const fn verification_prompt(category: SecurityCategory) -> &'static str {
|
|
|
348
351
|
SecurityCategory::HardcodedSecret => {
|
|
349
352
|
"Verify whether this literal is a real secret and rotate it if confirmed."
|
|
350
353
|
}
|
|
354
|
+
SecurityCategory::FirebaseApiKey => {
|
|
355
|
+
"Verify it is Firebase-provisioned, restricted to Firebase APIs, and covered by Security Rules and App Check."
|
|
356
|
+
}
|
|
351
357
|
SecurityCategory::InsecureTransport => {
|
|
352
358
|
"Verify whether this remote HTTP endpoint can expose sensitive traffic."
|
|
353
359
|
}
|
package/src/security_gate.rs
CHANGED
|
@@ -6,6 +6,7 @@ use std::process::Command;
|
|
|
6
6
|
use petgraph::visit::EdgeRef;
|
|
7
7
|
use thiserror::Error;
|
|
8
8
|
|
|
9
|
+
use crate::changed_scope::RefSuggestions;
|
|
9
10
|
use crate::graph::normalize_against;
|
|
10
11
|
use crate::output::{FindingKind, JsonReport, JsonSecurityOccurrence, Severity, Verdict};
|
|
11
12
|
use crate::{ModuleGraph, find_dead_code};
|
|
@@ -33,7 +34,7 @@ pub(crate) enum SecurityDiffSource {
|
|
|
33
34
|
pub enum SecurityGateError {
|
|
34
35
|
/// Security gates need an explicit diff.
|
|
35
36
|
#[error(
|
|
36
|
-
"security --gate new or newly-reachable requires --diff-file PATH, --diff-stdin,
|
|
37
|
+
"security --gate new or newly-reachable requires --diff-file PATH, --diff-stdin, --changed-since REF, or --compare REF"
|
|
37
38
|
)]
|
|
38
39
|
MissingDiffFile,
|
|
39
40
|
/// Diff file could not be read.
|
|
@@ -51,12 +52,14 @@ pub enum SecurityGateError {
|
|
|
51
52
|
source: std::io::Error,
|
|
52
53
|
},
|
|
53
54
|
/// Git returned a non-zero status.
|
|
54
|
-
#[error("git diff failed for security gate base {base:?}: {stderr}")]
|
|
55
|
+
#[error("git diff failed for security gate base {base:?}: {stderr}{suggestions}")]
|
|
55
56
|
GitDiff {
|
|
56
57
|
/// Base revision passed by the caller.
|
|
57
58
|
base: String,
|
|
58
59
|
/// Stderr from git.
|
|
59
60
|
stderr: String,
|
|
61
|
+
/// Similar refs found in the local repository.
|
|
62
|
+
suggestions: RefSuggestions,
|
|
60
63
|
},
|
|
61
64
|
/// Untracked file scope could not be read.
|
|
62
65
|
#[error("failed to read untracked file {path}: {source}")]
|
|
@@ -129,6 +132,7 @@ pub(crate) fn changed_lines_from_git(
|
|
|
129
132
|
return Err(SecurityGateError::GitDiff {
|
|
130
133
|
base: base.to_owned(),
|
|
131
134
|
stderr: String::from_utf8_lossy(&output.stderr).trim().to_owned(),
|
|
135
|
+
suggestions: RefSuggestions::for_base(root, base),
|
|
132
136
|
});
|
|
133
137
|
}
|
|
134
138
|
|
|
@@ -268,6 +272,7 @@ fn add_untracked_lines(
|
|
|
268
272
|
return Err(SecurityGateError::GitDiff {
|
|
269
273
|
base: base.to_owned(),
|
|
270
274
|
stderr: String::from_utf8_lossy(&output.stderr).trim().to_owned(),
|
|
275
|
+
suggestions: RefSuggestions::default(),
|
|
271
276
|
});
|
|
272
277
|
}
|
|
273
278
|
|