SPB Git

Repository Public License

Corpora.swift 15.9 KB 251 lines swift

1// ORIX Secure2// File: Packages/ORIXURLRisk/Tests/ORIXURLRiskTests/Corpora.swift3// Description: Test corpora: legitimate real-world links (false-positive measurement) and crafted links covering every signal.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import Foundation8@testable import ORIXURLRisk910enum Corpora {11    /// Legitimate links. The last entries are known hard cases (real sites whose name contains a brand name) kept on12    /// purpose so the measured false-positive rate is honest.13    static let benign: [String] = [14        "https://www.apple.com/iphone/",15        "https://www.google.com/search?q=swift+testing&hl=en",16        "https://accounts.google.com/o/oauth2/v2/auth?client_id=123.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&response_type=code&scope=openid",17        "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=abc&redirect_uri=https%3A%2F%2Foutlook.office.com%2Fowa%2F&response_type=code",18        "https://www.amazon.ca/dp/B08N5WRWNW?ref=ppx_yo2ov_dt_b_product_details&th=1",19        "https://us-east-1.console.aws.amazon.com/ec2/home?region=us-east-1#Instances:instanceState=running",20        "https://s3.us-west-2.amazonaws.com/my-bucket/reports/2024/q1.pdf",21        "https://github.com/apple/swift/blob/main/README.md",22        "https://raw.githubusercontent.com/user/repo/main/install.sh",23        "https://en.wikipedia.org/wiki/Punycode",24        "https://fr.wikipedia.org/wiki/Qu%C3%A9bec_(ville)",25        "https://www.desjardins.com/particuliers/index.jsp",26        "https://accesd.mouv.desjardins.com/identifiantunique/identification",27        "https://www.rbcroyalbank.com/personal.html",28        "https://www1.royalbank.com/cgi-bin/rbaccess/rbunxcgi?F6=1&F7=IB&F21=IB&F22=IB&REQUEST=ClientSignin&LANGUAGE=ENGLISH",29        "https://easyweb.td.com/",30        "https://www.bnc.ca/particuliers.html",31        "https://www.scotiabank.com/ca/en/personal.html",32        "https://www.bmo.com/main/personal",33        "https://www.canada.ca/en/revenue-agency.html",34        "https://www.canada.ca/fr/agence-revenu/services/services-electroniques/dossier-particuliers.html",35        "https://www.revenuquebec.ca/fr/",36        "https://www.quebec.ca/sante",37        "https://www.gov.uk/government/organisations/hm-revenue-customs",38        "https://www.service-public.fr/particuliers/vosdroits/N19808",39        "https://www.irs.gov/refunds",40        "https://www.netflix.com/browse",41        "https://www.facebook.com/groups/123456789/permalink/987654321/",42        "https://www.instagram.com/p/CxYz123/",43        "https://wa.me/15145551234",44        "https://www.dhl.com/ca-en/home/tracking.html?tracking-id=1234567890",45        "https://www.fedex.com/fedextrack/?trknbr=123456789012",46        "https://www.ups.com/track?loc=en_CA&tracknum=1Z999AA10123456784",47        "https://www.canadapost-postescanada.ca/track-reperage/en#/search?searchFor=1234567890123456",48        "https://münchen.de",49        "https://例え.jp",50        "https://пример.рф",51        "https://www.bücher.de/shop/home",52        "https://日本語.jp/",53        "https://한국어.kr/",54        "https://москва.рф/",55        "https://ελληνικά.gr/",56        "http://localhost:3000/",57        "http://127.0.0.1:8080/api/health",58        "http://192.168.1.1/",59        "https://192.168.2.103:8443/admin",60        "http://[::1]:5173/",61        "https://www.google.com/url?q=https://www.example.org/article&sa=D&source=editors&ust=1700000000000000&usg=AOvVaw0abc",62        "https://click.e.newsletter.example.com/?qs=3f1c0b8e9d2a7c6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b3a2f1e0d9c8b7a6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b3a2f1e0d9c8b7a6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b3a2f1e0d9c8b7a6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b",63        "https://www.nytimes.com/2024/05/01/technology/apple-earnings.html?utm_source=newsletter&utm_medium=email&utm_campaign=daily&utm_content=top-story&smid=nytcore-ios-share",64        "https://mail.google.com/mail/u/0/#inbox",65        "https://docs.google.com/document/d/1A2b3C4d5E6f7G8h9I0j/edit?usp=sharing",66        "https://drive.google.com/file/d/1AbCdEfGhIjKlMnOpQrStUvWxYz/view",67        "https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=42s",68        "https://youtu.be/dQw4w9WgXcQ",69        "https://stackoverflow.com/questions/24002369/how-do-i-call-objective-c-code-from-swift",70        "https://developer.apple.com/documentation/swift/string",71        "https://support.apple.com/en-ca/HT201222",72        "https://appleid.apple.com/account/manage",73        "https://www.paypal.com/signin?returnUri=https%3A%2F%2Fwww.paypal.com%2Fmyaccount",74        "https://www.linkedin.com/in/some-person-123456/",75        "https://twitter.com/user/status/1234567890123456789",76        "https://www.reddit.com/r/swift/comments/abc123/whats_new/",77        "https://www.bbc.co.uk/news/world-12345678",78        "https://www.abc.net.au/news/2024-05-01/story/103000000",79        "https://www.ulaval.ca/etudes/programmes",80        "https://uqo.ca/",81        "https://www.hydroquebec.com/residentiel/espace-client/",82        "https://www.interac.ca/en/consumers/products/interac-e-transfer/",83        "https://zoom.us/j/1234567890?pwd=abcdEFGHijklMNOPqrstUVWXyz",84        "https://teams.microsoft.com/l/meetup-join/19%3ameeting_abc%40thread.v2/0?context=%7b%22Tid%22%3a%22x%22%7d",85        "https://www.dropbox.com/s/abc123xyz/report.pdf?dl=0",86        "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js",87        "https://example.com",88        "example.com",89        "www.wikipedia.org",90        "https://www.sqdc.ca/fr-CA/",91        "https://bit.ly/3xYzAbC",92        "https://t.co/AbCdEfGhIj",93        "https://web.archive.org/web/20240101000000/https://www.example.com/",94        "https://translate.google.com/translate?sl=auto&tl=fr&u=https://www.lemonde.fr/",95        "https://www.booking.com/hotel/ca/fairmont-le-chateau-frontenac.html",96        "https://mybusiness.shop.example.co.uk/products?id=42",97        "https://portal.azure.com/#@contoso.onmicrosoft.com/resource/subscriptions",98        "https://www.tdcanadatrust.com/",99        "https://secure.bankofamerica.com/login/sign-in/signOnV2Screen.go",100        "https://www.cra-arc.gc.ca/menu-eng.html",101        "https://store.steampowered.com/app/730/",102        "https://open.spotify.com/track/4uLU6hMCjMI75M1A2tKUQC?si=abcdef",103        "http://neverssl.com/",104        "https://maps.app.goo.gl/AbCdEf123",105        "https://www.gouv.qc.ca/",106        "https://www.banquenationale.ca/",107        "https://ca.finance.yahoo.com/quote/AAPL/",108        "https://news.ycombinator.com/item?id=12345678",109        "https://www.ebay.ca/itm/123456789012",110        "https://www.aircanada.com/ca/en/aco/home.html",111        "https://www.costco.ca/",112        "https://www.lemonde.fr/international/article/2024/05/01/titre-de-l-article_6230000_3210.html",113        "https://www.radio-canada.ca/nouvelle/2000000/titre",114        "https://www.lapresse.ca/actualites/2024-05-01/titre.php",115        "https://www.walmart.ca/en/ip/item/6000200000000",116        "https://www.telus.com/en/mobility",117        "https://www.videotron.com/en/support",118        "https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fconsole.aws.amazon.com%2Fconsole%2Fhome",119        "https://auth.openai.com/authorize?client_id=abc&redirect_uri=https%3A%2F%2Fchatgpt.com%2Fapi%2Fauth%2Fcallback",120        "https://www.nasa.gov/missions/",121        "https://arxiv.org/abs/1706.03762",122        "https://doi.org/10.1038/s41586-021-03819-2",123        "https://www.sciencedirect.com/science/article/pii/S0304405X00000000",124        "https://www.cbc.ca/news/canada/montreal",125        "https://www.tripadvisor.ca/Hotel_Review-g155033-d155555-Reviews-Hotel-Quebec_City_Quebec.html",126        "https://calendly.com/someone/30min?month=2024-05",127        "https://www.eventbrite.ca/e/some-event-tickets-123456789012",128        "https://firebasestorage.googleapis.com/v0/b/project.appspot.com/o/images%2Fphoto.jpg?alt=media&token=abc",129        // Known hard cases: real sites of the brand that are not in the embedded domain list.130        "https://www.paypal-community.com/",131        "https://www.googleadservices.com/pagead/aclk?sa=L&ai=abc",132        "https://www.walmart.com.mx/",133        "https://microsoft.github.io/vscode-codicons/",134    ]135136    struct Suspicious: Sendable {137        var url: String138        var expected: [URLSignalKind]139        var minimum: URLRiskLevel140    }141142    static func s(_ url: String, _ expected: [URLSignalKind], _ minimum: URLRiskLevel = .low) -> Suspicious {143        Suspicious(url: url, expected: expected, minimum: minimum)144    }145146    static let longHost = "https://" + String(repeating: "a", count: 30) + "." + String(repeating: "b", count: 30) + ".example.com/"147148    static let suspicious: [Suspicious] = [149        // Homographs and Punycode150        s("http://xn--80ak6aa92e.com/", [.internationalizedHost, .wholeScriptConfusable, .brandConfusable, .unencryptedScheme], .high),151        s("https://аррӏе.com/login", [.internationalizedHost, .wholeScriptConfusable, .brandConfusable], .high),152        s("https://pаypal.com/", [.internationalizedHost, .mixedScript, .brandConfusable], .high),153        s("https://gооgle.com", [.mixedScript, .brandConfusable], .high),154        s("https://αρρle.com", [.mixedScript, .brandConfusable], .high),155        s("https://сосо.com", [.internationalizedHost, .wholeScriptConfusable], .elevated),156        s("https://exаmple.org/", [.mixedScript], .elevated),157        s("https://xn--zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.com/", [.invalidPunycode], .elevated),158        s("https://xn--.example.com/", [.invalidPunycode], .elevated),159        s("https://example.com\u{202E}gpj.exe", [.invisibleCharacters], .elevated),160        s("https://exam\u{200B}ple.com/", [.invisibleCharacters], .elevated),161        s("https://example.com/%E2%80%AEfdp.exe", [.invisibleCharacters], .elevated),162        s("https://example.com/", [.fullWidthCharacters], .elevated),163        s("https://example。com/", [.fullWidthCharacters], .elevated),164        // Brand lookalikes165        s("https://paypa1.com/signin", [.brandConfusable], .high),166        s("https://g00gle.com", [.brandConfusable], .high),167        s("https://rnicrosoft.com", [.brandConfusable], .high),168        s("https://arnazon.com", [.brandConfusable], .high),169        s("https://pâypal.com", [.brandConfusable], .high),170        s("https://paypol.com", [.brandTyposquat], .elevated),171        s("https://netfliix.com", [.brandTyposquat], .elevated),172        s("https://micorsoft.com", [.brandTyposquat], .elevated),173        s("https://faceboook.com", [.brandTyposquat], .elevated),174        s("https://desjardlns.com", [.brandTyposquat], .elevated),175        s("https://scotiabanck.com", [.brandTyposquat], .elevated),176        s("https://instagrarn.co", [.brandConfusable], .high),177        s("https://apple.com.secure-login.example.net/id", [.brandEmbedded, .sensitiveKeywords], .high),178        s("https://www.apple.com.evil.example.net/", [.brandEmbedded, .subdomainDepth], .high),179        s("https://paypal-verify.xyz", [.brandEmbedded, .sensitiveKeywords], .elevated),180        s("https://paypal.com.account-update.info/", [.brandEmbedded], .elevated),181        s("https://secure.desjardins.com.verify-id.ca/", [.brandEmbedded], .elevated),182        s("https://netflix.billing-update.com", [.brandEmbedded, .sensitiveKeywords], .elevated),183        s("https://secureamazonpayments.com", [.brandEmbedded], .elevated),184        s("https://td-login.com", [.brandEmbedded], .elevated),185        s("https://microsoft-support-365.com", [.brandEmbedded], .elevated),186        s("https://login.live.com.session-id.example.org/", [.brandEmbedded], .elevated),187        s("https://www.google.com.url.evil-redirect.example/", [.brandEmbedded], .elevated),188        s("https://interac.e-transfer-deposit.example.com/", [.brandEmbedded], .elevated),189        s("https://netflix.support/", [.brandOtherSuffix], .low),190        s("https://www.example.net/paypal.com/signin", [.brandInPath], .low),191        // IP hosts192        s("http://3232235777/", [.obfuscatedIP, .ipHost, .unencryptedScheme], .elevated),193        s("http://0xC0A80101/", [.obfuscatedIP, .ipHost], .elevated),194        s("http://0300.0250.0001.0001/", [.obfuscatedIP], .elevated),195        s("http://0x7f.1/", [.obfuscatedIP], .elevated),196        s("http://017700000001/", [.obfuscatedIP], .elevated),197        s("https://134744072/login", [.obfuscatedIP, .ipHost], .high),198        s("http://185.199.108.153/login", [.ipHost, .unencryptedScheme], .elevated),199        s("https://[2001:4860:4860::8888]/", [.ipHost], .elevated),200        // Userinfo, port, structure201        s("https://apple.com@evil.example/", [.userinfo], .elevated),202        s("https://www.paypal.com:signin@198.41.0.4/", [.userinfo, .ipHost], .high),203        s("https://user@example.org/", [.userinfo], .low),204        s("https://example.com:8443/", [.nonDefaultPort], .low),205        s("https://a.b.c.d.example.com/", [.subdomainDepth], .low),206        s(longHost, [.longHost], .low),207        s("https://secure-login-update-account.com", [.hyphensDigits, .sensitiveKeywords], .low),208        s("https://win-prize-2024-88812.com/", [.hyphensDigits], .low),209        s("https://account-verify.example.com", [.sensitiveKeywords], .low),210        s("https://example.com/" + String(repeating: "segment/", count: 30), [.longURL], .noSignals),211        // Encoding212        s("https://ex%61mple.com/", [.encodedHost], .elevated),213        s("https://example.com/a%252Fb", [.doubleEncoding], .low),214        s("https://example.com/files%2F..%2Fadmin", [.encodedPathCharacters], .low),215        s("https://example.com/user%40evil.example/", [.encodedPathCharacters], .low),216        s("https://example.com/?q=%3Cscript%3Ealert(1)%3C/script%3E", [.encodedScript], .elevated),217        s("https://example.com/search?term=%253Cscript%253Ealert(1)", [.encodedScript, .doubleEncoding], .elevated),218        s("https://example.com/file%00.pdf", [.nullByte], .elevated),219        // Redirects and shorteners220        s("https://example.com/login?redirect=https%3A%2F%2Fevil.example.net%2Fphish", [.redirectParameter], .low),221        s("https://example.com/?next=//evil.example.net", [.redirectParameter], .low),222        s("https://example.com/go?url=https%253A%252F%252Fevil.example.net", [.redirectParameter, .doubleEncoding], .elevated),223        s("https://trusted.example.com/https://evil.example.org/x", [.nestedURLInPath], .low),224        s("https://bit.ly/abc", [.shortener], .low),225        s("https://tinyurl.com/y2k", [.shortener], .low),226        s("https://www.is.gd/abcd", [.shortener], .low),227        // Downloads and TLD228        s("https://example.com/update/setup.exe", [.downloadExtension], .low),229        s("https://example.com/profiles/wifi.mobileconfig", [.downloadExtension], .low),230        s("http://example.com/profiles/vpn.mobileconfig", [.downloadExtension, .unencryptedScheme], .elevated),231        s("https://example.com/invoice.pdf.exe", [.downloadExtension], .elevated),232        s("https://example.com/app/release.apk", [.downloadExtension], .low),233        s("https://report.zip/", [.topLevelDomain], .noSignals),234        // Schemes and invalid input235        s("javascript:alert(document.cookie)", [.nonWebScheme], .elevated),236        s("data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==", [.nonWebScheme], .elevated),237        s("file:///etc/passwd", [.nonWebScheme], .low),238        s("tel:+19005551234", [.nonWebScheme], .low),239        s("sms:+15145551234?body=STOP", [.nonWebScheme], .low),240        s("myapp://open?x=1", [.nonWebScheme], .low),241        s("ftp://ftp.example.com/pub/file.txt", [.nonWebScheme, .unencryptedScheme], .low),242        s("http://example.com/", [.unencryptedScheme], .low),243        s("example.com/path", [.missingScheme], .noSignals),244        s("intranet/wiki", [.missingScheme, .singleLabelHost], .noSignals),245        s("https://exa mple.com/", [.invalidInput], .low),246        s("not a url at all ::::", [.invalidInput], .low),247        s("https://example.com:99999/", [.invalidInput], .low),248        s("https://", [.invalidInput], .low),249    ]250}251
Files main
Menu

Theme