Commit 9624234b8b
Unsigned
Layout: unified · split
web/src/utils/security-check-mappings.ts added +155
| @@ -0,0 +1,155 @@ | |||
| 1 | |||
| 2 | const securityCheckMapping: {[key: string]: string} = { | ||
| 3 | is_host_an_ipv4: 'Host is an IPv4 Address', | ||
| 4 | is_uncommon_host_length: 'Uncommon Host Length', | ||
| 5 | is_uncommon_dash_char_count: 'Uncommon Number of Dashes in Host', | ||
| 6 | is_uncommon_dot_char_count: 'Uncommon Number of Dots in Host', | ||
| 7 | is_uncommon_host_name: 'Uncommon Hostname', | ||
| 8 | is_suspicious_url_pattern: 'Suspicious URL Pattern', | ||
| 9 | is_suspicious_file_extension: 'Suspicious File Extension', | ||
| 10 | is_robots_noindex: 'Robots Noindex', | ||
| 11 | is_suspended_page: 'Suspended Page', | ||
| 12 | is_most_abused_tld: 'Top-Level Domain Highly Abused', | ||
| 13 | is_uncommon_clickable_url: 'Uncommon Clickable URL', | ||
| 14 | is_phishing_heuristic: 'Phishing Heuristic Detected', | ||
| 15 | is_possible_emotet: 'Possible Emotet Infection', | ||
| 16 | is_redirect_to_search_engine: 'Redirects to Search Engine', | ||
| 17 | is_redirect_to_wikipedia: 'Redirects to Wikipedia', | ||
| 18 | is_http_status_error: 'HTTP Status Error', | ||
| 19 | is_http_server_error: 'HTTP Server Error', | ||
| 20 | is_http_client_error: 'HTTP Client Error', | ||
| 21 | is_suspicious_content: 'Suspicious Content Detected', | ||
| 22 | is_url_accessible: 'URL is Accessible', | ||
| 23 | is_empty_page_title: 'Empty Page Title', | ||
| 24 | is_empty_page_content: 'Empty Page Content', | ||
| 25 | is_domain_ipv4_assigned: 'Domain IPv4 is Assigned', | ||
| 26 | is_domain_ipv4_private: 'Domain IPv4 is Private', | ||
| 27 | is_domain_ipv4_loopback: 'Domain IPv4 is Loopback', | ||
| 28 | is_domain_ipv4_reserved: 'Domain IPv4 is Reserved', | ||
| 29 | is_domain_ipv4_valid: 'Domain IPv4 is Valid', | ||
| 30 | is_domain_blacklisted: 'Domain is Blacklisted', | ||
| 31 | is_suspicious_domain: 'Suspicious Domain', | ||
| 32 | is_sinkholed_domain: 'Sinkholed Domain', | ||
| 33 | is_defaced_heuristic: 'Defacement Heuristic Detected', | ||
| 34 | is_masked_file: 'Masked File Detected', | ||
| 35 | is_risky_geo_location: 'Risky Geographical Location', | ||
| 36 | is_china_country: 'Located in China', | ||
| 37 | is_nigeria_country: 'Located in Nigeria', | ||
| 38 | is_non_standard_port: 'Non-standard Port Used', | ||
| 39 | is_email_address_on_url_query: 'Email Address Found in URL Query', | ||
| 40 | is_directory_listing: 'Directory Listing Enabled', | ||
| 41 | is_exe_on_directory_listing: '.EXE File Found in Directory Listing', | ||
| 42 | is_zip_on_directory_listing: '.ZIP File Found in Directory Listing', | ||
| 43 | is_php_on_directory_listing: '.PHP File Found in Directory Listing', | ||
| 44 | is_doc_on_directory_listing: '.DOC File Found in Directory Listing', | ||
| 45 | is_pdf_on_directory_listing: '.PDF File Found in Directory Listing', | ||
| 46 | is_apk_on_directory_listing: '.APK File Found in Directory Listing', | ||
| 47 | is_linux_elf_file: 'Linux ELF File Detected', | ||
| 48 | is_linux_elf_file_on_free_dynamic_dns: 'Linux ELF File on Free Dynamic DNS', | ||
| 49 | is_linux_elf_file_on_free_hosting: 'Linux ELF File on Free Hosting', | ||
| 50 | is_linux_elf_file_on_ipv4: 'Linux ELF File on IPv4 Address', | ||
| 51 | is_masked_linux_elf_file: 'Masked Linux ELF File Detected', | ||
| 52 | is_masked_windows_exe_file: 'Masked Windows Executable Detected', | ||
| 53 | is_ms_office_file: 'Microsoft Office File Detected', | ||
| 54 | is_windows_exe_file_on_free_dynamic_dns: 'Windows Executable on Free Dynamic DNS', | ||
| 55 | is_windows_exe_file_on_free_hosting: 'Windows Executable on Free Hosting', | ||
| 56 | is_windows_exe_file_on_ipv4: 'Windows Executable on IPv4 Address', | ||
| 57 | is_windows_exe_file: 'Windows Executable Detected', | ||
| 58 | is_android_apk_file_on_free_dynamic_dns: 'Android APK on Free Dynamic DNS', | ||
| 59 | is_android_apk_file_on_free_hosting: 'Android APK on Free Hosting', | ||
| 60 | is_android_apk_file_on_ipv4: 'Android APK on IPv4 Address', | ||
| 61 | is_android_apk_file: 'Android APK Detected', | ||
| 62 | is_external_redirect: 'External Redirect Detected', | ||
| 63 | is_risky_category: 'Risky Category Detected', | ||
| 64 | is_domain_recent: 'Domain Recently Created', | ||
| 65 | is_domain_very_recent: 'Domain Very Recently Created', | ||
| 66 | is_credit_card_field: 'Credit Card Field Present', | ||
| 67 | is_password_field: 'Password Field Present', | ||
| 68 | is_valid_https: 'Valid HTTPS Connection' | ||
| 69 | }; | ||
| 70 | const passFailLogic: {[key: string]: boolean | string} = { | ||
| 71 | // True means the check needs to be true to pass | ||
| 72 | is_valid_https: true, | ||
| 73 | is_host_an_ipv4: false, | ||
| 74 | is_uncommon_host_length: false, | ||
| 75 | is_uncommon_dash_char_count: false, | ||
| 76 | is_uncommon_dot_char_count: false, | ||
| 77 | is_uncommon_host_name: false, | ||
| 78 | is_suspicious_url_pattern: false, | ||
| 79 | is_suspicious_file_extension: false, | ||
| 80 | is_robots_noindex: false, | ||
| 81 | is_suspended_page: false, | ||
| 82 | is_most_abused_tld: false, | ||
| 83 | is_uncommon_clickable_url: false, | ||
| 84 | is_phishing_heuristic: false, | ||
| 85 | is_possible_emotet: false, | ||
| 86 | is_redirect_to_search_engine: false, | ||
| 87 | is_redirect_to_wikipedia: false, | ||
| 88 | is_http_status_error: false, | ||
| 89 | is_http_server_error: false, | ||
| 90 | is_http_client_error: false, | ||
| 91 | is_suspicious_content: false, | ||
| 92 | is_url_accessible: true, | ||
| 93 | is_empty_page_title: false, | ||
| 94 | is_empty_page_content: false, | ||
| 95 | is_domain_ipv4_assigned: true, | ||
| 96 | is_domain_ipv4_private: false, | ||
| 97 | is_domain_ipv4_loopback: false, | ||
| 98 | is_domain_ipv4_reserved: false, | ||
| 99 | is_domain_ipv4_valid: true, | ||
| 100 | is_domain_blacklisted: false, | ||
| 101 | is_suspicious_domain: false, | ||
| 102 | is_sinkholed_domain: false, | ||
| 103 | is_defaced_heuristic: false, | ||
| 104 | is_masked_file: false, | ||
| 105 | is_risky_geo_location: false, | ||
| 106 | is_china_country: false, | ||
| 107 | is_nigeria_country: false, | ||
| 108 | is_non_standard_port: false, | ||
| 109 | is_email_address_on_url_query: false, | ||
| 110 | is_directory_listing: false, | ||
| 111 | is_exe_on_directory_listing: false, | ||
| 112 | is_zip_on_directory_listing: false, | ||
| 113 | is_php_on_directory_listing: false, | ||
| 114 | is_doc_on_directory_listing: false, | ||
| 115 | is_pdf_on_directory_listing: false, | ||
| 116 | is_apk_on_directory_listing: false, | ||
| 117 | is_linux_elf_file: false, | ||
| 118 | is_linux_elf_file_on_free_dynamic_dns: false, | ||
| 119 | is_linux_elf_file_on_free_hosting: false, | ||
| 120 | is_linux_elf_file_on_ipv4: false, | ||
| 121 | is_masked_linux_elf_file: false, | ||
| 122 | is_masked_windows_exe_file: false, | ||
| 123 | is_ms_office_file: false, | ||
| 124 | is_windows_exe_file_on_free_dynamic_dns: false, | ||
| 125 | is_windows_exe_file_on_free_hosting: false, | ||
| 126 | is_windows_exe_file_on_ipv4: false, | ||
| 127 | is_windows_exe_file: false, | ||
| 128 | is_android_apk_file_on_free_dynamic_dns: false, | ||
| 129 | is_android_apk_file_on_free_hosting: false, | ||
| 130 | is_android_apk_file_on_ipv4: false, | ||
| 131 | is_android_apk_file: false, | ||
| 132 | is_external_redirect: false, | ||
| 133 | is_risky_category: false, | ||
| 134 | is_domain_recent: "no", | ||
| 135 | is_domain_very_recent: "no", | ||
| 136 | is_credit_card_field: false, | ||
| 137 | is_password_field: false, | ||
| 138 | }; | ||
| 139 | |||
| 140 | export const analyzeSecurityChecks = (checks: { [key: string]: boolean | string }) => { | ||
| 141 | |||
| 142 | let passedChecks = []; | ||
| 143 | let failedChecks = []; | ||
| 144 | for (const [check, value] of Object.entries(checks)) { | ||
| 145 | let shouldPass = passFailLogic.hasOwnProperty(check) ? passFailLogic[check] : false; | ||
| 146 | let actualPass = (value === shouldPass) || (shouldPass === true && value !== "no"); | ||
| 147 | |||
| 148 | if (actualPass) { | ||
| 149 | passedChecks.push(securityCheckMapping[check]); | ||
| 150 | } else { | ||
| 151 | failedChecks.push(securityCheckMapping[check]); | ||
| 152 | } | ||
| 153 | } | ||
| 154 | return { passedChecks, failedChecks }; | ||
| 155 | } | ||