dart-decimate 0.0.6 → 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 +1 -1
- package/README.md +17 -3
- 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/error.rs +1 -1
- package/src/cli/fix_run.rs +6 -11
- package/src/cli/scope_args.rs +14 -1
- package/src/cli/security_args.rs +4 -1
- package/src/cli.rs +16 -1
- 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 +9 -9
- package/src/mcp/cli_args.rs +4 -1
- package/src/mcp/tools.rs +9 -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/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/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ Add this to `package.json` if you want a short project command:
|
|
|
76
76
|
"dart-decimate": "dart-decimate json ."
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"dart-decimate": "^0.0.
|
|
79
|
+
"dart-decimate": "^0.0.7"
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
```
|
|
@@ -158,6 +158,10 @@ Print the HTML report instead:
|
|
|
158
158
|
npx --yes dart-decimate html . --stdout > dart-decimate-report.html
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
+
Changed files only: `npx --yes dart-decimate html . --compare origin/main`.
|
|
162
|
+
`--compare REF` aliases `--changed-since REF` and suggests similar branches when
|
|
163
|
+
the ref is not found.
|
|
164
|
+
|
|
161
165
|
To run the GitHub version directly:
|
|
162
166
|
|
|
163
167
|
```bash
|
|
@@ -321,6 +325,7 @@ Dart Decimate finds candidates for:
|
|
|
321
325
|
- risky WebView settings
|
|
322
326
|
- process execution
|
|
323
327
|
- raw SQL
|
|
328
|
+
- Firebase client API keys in `FirebaseOptions`
|
|
324
329
|
- plain local storage of secret-like material
|
|
325
330
|
|
|
326
331
|
Useful commands:
|
|
@@ -329,8 +334,13 @@ Useful commands:
|
|
|
329
334
|
dart-decimate security . --surface --format json
|
|
330
335
|
dart-decimate security . --ci --sarif-file dart-decimate-security.sarif
|
|
331
336
|
git diff --cached --unified=0 | dart-decimate security . --gate new --diff-stdin --format json
|
|
337
|
+
dart-decimate security . --gate newly-reachable --compare origin/main --format json
|
|
332
338
|
```
|
|
333
339
|
|
|
340
|
+
`--gate new` keeps candidates on added lines. `--gate newly-reachable` keeps
|
|
341
|
+
reachable candidates affected by changed files. Both accept `--compare REF`,
|
|
342
|
+
`--changed-since REF`, `--diff-file PATCH`, or `--diff-stdin`.
|
|
343
|
+
|
|
334
344
|
### 9. PR Risk
|
|
335
345
|
|
|
336
346
|
Use this before merging changed code.
|
|
@@ -431,6 +441,10 @@ Example shape:
|
|
|
431
441
|
}
|
|
432
442
|
```
|
|
433
443
|
|
|
444
|
+
When grouped security findings hide additional occurrences, `next_steps` can
|
|
445
|
+
include `review-security-surface`, which reruns
|
|
446
|
+
`dart-decimate security . --format json --surface`.
|
|
447
|
+
|
|
434
448
|
If a JSON command fails before a report can be built, stdout still stays
|
|
435
449
|
machine-readable:
|
|
436
450
|
|
|
@@ -526,7 +540,7 @@ rules = ["lib/domain:lib/ui"]
|
|
|
526
540
|
|
|
527
541
|
[security]
|
|
528
542
|
surface = true
|
|
529
|
-
categories = ["hardcoded-secret", "insecure-transport", "tls-bypass"]
|
|
543
|
+
categories = ["hardcoded-secret", "firebase-api-key", "insecure-transport", "tls-bypass"]
|
|
530
544
|
|
|
531
545
|
[rules]
|
|
532
546
|
unused-files = "error"
|
|
@@ -675,7 +689,7 @@ This repository forbids `unsafe_code`.
|
|
|
675
689
|
|
|
676
690
|
## Release Flow
|
|
677
691
|
|
|
678
|
-
Current version: `0.0.
|
|
692
|
+
Current version: `0.0.7`.
|
|
679
693
|
|
|
680
694
|
After the first public release, changes should go through pull requests.
|
|
681
695
|
|
package/package.json
CHANGED
package/src/baseline.rs
CHANGED
|
@@ -378,6 +378,10 @@ pub fn apply_baseline_to_report(report: &mut JsonReport, baseline: &Baseline) {
|
|
|
378
378
|
.retain(|finding| !known.contains(finding_identity(finding).as_str()));
|
|
379
379
|
filter_detail_sections(report);
|
|
380
380
|
recompute_summary(report);
|
|
381
|
+
let has_hidden_security_surface = report.has_hidden_security_candidate_occurrences();
|
|
382
|
+
report
|
|
383
|
+
.next_steps
|
|
384
|
+
.retain(|step| next_step_live(&step.id, &report.findings, has_hidden_security_surface));
|
|
381
385
|
report.verdict = if report
|
|
382
386
|
.findings
|
|
383
387
|
.iter()
|
|
@@ -435,9 +439,6 @@ fn filter_detail_sections(report: &mut JsonReport) {
|
|
|
435
439
|
report
|
|
436
440
|
.attack_surface
|
|
437
441
|
.retain(|entry| attack_surface_live(entry, &report.security_candidates));
|
|
438
|
-
report
|
|
439
|
-
.next_steps
|
|
440
|
-
.retain(|step| next_step_live(&step.id, &remaining));
|
|
441
442
|
}
|
|
442
443
|
|
|
443
444
|
fn clone_group_live(
|
|
@@ -500,21 +501,25 @@ fn attack_surface_live(
|
|
|
500
501
|
.any(|candidate| candidate.category == entry.category)
|
|
501
502
|
}
|
|
502
503
|
|
|
503
|
-
fn next_step_live(id: &str,
|
|
504
|
+
fn next_step_live(id: &str, findings: &[Finding], has_hidden_security_surface: bool) -> bool {
|
|
504
505
|
match id {
|
|
505
|
-
"trace-unused-export" =>
|
|
506
|
-
"trace-unused-type" =>
|
|
507
|
-
"trace-unused-dependency" =>
|
|
506
|
+
"trace-unused-export" => has_finding_kind(findings, FindingKind::UnusedExport),
|
|
507
|
+
"trace-unused-type" => has_finding_kind(findings, FindingKind::UnusedType),
|
|
508
|
+
"trace-unused-dependency" => findings
|
|
508
509
|
.iter()
|
|
509
|
-
.any(|
|
|
510
|
-
"trace-code-duplication" =>
|
|
511
|
-
"complexity-breakdown" =>
|
|
510
|
+
.any(|finding| is_dependency_hygiene_kind(finding.kind)),
|
|
511
|
+
"trace-code-duplication" => has_finding_kind(findings, FindingKind::CodeDuplication),
|
|
512
|
+
"complexity-breakdown" => findings.iter().any(|finding| complexity_kind(finding.kind)),
|
|
513
|
+
"review-security-surface" => {
|
|
514
|
+
has_hidden_security_surface
|
|
515
|
+
&& has_finding_kind(findings, FindingKind::SecurityCandidate)
|
|
516
|
+
}
|
|
512
517
|
_ => true,
|
|
513
518
|
}
|
|
514
519
|
}
|
|
515
520
|
|
|
516
|
-
fn
|
|
517
|
-
|
|
521
|
+
fn has_finding_kind(findings: &[Finding], expected: FindingKind) -> bool {
|
|
522
|
+
findings.iter().any(|finding| finding.kind == expected)
|
|
518
523
|
}
|
|
519
524
|
|
|
520
525
|
fn complexity_kind(kind: FindingKind) -> bool {
|
package/src/changed_scope.rs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
use std::collections::BTreeSet;
|
|
2
|
+
use std::fmt;
|
|
2
3
|
use std::path::{Path, PathBuf};
|
|
3
4
|
use std::process::Command;
|
|
4
5
|
|
|
@@ -17,15 +18,37 @@ pub enum ChangedScopeError {
|
|
|
17
18
|
source: std::io::Error,
|
|
18
19
|
},
|
|
19
20
|
/// Git returned a non-zero status.
|
|
20
|
-
#[error("git diff failed for base {base:?}: {stderr}")]
|
|
21
|
+
#[error("git diff failed for base {base:?}: {stderr}{suggestions}")]
|
|
21
22
|
GitDiff {
|
|
22
23
|
/// Base revision passed by the caller.
|
|
23
24
|
base: String,
|
|
24
25
|
/// Stderr from git.
|
|
25
26
|
stderr: String,
|
|
27
|
+
/// Similar refs found in the local repository.
|
|
28
|
+
suggestions: RefSuggestions,
|
|
26
29
|
},
|
|
27
30
|
}
|
|
28
31
|
|
|
32
|
+
/// Similar Git refs for an invalid changed-scope base.
|
|
33
|
+
#[derive(Debug, Clone, Default)]
|
|
34
|
+
pub struct RefSuggestions(Vec<String>);
|
|
35
|
+
|
|
36
|
+
impl fmt::Display for RefSuggestions {
|
|
37
|
+
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
38
|
+
match self.0.as_slice() {
|
|
39
|
+
[] => Ok(()),
|
|
40
|
+
[one] => write!(formatter, "\nDid you mean {one}?"),
|
|
41
|
+
many => write!(formatter, "\nDid you mean one of: {}?", many.join(", ")),
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
impl RefSuggestions {
|
|
47
|
+
pub(crate) fn for_base(root: &Path, base: &str) -> Self {
|
|
48
|
+
Self(similar_refs(root, base))
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
29
52
|
/// Return root-normalized files changed since `base`.
|
|
30
53
|
///
|
|
31
54
|
/// # Errors
|
|
@@ -40,10 +63,7 @@ pub fn changed_files(root: &Path, base: &str) -> Result<Vec<PathBuf>, ChangedSco
|
|
|
40
63
|
.map_err(|source| ChangedScopeError::Git { source })?;
|
|
41
64
|
|
|
42
65
|
if !output.status.success() {
|
|
43
|
-
return Err(
|
|
44
|
-
base: base.to_owned(),
|
|
45
|
-
stderr: String::from_utf8_lossy(&output.stderr).trim().to_owned(),
|
|
46
|
-
});
|
|
66
|
+
return Err(git_diff_error(root, base, &output.stderr));
|
|
47
67
|
}
|
|
48
68
|
|
|
49
69
|
let untracked = Command::new("git")
|
|
@@ -56,6 +76,7 @@ pub fn changed_files(root: &Path, base: &str) -> Result<Vec<PathBuf>, ChangedSco
|
|
|
56
76
|
return Err(ChangedScopeError::GitDiff {
|
|
57
77
|
base: base.to_owned(),
|
|
58
78
|
stderr: String::from_utf8_lossy(&untracked.stderr).trim().to_owned(),
|
|
79
|
+
suggestions: RefSuggestions::default(),
|
|
59
80
|
});
|
|
60
81
|
}
|
|
61
82
|
|
|
@@ -115,3 +136,75 @@ fn normalize_changed_path(root: &Path, line: &str) -> Option<PathBuf> {
|
|
|
115
136
|
let path = normalize_against(root, Path::new(line));
|
|
116
137
|
path.starts_with(root).then_some(path)
|
|
117
138
|
}
|
|
139
|
+
|
|
140
|
+
fn git_diff_error(root: &Path, base: &str, stderr: &[u8]) -> ChangedScopeError {
|
|
141
|
+
ChangedScopeError::GitDiff {
|
|
142
|
+
base: base.to_owned(),
|
|
143
|
+
stderr: String::from_utf8_lossy(stderr).trim().to_owned(),
|
|
144
|
+
suggestions: RefSuggestions::for_base(root, base),
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
fn similar_refs(root: &Path, base: &str) -> Vec<String> {
|
|
149
|
+
let Ok(output) = Command::new("git")
|
|
150
|
+
.args([
|
|
151
|
+
"for-each-ref",
|
|
152
|
+
"--format=%(refname:short)",
|
|
153
|
+
"refs/heads",
|
|
154
|
+
"refs/remotes",
|
|
155
|
+
])
|
|
156
|
+
.current_dir(root)
|
|
157
|
+
.output()
|
|
158
|
+
else {
|
|
159
|
+
return Vec::new();
|
|
160
|
+
};
|
|
161
|
+
if !output.status.success() {
|
|
162
|
+
return Vec::new();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let mut scored = String::from_utf8_lossy(&output.stdout)
|
|
166
|
+
.lines()
|
|
167
|
+
.map(str::trim)
|
|
168
|
+
.filter(|ref_name| !ref_name.is_empty())
|
|
169
|
+
.filter(|ref_name| !ref_name.ends_with("/HEAD"))
|
|
170
|
+
.filter(|ref_name| *ref_name != base)
|
|
171
|
+
.filter_map(|ref_name| {
|
|
172
|
+
let short = ref_name.rsplit('/').next().unwrap_or(ref_name);
|
|
173
|
+
let score = levenshtein(base, ref_name).min(levenshtein(base, short));
|
|
174
|
+
let contains_bonus = if ref_name.contains(base) || short.contains(base) {
|
|
175
|
+
0
|
|
176
|
+
} else {
|
|
177
|
+
score
|
|
178
|
+
};
|
|
179
|
+
let score = score.min(contains_bonus);
|
|
180
|
+
(score <= suggestion_threshold(base)).then_some((score, ref_name.to_owned()))
|
|
181
|
+
})
|
|
182
|
+
.collect::<Vec<_>>();
|
|
183
|
+
scored.sort();
|
|
184
|
+
scored
|
|
185
|
+
.into_iter()
|
|
186
|
+
.map(|(_, ref_name)| ref_name)
|
|
187
|
+
.take(3)
|
|
188
|
+
.collect()
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
fn suggestion_threshold(value: &str) -> usize {
|
|
192
|
+
2.max(value.len() / 3)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fn levenshtein(left: &str, right: &str) -> usize {
|
|
196
|
+
let right_chars = right.chars().collect::<Vec<_>>();
|
|
197
|
+
let mut previous = (0..=right_chars.len()).collect::<Vec<_>>();
|
|
198
|
+
for (left_index, left_char) in left.chars().enumerate() {
|
|
199
|
+
let mut current = Vec::with_capacity(right_chars.len() + 1);
|
|
200
|
+
current.push(left_index + 1);
|
|
201
|
+
for (right_index, right_char) in right_chars.iter().enumerate() {
|
|
202
|
+
let insertion = current[right_index] + 1;
|
|
203
|
+
let deletion = previous[right_index + 1] + 1;
|
|
204
|
+
let substitution = previous[right_index] + usize::from(left_char != *right_char);
|
|
205
|
+
current.push(insertion.min(deletion).min(substitution));
|
|
206
|
+
}
|
|
207
|
+
previous = current;
|
|
208
|
+
}
|
|
209
|
+
previous[right_chars.len()]
|
|
210
|
+
}
|
package/src/cli/audit_run.rs
CHANGED
|
@@ -7,7 +7,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
|
|
7
7
|
use clap::{Arg, ArgMatches};
|
|
8
8
|
|
|
9
9
|
use crate::baseline::baseline_from_report;
|
|
10
|
-
use crate::changed_scope::{changed_file_scope_from_changed, changed_files};
|
|
10
|
+
use crate::changed_scope::{RefSuggestions, changed_file_scope_from_changed, changed_files};
|
|
11
11
|
use crate::config::apply_rules_to_report;
|
|
12
12
|
use crate::graph::normalize_path;
|
|
13
13
|
use crate::output::{
|
|
@@ -284,6 +284,7 @@ where
|
|
|
284
284
|
Err(crate::changed_scope::ChangedScopeError::GitDiff {
|
|
285
285
|
base: base.to_owned(),
|
|
286
286
|
stderr: String::from_utf8_lossy(&output.stderr).trim().to_owned(),
|
|
287
|
+
suggestions: RefSuggestions::default(),
|
|
287
288
|
}
|
|
288
289
|
.into())
|
|
289
290
|
}
|
package/src/cli/error.rs
CHANGED
|
@@ -41,7 +41,7 @@ pub enum CliError {
|
|
|
41
41
|
Widgets(#[from] WidgetAnalysisError),
|
|
42
42
|
/// Security top truncation cannot safely run before changed-line scoping.
|
|
43
43
|
#[error(
|
|
44
|
-
"security --top cannot be combined with --gate, --diff-file, --diff-stdin,
|
|
44
|
+
"security --top cannot be combined with --gate, --diff-file, --diff-stdin, --changed-since, or --compare"
|
|
45
45
|
)]
|
|
46
46
|
UnsupportedSecurityTopScope,
|
|
47
47
|
/// Cross-language duplicate detection is JavaScript/TypeScript-specific in Fallow.
|
package/src/cli/fix_run.rs
CHANGED
|
@@ -74,8 +74,9 @@ pub(super) fn run_fix<W: Write>(subcommand: &ArgMatches, mut writer: W) -> Resul
|
|
|
74
74
|
conditional_environment: super::common_args::conditional_environment(subcommand),
|
|
75
75
|
},
|
|
76
76
|
)?;
|
|
77
|
+
let command = ReportCommand::Check;
|
|
77
78
|
let request = CommandRequest {
|
|
78
|
-
command
|
|
79
|
+
command,
|
|
79
80
|
root,
|
|
80
81
|
format: match format {
|
|
81
82
|
OutputFormat::Human => super::ReportOutputFormat::Human,
|
|
@@ -94,16 +95,10 @@ pub(super) fn run_fix<W: Write>(subcommand: &ArgMatches, mut writer: W) -> Resul
|
|
|
94
95
|
policy_packs: Vec::new(),
|
|
95
96
|
audit_base: None,
|
|
96
97
|
audit_gate: super::audit_run::AuditGate::default(),
|
|
97
|
-
file_paths: subcommand
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
workspace_patterns: subcommand
|
|
102
|
-
.get_many::<String>("workspace")
|
|
103
|
-
.map(|values| values.cloned().collect())
|
|
104
|
-
.unwrap_or_default(),
|
|
105
|
-
changed_workspaces: subcommand.get_one::<String>("changed-workspaces").cloned(),
|
|
106
|
-
changed_since: subcommand.get_one::<String>("changed-since").cloned(),
|
|
98
|
+
file_paths: super::scope_args::file_paths(command, subcommand),
|
|
99
|
+
workspace_patterns: super::scope_args::workspace_patterns(command, subcommand),
|
|
100
|
+
changed_workspaces: super::scope_args::changed_workspaces(command, subcommand),
|
|
101
|
+
changed_since: super::scope_args::changed_since(command, subcommand),
|
|
107
102
|
baseline_paths: Vec::new(),
|
|
108
103
|
security_sarif_file: None,
|
|
109
104
|
security_gate: None,
|
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.rs
CHANGED
|
@@ -497,7 +497,7 @@ fn request_from_matches(matches: &ArgMatches) -> Result<CommandRequest, CliError
|
|
|
497
497
|
let file_paths = scope_args::file_paths(command, subcommand);
|
|
498
498
|
let workspace_patterns = scope_args::workspace_patterns(command, subcommand);
|
|
499
499
|
let changed_workspaces = scope_args::changed_workspaces(command, subcommand);
|
|
500
|
-
let changed_since =
|
|
500
|
+
let changed_since = report_changed_since(command, subcommand, &security_cli);
|
|
501
501
|
let baseline_paths = baseline_paths(command, subcommand);
|
|
502
502
|
let save_baseline = if supports_global_baseline(command) {
|
|
503
503
|
subcommand.get_one::<PathBuf>("save-baseline").cloned()
|
|
@@ -604,6 +604,21 @@ fn validate_security_cli(
|
|
|
604
604
|
Ok(())
|
|
605
605
|
}
|
|
606
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
|
+
|
|
607
622
|
fn baseline_paths(command: ReportCommand, subcommand: &ArgMatches) -> Vec<PathBuf> {
|
|
608
623
|
let mut paths = Vec::new();
|
|
609
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",
|