dart_audit 0.2.0
dart_audit: ^0.2.0 copied to clipboard
Security vulnerability scanner for Dart and Flutter projects. Checks all dependencies against the OSV.dev database.
0.2.0 #
Added #
-
inspectsubcommand — statically analyses a pub.dev package's Dart source before it enters the project, enabling supply-chain attack detection.- Downloads the package
.tar.gzarchive frompub.devusing thearchivepackage; extracts only.dartfiles to a temporary directory (always cleaned up). - Regex scanner — 14 rules across 7 categories: hard-coded URLs to unknown hosts, raw TCP sockets,
Process.run/ shell injection, sensitive file-system paths, obfuscation techniques (hex encoding, Base64 eval, Unicode escapes, char-code concatenation), crypto-mining, backdoor / reverse-shell patterns, and data exfiltration markers. - Shannon entropy scanner — flags string literals with high entropy (> 4.5 bits → MEDIUM, > 5.5 bits → HIGH) as possible obfuscated payloads or embedded secrets. Minimum string length of 20 characters to reduce noise.
- Weighted risk score 0–100 (CRITICAL regex: 40 pts, HIGH: 20 pts, MEDIUM: 10 pts; entropy HIGH: 15 pts, MEDIUM: 5 pts), clamped and labelled CLEAN / LOW RISK / SUSPICIOUS / HIGH RISK.
- Both scanners run in parallel via
Future.wait. - Exit code
1when risk score ≥ 30 (SUSPICIOUS or worse);--exit-zerodisables this. --format jsonproduces machine-readable output.- Throws typed
PackageNotFoundExceptionon 404 from pub.dev.
- Downloads the package
-
Subcommand architecture — the CLI is now structured as
dart_audit <command> [options]with two commands:audit(default) andinspect. A baredart_auditstill behaves asauditfor backwards compatibility. -
--format jsonfor theauditcommand — all findings and package metadata are serialised to structured JSON. -
--min-severityfilter foraudit— only reports findings at or above the specified level (low / medium / high / critical). -
--ignoreflag foraudit— suppresses specific CVE / GHSA IDs. Can be repeated. -
--no-colorglobal flag — disables ANSI colour output. Color state is now shared via a singlecolor_outputmodule so both commands honour the flag consistently. -
HTTP timeout and retries for
audit— requests to OSV.dev now time out after 30 s and are retried up to 3 times with exponential back-off (1 s, 2 s, 4 s). -
Skipped-package warnings — git, path, and SDK dependencies are now tracked and reported as warnings instead of being silently ignored.
-
CVSS parsing improvements — falls back through three levels: (1) top-level
severityarray withCVSS_V3/CVSS_V2type, (2)database_specific.severity, (3)affected[].database_specific.severity. -
Progress indicator for large dependency trees — reports batch progress while querying OSV.dev.
-
Version read from
pubspec.yamlat runtime — no more hardcoded version constant.
Fixed #
_resolveFixedVersionpreviously returnednulleven when a fix was found (dead code path). Now correctly resolves and returns the fixed version string.
0.1.0 #
Initial release.
Added #
dart_auditCLI tool — scanspubspec.lockagainst the OSV.dev vulnerability database.--lockfile / -loption to specify a custom path topubspec.lock(defaults topubspec.lockin the current directory).--verbose / -vflag to list all packages including clean ones.--exit-zeroflag for CI reporting-only mode (always exits 0 even when vulnerabilities are found).--versionflag to print the current version.- Severity classification: CRITICAL, HIGH, MEDIUM, LOW, UNKNOWN — derived from CVSS scores and OSV database-specific fields.
- Colored terminal output using ANSI codes (auto-disabled when stdout is not a terminal).
- CVE / GHSA alias display, vulnerability summary, and available fix version for each finding.
- Batched OSV.dev API requests (up to 100 packages per request) to handle large dependency trees efficiently.
- Filters to
hostedpackages only — skipsgitandpathdependencies not indexed by OSV.dev. - Exit code
1when vulnerabilities are found, enabling automatic CI/CD pipeline failure.