Comprehensive source map crawler
(
js_files: &[String],
client: &Client,
validate_tokens: bool,
max_concurrent: usize,
)
| 865 | |
| 866 | /// Comprehensive source map crawler |
| 867 | pub async fn crawl_source_maps( |
| 868 | js_files: &[String], |
| 869 | client: &Client, |
| 870 | validate_tokens: bool, |
| 871 | max_concurrent: usize, |
| 872 | ) -> Vec<SourceMapInfo> { |
| 873 | println!("{}", "[*] Searching for source maps (.map files)...".cyan()); |
| 874 | |
| 875 | let mut all_maps = Vec::new(); |
| 876 | let mut found = 0; |
| 877 | |
| 878 | use futures::stream::{self, StreamExt}; |
| 879 | |
| 880 | let results = stream::iter(js_files.to_vec()) |
| 881 | .map(|js_url| { |
| 882 | let client = client.clone(); |
| 883 | async move { |
| 884 | // Fetch JS file |
| 885 | let js_response = client |
| 886 | .get(&js_url) |
| 887 | .timeout(Duration::from_secs(10)) |
| 888 | .send() |
| 889 | .await |
| 890 | .ok()?; |
| 891 | |
| 892 | let js_content = js_response.text().await.ok()?; |
| 893 | |
| 894 | // Try to find source map |
| 895 | let map_url = find_source_map(&js_url, &js_content, &client).await?; |
| 896 | |
| 897 | // Fetch and parse source map |
| 898 | let source_map = fetch_source_map(&map_url, &client).await?; |
| 899 | |
| 900 | // Analyze it |
| 901 | let info = analyze_source_map(&map_url, &source_map, &client, validate_tokens).await; |
| 902 | |
| 903 | Some(info) |
| 904 | } |
| 905 | }) |
| 906 | .buffer_unordered(max_concurrent) |
| 907 | .collect::<Vec<_>>() |
| 908 | .await; |
| 909 | |
| 910 | for info in results.into_iter().flatten() { |
| 911 | found += 1; |
| 912 | println!("{}", format!(" [+] Found source map: {}", info.map_url).green()); |
| 913 | println!("{}", format!(" Original files: {}", info.original_files.len()).cyan()); |
| 914 | if !info.secrets.is_empty() { |
| 915 | println!("{}", format!(" Secrets found: {}", info.secrets.len()).red()); |
| 916 | } |
| 917 | if !info.endpoints.is_empty() { |
| 918 | println!("{}", format!(" Endpoints found: {}", info.endpoints.len()).yellow()); |
| 919 | } |
| 920 | all_maps.push(info); |
| 921 | } |
| 922 | |
| 923 | println!("{}", format!("[+] Source map analysis complete: {} maps found", found).green().bold()); |
| 924 |
nothing calls this directly
no test coverage detected