safe_url_check
1.1.2, released 3 years ago by google.dev
Check if an untrusted URL is broken without allowing connections to private IP addresses.
Quiet but busy
What it does
Provides a safeUrlCheck function that makes HEAD requests and follows redirects while verifying that the host does not resolve to private IPv4 or locally unique IPv6 addresses. This prevents attackers from exploiting cloud environments by pointing URLs to internal services.
AI-written summary of version 1.1.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to check if user-submitted or untrusted URLs are broken.
- Your application runs in a cloud environment and needs protection against SSRF attacks targeting private IP spaces.
Skip it when
- You require full HTTP client capabilities beyond checking if a URL is broken.
- You need to allow connections to private IP addresses.
Strengths
- Prevents unauthorized access to private IP space via DNS rebinding or malicious URLs.
- Handles redirects safely while verifying intermediate and final hosts.
Weaknesses
- Limited to checking if a URL is broken rather than being a full-featured HTTP client.
- IP address blocking rules may need expansion for additional address spaces.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Not documented
import 'package:safe_url_check/safe_url_check.dart';
Future<void> main() async {
final exists = await safeUrlCheck(
Uri.parse('https://google.com'),
userAgent: 'myexample/1.0.0 (+https://example.com)',
);
if (exists) {
print('The url: https://google.com is NOT broken');
}
}Alternatives
Packages that do the same job and could replace safe_url_check.
Works with
Packages commonly used together with safe_url_check: ones it builds on, ones built on it, and its own family.
- retrysafe_url_check depends on itProvides automatic retry with exponential back‑off for async functions.
- neat_periodic_taskSame familyAuxiliary classes for reliably running periodic tasks in long-running processes.
- neat_cacheSame familyA cache abstraction for wrapping in-memory or redis caches with timeouts.
- panaBuilt on safe_url_checkProduce a report summarizing the health and quality of a Dart package