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/cli/scope_args.rs
CHANGED
|
@@ -18,6 +18,7 @@ pub(super) fn report_command(command: Command) -> Command {
|
|
|
18
18
|
.arg(workspace_arg())
|
|
19
19
|
.arg(changed_workspaces_arg())
|
|
20
20
|
.arg(changed_since_arg())
|
|
21
|
+
.arg(compare_arg())
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
pub(super) fn file_arg() -> Arg {
|
|
@@ -53,6 +54,15 @@ pub(super) fn changed_since_arg() -> Arg {
|
|
|
53
54
|
.long("changed-since")
|
|
54
55
|
.value_name("REF")
|
|
55
56
|
.help("Scope findings to files changed since a Git ref")
|
|
57
|
+
.conflicts_with("compare")
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
pub(super) fn compare_arg() -> Arg {
|
|
61
|
+
Arg::new("compare")
|
|
62
|
+
.long("compare")
|
|
63
|
+
.value_name("REF")
|
|
64
|
+
.help("Alias for --changed-since; scope findings to files changed since a Git ref")
|
|
65
|
+
.conflicts_with("changed-since")
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
pub(super) fn workspace_patterns(command: ReportCommand, subcommand: &ArgMatches) -> Vec<String> {
|
|
@@ -90,7 +100,10 @@ pub(super) fn changed_workspaces(
|
|
|
90
100
|
|
|
91
101
|
pub(super) fn changed_since(command: ReportCommand, subcommand: &ArgMatches) -> Option<String> {
|
|
92
102
|
if supports_report_scope(command) {
|
|
93
|
-
subcommand
|
|
103
|
+
subcommand
|
|
104
|
+
.get_one::<String>("changed-since")
|
|
105
|
+
.or_else(|| subcommand.get_one::<String>("compare"))
|
|
106
|
+
.cloned()
|
|
94
107
|
} else {
|
|
95
108
|
None
|
|
96
109
|
}
|
package/src/cli/security_args.rs
CHANGED
|
@@ -143,7 +143,10 @@ pub(super) fn security_cli_options(
|
|
|
143
143
|
sarif_file: matches.get_one::<PathBuf>("sarif-file").cloned(),
|
|
144
144
|
gate: security_gate_mode(matches),
|
|
145
145
|
diff: security_diff(matches),
|
|
146
|
-
changed_since: matches
|
|
146
|
+
changed_since: matches
|
|
147
|
+
.get_one::<String>("changed-since")
|
|
148
|
+
.or_else(|| matches.get_one::<String>("compare"))
|
|
149
|
+
.cloned(),
|
|
147
150
|
ci: matches.get_flag("ci"),
|
|
148
151
|
fail_on_issues: matches.get_flag("fail-on-issues"),
|
|
149
152
|
summary: matches.get_flag("summary"),
|
package/src/cli/tests.rs
CHANGED
|
@@ -239,6 +239,65 @@ fn check_command_reports_duplicate_exports() -> Result<(), Box<dyn std::error::E
|
|
|
239
239
|
Ok(())
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
#[test]
|
|
243
|
+
fn check_command_emits_html_report() -> Result<(), Box<dyn std::error::Error>> {
|
|
244
|
+
let fixture = tempfile::tempdir()?;
|
|
245
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
246
|
+
write(&fixture, "lib/a.dart", "import 'b.dart';\nclass A {}\n")?;
|
|
247
|
+
write(&fixture, "lib/b.dart", "import 'a.dart';\nclass B {}\n")?;
|
|
248
|
+
let mut output = Vec::new();
|
|
249
|
+
|
|
250
|
+
let code = run_from(
|
|
251
|
+
[
|
|
252
|
+
"dart-decimate",
|
|
253
|
+
"check",
|
|
254
|
+
fixture.path().to_str().unwrap_or("."),
|
|
255
|
+
"--format",
|
|
256
|
+
"html",
|
|
257
|
+
],
|
|
258
|
+
&mut output,
|
|
259
|
+
)?;
|
|
260
|
+
|
|
261
|
+
let html = String::from_utf8(output)?;
|
|
262
|
+
assert_eq!(code, 1);
|
|
263
|
+
assert!(html.starts_with("<!doctype html>"));
|
|
264
|
+
assert!(html.contains("<h1>check report</h1>"));
|
|
265
|
+
assert!(html.contains("Circular dependency"));
|
|
266
|
+
assert!(html.contains("Why"));
|
|
267
|
+
assert!(html.contains("Best"));
|
|
268
|
+
assert!(html.contains("lib/a.dart"));
|
|
269
|
+
|
|
270
|
+
Ok(())
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
#[test]
|
|
274
|
+
fn open_html_rejects_explicit_non_html_format() -> Result<(), Box<dyn std::error::Error>> {
|
|
275
|
+
let fixture = tempfile::tempdir()?;
|
|
276
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
277
|
+
write(&fixture, "lib/main.dart", "void main() {}\n")?;
|
|
278
|
+
let mut output = Vec::new();
|
|
279
|
+
|
|
280
|
+
let result = run_from(
|
|
281
|
+
[
|
|
282
|
+
"dart-decimate",
|
|
283
|
+
"check",
|
|
284
|
+
fixture.path().to_str().unwrap_or("."),
|
|
285
|
+
"--format",
|
|
286
|
+
"json",
|
|
287
|
+
"--open",
|
|
288
|
+
],
|
|
289
|
+
&mut output,
|
|
290
|
+
);
|
|
291
|
+
let Err(error) = result else {
|
|
292
|
+
panic!("json reports cannot be opened as HTML");
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
assert!(matches!(error, CliError::HtmlOpenRequiresHtml));
|
|
296
|
+
assert!(output.is_empty());
|
|
297
|
+
|
|
298
|
+
Ok(())
|
|
299
|
+
}
|
|
300
|
+
|
|
242
301
|
#[test]
|
|
243
302
|
fn check_command_reports_boundaries_and_unresolved_imports()
|
|
244
303
|
-> Result<(), Box<dyn std::error::Error>> {
|
|
@@ -507,6 +566,37 @@ fn check_command_treats_public_library_files_as_default_entry_points()
|
|
|
507
566
|
Ok(())
|
|
508
567
|
}
|
|
509
568
|
|
|
569
|
+
#[test]
|
|
570
|
+
fn output_alias_commands_run_check_formats() -> Result<(), Box<dyn std::error::Error>> {
|
|
571
|
+
let fixture = tempfile::tempdir()?;
|
|
572
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
573
|
+
write(&fixture, "lib/a.dart", "import 'b.dart';\nclass A {}\n")?;
|
|
574
|
+
write(&fixture, "lib/b.dart", "import 'a.dart';\nclass B {}\n")?;
|
|
575
|
+
let root = fixture.path().to_str().unwrap_or(".");
|
|
576
|
+
|
|
577
|
+
let mut output = Vec::new();
|
|
578
|
+
let code = run_from(["dart-decimate", "json", root], &mut output)?;
|
|
579
|
+
let json = serde_json::from_slice::<Value>(&output)?;
|
|
580
|
+
assert_eq!(code, 1);
|
|
581
|
+
assert_eq!(json["command"], "check");
|
|
582
|
+
assert_eq!(json["summary"]["cycles"], 1);
|
|
583
|
+
|
|
584
|
+
output.clear();
|
|
585
|
+
let code = run_from(["dart-decimate", "html", root, "--stdout"], &mut output)?;
|
|
586
|
+
let html = String::from_utf8(std::mem::take(&mut output))?;
|
|
587
|
+
assert_eq!(code, 1);
|
|
588
|
+
assert!(html.starts_with("<!doctype html>"));
|
|
589
|
+
assert!(html.contains("Circular dependency"));
|
|
590
|
+
|
|
591
|
+
let code = run_from(["dart-decimate", "human", root], &mut output)?;
|
|
592
|
+
let human = String::from_utf8(output)?;
|
|
593
|
+
assert_eq!(code, 1);
|
|
594
|
+
assert!(human.contains("Dart Decimate check"));
|
|
595
|
+
assert!(human.contains("Why"));
|
|
596
|
+
|
|
597
|
+
Ok(())
|
|
598
|
+
}
|
|
599
|
+
|
|
510
600
|
fn write(fixture: &TempDir, path: &str, source: &str) -> Result<(), std::io::Error> {
|
|
511
601
|
let path = fixture.path().join(path);
|
|
512
602
|
if let Some(parent) = path.parent() {
|
package/src/cli/trace_run.rs
CHANGED
|
@@ -56,6 +56,9 @@ fn run_trace_file<W: Write>(
|
|
|
56
56
|
serde_json::to_writer_pretty(&mut *writer, &report)?;
|
|
57
57
|
writeln!(writer)?;
|
|
58
58
|
}
|
|
59
|
+
ReportOutputFormat::Html | ReportOutputFormat::HtmlOpen => {
|
|
60
|
+
unreachable!("HTML is rejected before trace rendering")
|
|
61
|
+
}
|
|
59
62
|
ReportOutputFormat::Sarif => unreachable!("SARIF is rejected before trace rendering"),
|
|
60
63
|
}
|
|
61
64
|
Ok(())
|
|
@@ -82,6 +85,9 @@ fn run_trace_symbol<W: Write>(
|
|
|
82
85
|
serde_json::to_writer_pretty(&mut *writer, &report)?;
|
|
83
86
|
writeln!(writer)?;
|
|
84
87
|
}
|
|
88
|
+
ReportOutputFormat::Html | ReportOutputFormat::HtmlOpen => {
|
|
89
|
+
unreachable!("HTML is rejected before trace rendering")
|
|
90
|
+
}
|
|
85
91
|
ReportOutputFormat::Sarif => unreachable!("SARIF is rejected before trace rendering"),
|
|
86
92
|
}
|
|
87
93
|
Ok(())
|
|
@@ -104,6 +110,9 @@ fn run_trace_dependency<W: Write>(
|
|
|
104
110
|
serde_json::to_writer_pretty(&mut *writer, &report)?;
|
|
105
111
|
writeln!(writer)?;
|
|
106
112
|
}
|
|
113
|
+
ReportOutputFormat::Html | ReportOutputFormat::HtmlOpen => {
|
|
114
|
+
unreachable!("HTML is rejected before trace rendering")
|
|
115
|
+
}
|
|
107
116
|
ReportOutputFormat::Sarif => unreachable!("SARIF is rejected before trace rendering"),
|
|
108
117
|
}
|
|
109
118
|
Ok(())
|
|
@@ -125,6 +134,9 @@ fn run_trace_clone<W: Write>(
|
|
|
125
134
|
serde_json::to_writer_pretty(&mut *writer, &report)?;
|
|
126
135
|
writeln!(writer)?;
|
|
127
136
|
}
|
|
137
|
+
ReportOutputFormat::Html | ReportOutputFormat::HtmlOpen => {
|
|
138
|
+
unreachable!("HTML is rejected before trace rendering")
|
|
139
|
+
}
|
|
128
140
|
ReportOutputFormat::Sarif => unreachable!("SARIF is rejected before trace rendering"),
|
|
129
141
|
}
|
|
130
142
|
Ok(())
|
package/src/cli.rs
CHANGED
|
@@ -16,8 +16,8 @@ use crate::config::{
|
|
|
16
16
|
apply_rules_to_report, load_dart_decimate_config,
|
|
17
17
|
};
|
|
18
18
|
use crate::output::{
|
|
19
|
-
ReportCommand, Verdict, build_json_report, filter_report_findings,
|
|
20
|
-
render_sarif_report,
|
|
19
|
+
ReportCommand, Verdict, build_json_report, filter_report_findings, render_html_report,
|
|
20
|
+
render_human_report, render_sarif_report,
|
|
21
21
|
};
|
|
22
22
|
use crate::scan::{ScanOptions, scan_project_with_options};
|
|
23
23
|
use crate::{
|
|
@@ -45,6 +45,7 @@ mod fix_run;
|
|
|
45
45
|
mod flags_args;
|
|
46
46
|
mod health_args;
|
|
47
47
|
mod hooks_run;
|
|
48
|
+
mod html_open;
|
|
48
49
|
mod impact_run;
|
|
49
50
|
mod init_run;
|
|
50
51
|
mod inspect_args;
|
|
@@ -283,6 +284,10 @@ fn run_request<W: Write>(request: &CommandRequest, mut writer: W) -> Result<i32,
|
|
|
283
284
|
|
|
284
285
|
match request.format {
|
|
285
286
|
ReportOutputFormat::Human => writer.write_all(render_human_report(&report).as_bytes())?,
|
|
287
|
+
ReportOutputFormat::HtmlOpen => {
|
|
288
|
+
html_open::write_and_open_html_report(&report, &mut writer)?;
|
|
289
|
+
}
|
|
290
|
+
ReportOutputFormat::Html => writer.write_all(render_html_report(&report).as_bytes())?,
|
|
286
291
|
ReportOutputFormat::Json => {
|
|
287
292
|
serde_json::to_writer_pretty(&mut writer, &report)?;
|
|
288
293
|
writeln!(writer)?;
|
|
@@ -307,7 +312,43 @@ fn command() -> Command {
|
|
|
307
312
|
.about("Rust-native Dart and Flutter module-graph intelligence")
|
|
308
313
|
.subcommand_required(false)
|
|
309
314
|
.arg_required_else_help(false);
|
|
310
|
-
schema_subcommands(support_subcommands(
|
|
315
|
+
schema_subcommands(support_subcommands(shortcut_subcommands(
|
|
316
|
+
report_subcommands(command),
|
|
317
|
+
)))
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
fn shortcut_subcommands(command: Command) -> Command {
|
|
321
|
+
command
|
|
322
|
+
.subcommand(output_shortcut_command(
|
|
323
|
+
"human",
|
|
324
|
+
"Shortcut for check with readable terminal output",
|
|
325
|
+
))
|
|
326
|
+
.subcommand(output_shortcut_command(
|
|
327
|
+
"json",
|
|
328
|
+
"Shortcut for check with JSON output",
|
|
329
|
+
))
|
|
330
|
+
.subcommand(
|
|
331
|
+
output_shortcut_command("html", "Shortcut for check with a browser HTML report").arg(
|
|
332
|
+
Arg::new("stdout")
|
|
333
|
+
.long("stdout")
|
|
334
|
+
.help("Print the HTML report instead of opening it in the browser")
|
|
335
|
+
.action(ArgAction::SetTrue),
|
|
336
|
+
),
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
fn output_shortcut_command(name: &'static str, about: &'static str) -> Command {
|
|
341
|
+
Command::new(name)
|
|
342
|
+
.about(about)
|
|
343
|
+
.after_help("All check flags can also be passed to this shortcut.")
|
|
344
|
+
.arg(common_args::root_arg())
|
|
345
|
+
.arg(
|
|
346
|
+
Arg::new("format")
|
|
347
|
+
.long("format")
|
|
348
|
+
.value_name("FORMAT")
|
|
349
|
+
.value_parser(common_args::REPORT_FORMAT_VALUES)
|
|
350
|
+
.hide(true),
|
|
351
|
+
)
|
|
311
352
|
}
|
|
312
353
|
|
|
313
354
|
fn report_subcommands(command: Command) -> Command {
|
|
@@ -432,11 +473,7 @@ fn request_from_matches(matches: &ArgMatches) -> Result<CommandRequest, CliError
|
|
|
432
473
|
let root = root_path(subcommand);
|
|
433
474
|
let config = load_config(&root, subcommand)?;
|
|
434
475
|
let security_cli = security_cli_options(command, subcommand);
|
|
435
|
-
let format =
|
|
436
|
-
ReportOutputFormat::Sarif
|
|
437
|
-
} else {
|
|
438
|
-
report_output_format(subcommand, &config)
|
|
439
|
-
};
|
|
476
|
+
let format = request_format(subcommand, &config, &security_cli)?;
|
|
440
477
|
let entry_points = entry_points(subcommand, &config);
|
|
441
478
|
let production = mode_args::production(subcommand, &config);
|
|
442
479
|
let symbol_options = SymbolRequestOptions {
|
|
@@ -460,7 +497,7 @@ fn request_from_matches(matches: &ArgMatches) -> Result<CommandRequest, CliError
|
|
|
460
497
|
let file_paths = scope_args::file_paths(command, subcommand);
|
|
461
498
|
let workspace_patterns = scope_args::workspace_patterns(command, subcommand);
|
|
462
499
|
let changed_workspaces = scope_args::changed_workspaces(command, subcommand);
|
|
463
|
-
let changed_since =
|
|
500
|
+
let changed_since = report_changed_since(command, subcommand, &security_cli);
|
|
464
501
|
let baseline_paths = baseline_paths(command, subcommand);
|
|
465
502
|
let save_baseline = if supports_global_baseline(command) {
|
|
466
503
|
subcommand.get_one::<PathBuf>("save-baseline").cloned()
|
|
@@ -526,6 +563,33 @@ fn request_from_matches(matches: &ArgMatches) -> Result<CommandRequest, CliError
|
|
|
526
563
|
})
|
|
527
564
|
}
|
|
528
565
|
|
|
566
|
+
fn request_format(
|
|
567
|
+
subcommand: &ArgMatches,
|
|
568
|
+
config: &DartDecimateConfig,
|
|
569
|
+
security_cli: &SecurityCliOptions,
|
|
570
|
+
) -> Result<ReportOutputFormat, CliError> {
|
|
571
|
+
let open_html = subcommand
|
|
572
|
+
.try_get_one::<bool>("open")
|
|
573
|
+
.ok()
|
|
574
|
+
.flatten()
|
|
575
|
+
.copied()
|
|
576
|
+
.unwrap_or_default();
|
|
577
|
+
let explicit_format = subcommand.value_source("format") == Some(ValueSource::CommandLine);
|
|
578
|
+
let format = if security_cli.ci {
|
|
579
|
+
ReportOutputFormat::Sarif
|
|
580
|
+
} else {
|
|
581
|
+
report_output_format(subcommand, config)
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
if !open_html {
|
|
585
|
+
return Ok(format);
|
|
586
|
+
}
|
|
587
|
+
if security_cli.ci || (explicit_format && format != ReportOutputFormat::Html) {
|
|
588
|
+
return Err(CliError::HtmlOpenRequiresHtml);
|
|
589
|
+
}
|
|
590
|
+
Ok(ReportOutputFormat::HtmlOpen)
|
|
591
|
+
}
|
|
592
|
+
|
|
529
593
|
fn validate_security_cli(
|
|
530
594
|
security_cli: &SecurityCliOptions,
|
|
531
595
|
security_options: &SecurityOptions,
|
|
@@ -540,6 +604,21 @@ fn validate_security_cli(
|
|
|
540
604
|
Ok(())
|
|
541
605
|
}
|
|
542
606
|
|
|
607
|
+
fn report_changed_since(
|
|
608
|
+
command: ReportCommand,
|
|
609
|
+
subcommand: &ArgMatches,
|
|
610
|
+
security_cli: &SecurityCliOptions,
|
|
611
|
+
) -> Option<String> {
|
|
612
|
+
let changed_since = scope_args::changed_since(command, subcommand);
|
|
613
|
+
if command == ReportCommand::Security
|
|
614
|
+
&& security_cli.gate == Some(SecurityGateMode::NewlyReachable)
|
|
615
|
+
{
|
|
616
|
+
None
|
|
617
|
+
} else {
|
|
618
|
+
changed_since
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
543
622
|
fn baseline_paths(command: ReportCommand, subcommand: &ArgMatches) -> Vec<PathBuf> {
|
|
544
623
|
let mut paths = Vec::new();
|
|
545
624
|
if supports_global_baseline(command) {
|
|
@@ -18,6 +18,11 @@ pub(super) fn aliases(rule_id: &str, kind: FindingKind) -> Vec<&'static str> {
|
|
|
18
18
|
"security-hardcoded-secret",
|
|
19
19
|
"hardcoded-secret",
|
|
20
20
|
],
|
|
21
|
+
"security-firebase-api-key" => vec![
|
|
22
|
+
"dart-decimate/security-firebase-api-key",
|
|
23
|
+
"security-firebase-api-key",
|
|
24
|
+
"firebase-api-key",
|
|
25
|
+
],
|
|
21
26
|
"security-insecure-transport" => vec![
|
|
22
27
|
"dart-decimate/security-insecure-transport",
|
|
23
28
|
"security-insecure-transport",
|
|
@@ -92,6 +97,9 @@ fn all_security_aliases() -> Vec<&'static str> {
|
|
|
92
97
|
"dart-decimate/security-hardcoded-secret",
|
|
93
98
|
"security-hardcoded-secret",
|
|
94
99
|
"hardcoded-secret",
|
|
100
|
+
"dart-decimate/security-firebase-api-key",
|
|
101
|
+
"security-firebase-api-key",
|
|
102
|
+
"firebase-api-key",
|
|
95
103
|
"dart-decimate/security-insecure-transport",
|
|
96
104
|
"security-insecure-transport",
|
|
97
105
|
"insecure-transport",
|
package/src/config/rules.rs
CHANGED
|
@@ -99,11 +99,12 @@ pub fn apply_rules_to_report(report: &mut JsonReport, rules: &RuleConfig) -> Res
|
|
|
99
99
|
report
|
|
100
100
|
.attack_surface
|
|
101
101
|
.retain(|entry| security_surface_enabled(entry, &rules));
|
|
102
|
-
report
|
|
103
|
-
.next_steps
|
|
104
|
-
.retain(|step| next_step_enabled(&step.id, &report.findings));
|
|
105
102
|
|
|
106
103
|
recompute_summary(report);
|
|
104
|
+
let has_hidden_security_surface = report.has_hidden_security_candidate_occurrences();
|
|
105
|
+
report
|
|
106
|
+
.next_steps
|
|
107
|
+
.retain(|step| next_step_enabled(&step.id, &report.findings, has_hidden_security_surface));
|
|
107
108
|
report.verdict = if report
|
|
108
109
|
.findings
|
|
109
110
|
.iter()
|
|
@@ -246,6 +247,7 @@ fn complexity_kind(rule_id: &str) -> FindingKind {
|
|
|
246
247
|
fn security_surface_enabled(entry: &JsonAttackSurfaceEntry, rules: &RuleMatcher) -> bool {
|
|
247
248
|
let rule_id = match entry.category {
|
|
248
249
|
SecurityCategory::HardcodedSecret => "dart-decimate/security-hardcoded-secret",
|
|
250
|
+
SecurityCategory::FirebaseApiKey => "dart-decimate/security-firebase-api-key",
|
|
249
251
|
SecurityCategory::InsecureTransport => "dart-decimate/security-insecure-transport",
|
|
250
252
|
SecurityCategory::TlsBypass => "dart-decimate/security-tls-bypass",
|
|
251
253
|
SecurityCategory::WebViewRisk => "dart-decimate/security-webview-risk",
|
|
@@ -256,7 +258,7 @@ fn security_surface_enabled(entry: &JsonAttackSurfaceEntry, rules: &RuleMatcher)
|
|
|
256
258
|
rules.level(rule_id, FindingKind::SecurityCandidate) != RuleLevel::Off
|
|
257
259
|
}
|
|
258
260
|
|
|
259
|
-
fn next_step_enabled(id: &str, findings: &[Finding]) -> bool {
|
|
261
|
+
fn next_step_enabled(id: &str, findings: &[Finding], has_hidden_security_surface: bool) -> bool {
|
|
260
262
|
match id {
|
|
261
263
|
"trace-unused-export" => has_kind(findings, FindingKind::UnusedExport),
|
|
262
264
|
"trace-unused-type" => has_kind(findings, FindingKind::UnusedType),
|
|
@@ -273,6 +275,9 @@ fn next_step_enabled(id: &str, findings: &[Finding]) -> bool {
|
|
|
273
275
|
| FindingKind::HighCrapScore
|
|
274
276
|
)
|
|
275
277
|
}),
|
|
278
|
+
"review-security-surface" => {
|
|
279
|
+
has_hidden_security_surface && has_kind(findings, FindingKind::SecurityCandidate)
|
|
280
|
+
}
|
|
276
281
|
_ => true,
|
|
277
282
|
}
|
|
278
283
|
}
|
package/src/config.rs
CHANGED
package/src/explain.rs
CHANGED
package/src/manifest/mcp.rs
CHANGED
|
@@ -45,6 +45,7 @@ fn mcp_overview_tools() -> Vec<Value> {
|
|
|
45
45
|
"config",
|
|
46
46
|
"since",
|
|
47
47
|
"changed_since",
|
|
48
|
+
"compare",
|
|
48
49
|
"baseline",
|
|
49
50
|
"regression_baseline",
|
|
50
51
|
"fail_on_regression",
|
|
@@ -156,6 +157,7 @@ fn analyze_mcp_tool() -> Value {
|
|
|
156
157
|
"workspace",
|
|
157
158
|
"changed_workspaces",
|
|
158
159
|
"changed_since",
|
|
160
|
+
"compare",
|
|
159
161
|
"baseline",
|
|
160
162
|
"regression_baseline",
|
|
161
163
|
"fail_on_regression",
|
|
@@ -233,6 +235,7 @@ fn dupes_mcp_tool() -> Value {
|
|
|
233
235
|
"workspace",
|
|
234
236
|
"changed_workspaces",
|
|
235
237
|
"changed_since",
|
|
238
|
+
"compare",
|
|
236
239
|
"baseline",
|
|
237
240
|
"regression_baseline",
|
|
238
241
|
"fail_on_regression",
|
|
@@ -266,6 +269,7 @@ fn health_mcp_tool() -> Value {
|
|
|
266
269
|
"workspace",
|
|
267
270
|
"changed_workspaces",
|
|
268
271
|
"changed_since",
|
|
272
|
+
"compare",
|
|
269
273
|
"baseline",
|
|
270
274
|
"regression_baseline",
|
|
271
275
|
"fail_on_regression",
|
|
@@ -363,6 +367,7 @@ fn security_mcp_tool() -> Value {
|
|
|
363
367
|
"workspace",
|
|
364
368
|
"changed_workspaces",
|
|
365
369
|
"changed_since",
|
|
370
|
+
"compare",
|
|
366
371
|
"baseline",
|
|
367
372
|
"regression_baseline",
|
|
368
373
|
"fail_on_regression",
|
|
@@ -394,6 +399,7 @@ fn feature_flags_mcp_tool() -> Value {
|
|
|
394
399
|
"workspace",
|
|
395
400
|
"changed_workspaces",
|
|
396
401
|
"changed_since",
|
|
402
|
+
"compare",
|
|
397
403
|
"baseline",
|
|
398
404
|
"regression_baseline",
|
|
399
405
|
"fail_on_regression",
|
|
@@ -444,6 +450,7 @@ fn fix_preview_mcp_tool() -> Value {
|
|
|
444
450
|
"workspace",
|
|
445
451
|
"changed_workspaces",
|
|
446
452
|
"changed_since",
|
|
453
|
+
"compare",
|
|
447
454
|
"production",
|
|
448
455
|
"action",
|
|
449
456
|
"no_create_config",
|
|
@@ -465,6 +472,7 @@ fn fix_apply_mcp_tool() -> Value {
|
|
|
465
472
|
"workspace",
|
|
466
473
|
"changed_workspaces",
|
|
467
474
|
"changed_since",
|
|
475
|
+
"compare",
|
|
468
476
|
"production",
|
|
469
477
|
"action",
|
|
470
478
|
"no_create_config",
|
|
@@ -489,6 +497,7 @@ fn audit_mcp_tool() -> Value {
|
|
|
489
497
|
"workspace",
|
|
490
498
|
"changed_workspaces",
|
|
491
499
|
"changed_since",
|
|
500
|
+
"compare",
|
|
492
501
|
"include_entry_exports",
|
|
493
502
|
"private_type_leaks",
|
|
494
503
|
"boundary",
|
package/src/manifest.rs
CHANGED
|
@@ -35,7 +35,7 @@ pub fn dart_decimate_schema() -> Value {
|
|
|
35
35
|
"default_command": "check",
|
|
36
36
|
"default_behavior": "Bare dart-decimate invocations default to dart-decimate check against the provided root.",
|
|
37
37
|
"global_flags": ["--root", "--format", "--config", "--quiet"],
|
|
38
|
-
"output_formats": ["human", "json", "sarif"],
|
|
38
|
+
"output_formats": ["human", "html", "json", "sarif"],
|
|
39
39
|
"plugins": plugins(),
|
|
40
40
|
"environment_variables": environment_variables(),
|
|
41
41
|
"mcp_tools": mcp_tools(),
|
|
@@ -121,19 +121,40 @@ fn append_commands(commands: &mut Vec<Value>, values: Value) {
|
|
|
121
121
|
|
|
122
122
|
fn analysis_commands() -> Value {
|
|
123
123
|
json!([
|
|
124
|
+
{
|
|
125
|
+
"name": "human",
|
|
126
|
+
"kind": "shortcut",
|
|
127
|
+
"description": "Shortcut for check with readable terminal output.",
|
|
128
|
+
"schema": SCHEMA_VERSION,
|
|
129
|
+
"flags": ["ROOT"]
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "json",
|
|
133
|
+
"kind": "shortcut",
|
|
134
|
+
"description": "Shortcut for check with JSON output.",
|
|
135
|
+
"schema": SCHEMA_VERSION,
|
|
136
|
+
"flags": ["ROOT"]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "html",
|
|
140
|
+
"kind": "shortcut",
|
|
141
|
+
"description": "Shortcut for check with a browser HTML report.",
|
|
142
|
+
"schema": SCHEMA_VERSION,
|
|
143
|
+
"flags": ["ROOT", "--stdout"]
|
|
144
|
+
},
|
|
124
145
|
{
|
|
125
146
|
"name": "check",
|
|
126
147
|
"kind": "combined",
|
|
127
148
|
"description": "Run all enabled graph, symbol, dependency, duplicate, health, flag, and security checks.",
|
|
128
149
|
"schema": SCHEMA_VERSION,
|
|
129
|
-
"flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--circular-deps", "--re-export-cycles", "--boundary-violations", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
150
|
+
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--circular-deps", "--re-export-cycles", "--boundary-violations", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
130
151
|
},
|
|
131
152
|
{
|
|
132
153
|
"name": "audit",
|
|
133
154
|
"kind": "audit",
|
|
134
155
|
"description": "Run changed-code graph checks scoped from a Git base ref.",
|
|
135
156
|
"schema": SCHEMA_VERSION,
|
|
136
|
-
"flags": ["--root", "--brief", "--base", "--gate", "--dead-code-baseline", "--health-baseline", "--dupes-baseline", "--max-decisions", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks"]
|
|
157
|
+
"flags": ["--root", "--brief", "--base", "--gate", "--dead-code-baseline", "--health-baseline", "--dupes-baseline", "--max-decisions", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks"]
|
|
137
158
|
},
|
|
138
159
|
{
|
|
139
160
|
"name": "review",
|
|
@@ -154,42 +175,42 @@ fn analysis_commands() -> Value {
|
|
|
154
175
|
"kind": "dead-code",
|
|
155
176
|
"description": "Find unreachable Dart files and conservative symbol-level dead code.",
|
|
156
177
|
"schema": SCHEMA_VERSION,
|
|
157
|
-
"flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
178
|
+
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
|
|
158
179
|
},
|
|
159
180
|
{
|
|
160
181
|
"name": "cycles",
|
|
161
182
|
"kind": "cycles",
|
|
162
183
|
"description": "Find import/export/part/augment dependency cycles.",
|
|
163
184
|
"schema": SCHEMA_VERSION,
|
|
164
|
-
"flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline"]
|
|
185
|
+
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline"]
|
|
165
186
|
},
|
|
166
187
|
{
|
|
167
188
|
"name": "dupes",
|
|
168
189
|
"kind": "dupes",
|
|
169
190
|
"description": "Find duplicated Dart code blocks.",
|
|
170
191
|
"schema": SCHEMA_VERSION,
|
|
171
|
-
"flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports"]
|
|
192
|
+
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports"]
|
|
172
193
|
},
|
|
173
194
|
{
|
|
174
195
|
"name": "health",
|
|
175
196
|
"kind": "health",
|
|
176
197
|
"description": "Find complex functions, coverage gaps, hotspots, and refactoring targets.",
|
|
177
198
|
"schema": SCHEMA_VERSION,
|
|
178
|
-
"flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--max-cyclomatic", "--max-cognitive", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--top"]
|
|
199
|
+
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--max-cyclomatic", "--max-cognitive", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--top"]
|
|
179
200
|
},
|
|
180
201
|
{
|
|
181
202
|
"name": "flags",
|
|
182
203
|
"kind": "flags",
|
|
183
204
|
"description": "Inventory Dart and Flutter feature flag patterns.",
|
|
184
205
|
"schema": SCHEMA_VERSION,
|
|
185
|
-
"flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top"]
|
|
206
|
+
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top"]
|
|
186
207
|
},
|
|
187
208
|
{
|
|
188
209
|
"name": "security",
|
|
189
210
|
"kind": "security",
|
|
190
211
|
"description": "Surface local deterministic security review candidates.",
|
|
191
212
|
"schema": SCHEMA_VERSION,
|
|
192
|
-
"flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top", "--surface", "--sarif-file", "--ci", "--fail-on-issues", "--summary", "--gate", "--diff-file", "--diff-stdin", "--changed-since"]
|
|
213
|
+
"flags": ["--root", "--format", "--open", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top", "--surface", "--sarif-file", "--ci", "--fail-on-issues", "--summary", "--gate", "--diff-file", "--diff-stdin", "--changed-since", "--compare"]
|
|
193
214
|
},
|
|
194
215
|
{
|
|
195
216
|
"name": "impact",
|
|
@@ -317,7 +338,7 @@ fn project_support_commands() -> Vec<Value> {
|
|
|
317
338
|
"kind": "fix",
|
|
318
339
|
"description": "Plan or apply safe auto-fixes.",
|
|
319
340
|
"schema": FIX_SCHEMA_VERSION,
|
|
320
|
-
"flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--action", "--dry-run", "--apply", "--yes", "--confirm"]
|
|
341
|
+
"flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--compare", "--action", "--dry-run", "--apply", "--yes", "--confirm"]
|
|
321
342
|
}),
|
|
322
343
|
]
|
|
323
344
|
}
|