dart-decimate 0.0.19 → 0.0.20
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 +2 -2
- package/package.json +1 -1
- package/src/security/detect.rs +7 -1
- package/src/security/tests.rs +59 -0
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ Add this to `package.json` if you want a short project command:
|
|
|
91
91
|
"dart-decimate": "dart-decimate json ."
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"dart-decimate": "^0.0.
|
|
94
|
+
"dart-decimate": "^0.0.20"
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
```
|
|
@@ -675,7 +675,7 @@ This repository forbids `unsafe_code`.
|
|
|
675
675
|
|
|
676
676
|
## Release Flow
|
|
677
677
|
|
|
678
|
-
Current version: `0.0.
|
|
678
|
+
Current version: `0.0.20`.
|
|
679
679
|
|
|
680
680
|
After the first public release, changes should go through pull requests. Every
|
|
681
681
|
PR to `main` must bump both `Cargo.toml` and `package.json` above the base
|
package/package.json
CHANGED
package/src/security/detect.rs
CHANGED
|
@@ -101,7 +101,13 @@ fn detect_hardcoded_secrets(
|
|
|
101
101
|
{
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
|
-
if
|
|
104
|
+
if ((secret_binding_name
|
|
105
|
+
|| (secret_name
|
|
106
|
+
&& (literal_has_concrete_token_like_segment(&literal.value)
|
|
107
|
+
|| literal_has_embedded_url_credentials(&literal.value))))
|
|
108
|
+
&& literal.value.len() >= 12)
|
|
109
|
+
|| secret_value
|
|
110
|
+
{
|
|
105
111
|
candidates.push(detected(
|
|
106
112
|
path,
|
|
107
113
|
source,
|
package/src/security/tests.rs
CHANGED
|
@@ -141,6 +141,65 @@ class Copy {
|
|
|
141
141
|
Ok(())
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
#[test]
|
|
145
|
+
fn skips_low_entropy_labels_with_secret_like_words() -> Result<(), Box<dyn std::error::Error>> {
|
|
146
|
+
let fixture = tempfile::tempdir()?;
|
|
147
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
148
|
+
write(
|
|
149
|
+
&fixture,
|
|
150
|
+
"lib/main.dart",
|
|
151
|
+
"void log(String message) => print(message);
|
|
152
|
+
|
|
153
|
+
void main() {
|
|
154
|
+
log('requestAuthorization result');
|
|
155
|
+
log('synchronizeRemoteCatalog');
|
|
156
|
+
}
|
|
157
|
+
",
|
|
158
|
+
)?;
|
|
159
|
+
|
|
160
|
+
let project = scan_project(fixture.path())?;
|
|
161
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
162
|
+
|
|
163
|
+
assert!(report.candidates.is_empty());
|
|
164
|
+
assert_eq!(report.total_occurrences, 0);
|
|
165
|
+
|
|
166
|
+
Ok(())
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
#[test]
|
|
170
|
+
fn reports_secret_bindings_and_shaped_literals() -> Result<(), Box<dyn std::error::Error>> {
|
|
171
|
+
let fixture = tempfile::tempdir()?;
|
|
172
|
+
write(&fixture, "pubspec.yaml", "name: app\n")?;
|
|
173
|
+
write(
|
|
174
|
+
&fixture,
|
|
175
|
+
"lib/main.dart",
|
|
176
|
+
"const clientSecret = 'ordinary dictionary words';
|
|
177
|
+
|
|
178
|
+
void authenticate({required String accessToken}) {}
|
|
179
|
+
void log(String message) => print(message);
|
|
180
|
+
|
|
181
|
+
void main() {
|
|
182
|
+
authenticate(accessToken: 'another dictionary phrase');
|
|
183
|
+
log('ghp_0123456789abcdef0123456789abcdef');
|
|
184
|
+
print(clientSecret);
|
|
185
|
+
}
|
|
186
|
+
",
|
|
187
|
+
)?;
|
|
188
|
+
|
|
189
|
+
let project = scan_project(fixture.path())?;
|
|
190
|
+
let report = analyze_security(&project, &SecurityOptions::default(), None)?;
|
|
191
|
+
|
|
192
|
+
assert_eq!(report.total_occurrences, 3);
|
|
193
|
+
assert_eq!(report.candidates.len(), 1);
|
|
194
|
+
assert_eq!(
|
|
195
|
+
report.candidates[0].rule_id,
|
|
196
|
+
"dart-decimate/security-hardcoded-secret"
|
|
197
|
+
);
|
|
198
|
+
assert_eq!(report.candidates[0].occurrences.len(), 3);
|
|
199
|
+
|
|
200
|
+
Ok(())
|
|
201
|
+
}
|
|
202
|
+
|
|
144
203
|
#[test]
|
|
145
204
|
fn reports_operational_copy_with_concrete_token_segments() -> Result<(), Box<dyn std::error::Error>>
|
|
146
205
|
{
|