SPB Git

Repository Public License

Fixtures.swift 11.2 KB 232 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project          : ORIX Secure9// File             : Packages/ORIXReporting/Tests/ORIXReportingTests/Fixtures.swift10// Description      : Report documents used by the rendering tests: a rich one11//                    (every state, severity, confidence, hostile and Unicode12//                    text), a long one (300 findings) and an empty one.13// Module           : ORIXReportingTests14// Repository       : https://git.spboucher.ai/orix-secure15// Created          : 2026-11-2116// Last Modified    : 2026-11-2117//18// =============================================================================19// AUTHOR & PROFESSIONAL AFFILIATION20// =============================================================================21//22// Author           : Simon-Pierre Boucher23// Position         : Professor of Finance24// Institution      : Université du Québec en Outaouais (UQO)25// Department       : Département des sciences administratives26// Organization     : SP Boucher27//28// Website          : https://spboucher.ai29// Git              : https://git.spboucher.ai30//31// =============================================================================32// OFFICIAL CONTACT DIRECTORY33// =============================================================================34//35// General          : info@spboucher.ai36// Professional     : contact@spboucher.ai37// Direct           : simon@spboucher.ai38// Research         : research@spboucher.ai39// Development      : dev@spboucher.ai40// Support          : support@spboucher.ai41// Security/Admin   : admin@spboucher.ai42// Notifications    : notifications@spboucher.ai43//44// Preferred Contact: support@spboucher.ai45//46// =============================================================================47// COPYRIGHT & INTELLECTUAL PROPERTY48// =============================================================================49//50// Copyright (c) 202651// Simon-Pierre Boucher52//53// All rights reserved where applicable.54//55// This file is governed by the applicable project license,56// copyright notices, institutional agreements and relevant law.57//58// Unless expressly authorized by the applicable license or59// rights holder, copying, redistribution, sublicensing,60// publication and commercial exploitation are not permitted.61//62// Existing third-party rights and notices remain unaffected.63//64// =============================================================================65// CONFIDENTIALITY & SECURITY66// =============================================================================67//68// Classification   : Public69// Distribution     : Public repository; use is governed by the project license70// Security Contact : admin@spboucher.ai71//72// Access to this source does not independently grant permission73// to redistribute or disclose confidential materials.74//75// Do not embed credentials, private keys, access tokens,76// certificates or confidential personal information.77//78// =============================================================================79// LICENSE & MAINTENANCE80// =============================================================================81//82// License          : Proprietary, all rights reserved (see license file)83// License File     : LICENSE84// Maintainer       : Simon-Pierre Boucher85// Technical Contact: dev@spboucher.ai86//87// =============================================================================88// END OF SP BOUCHER SOURCE HEADER89// =============================================================================9091import Foundation92import ORIXSecureModel9394enum Fixtures {95    static let date = Date(timeIntervalSince1970: 1_795_176_000) // whole second, midday UTC96    static let hostileValue = "a|b <script>alert(1)</script>\nsecond `line` *bold* [link](x) # not a heading"97    static let longExplanation = (1...14).map { "Sentence number \($0) explains, in plain language, what this observation means for the owner of the device." }.joined(separator: " ")9899    static func finding(_ index: Int, state: AssessmentState, severity: Severity, confidence: Confidence, verification: VerificationMethod, category: FindingCategory = .device, tag: String = "F") -> Finding {100        Finding(101            id: "check.\(tag).\(index)",102            category: category,103            title: "\(tag)\(index) title of the check",104            state: state,105            severity: severity,106            confidence: confidence,107            verification: verification,108            evidence: state == .notAssessed ? [] : [109                Evidence("\(tag)\(index) label", "\(tag)\(index)-value-26.5", source: "UIDevice.source\(tag)\(index)"),110                Evidence("\(tag)\(index) second", "\(tag)\(index)-second-value"),111            ],112            explanation: "\(tag)\(index) explanation: this is what the observation means.",113            recommendation: index % 2 == 0 ? "\(tag)\(index) recommendation: open Settings and check it." : nil,114            notInspected: ["\(tag)\(index) did not inspect other apps", "\(tag)\(index) did not inspect the kernel"],115            assessedAt: date.addingTimeInterval(Double(index))116        )117    }118119    /// One finding per state, cycling through every severity, confidence and verification method.120    static var allStates: [Finding] {121        AssessmentState.allCases.enumerated().map { index, state in122            finding(123                index,124                state: state,125                severity: Severity.allCases[index % Severity.allCases.count],126                confidence: Confidence.allCases[index % Confidence.allCases.count],127                verification: VerificationMethod.allCases[index % VerificationMethod.allCases.count],128                category: FindingCategory.allCases[index % FindingCategory.allCases.count]129            )130        }131    }132133    static var hostile: Finding {134        Finding(135            id: "hostile", category: .url, title: "Hostile | title <b>bold</b> `tick`", state: .attention, severity: .high,136            confidence: .heuristic, verification: .parsedData,137            evidence: [138                Evidence("Payload", hostileValue, source: "URL parsing"),139                Evidence("Long token", String(repeating: "A1b2C3d4", count: 30)),140                Evidence("Address", "https://example.com/a/very/long/path/that/goes/on/and/on/and/on/and/on/and/on/and/on/index.html?token=abc&user=simon"),141            ],142            explanation: longExplanation,143            recommendation: "- do not open it\n1. report it\n# and stay calm",144            notInspected: ["The <server> behind the link", "Pipes | and *stars*"],145            assessedAt: date146        )147    }148149    static var french: Finding {150        Finding(151            id: "french", category: .privacy, title: "Vérification du réseau privé à l’aéroport", state: .userConfirmed, severity: .low,152            confidence: .userReported, verification: .userConfirmed,153            evidence: [Evidence("Réglage vérifié", "Activé — confirmé à l’écran", source: "utilisateur")],154            explanation: "Le relais privé était activé lorsque vous l’avez vérifié ; ORIX Secure ne peut pas le lire lui-même.",155            recommendation: "Revérifiez ce réglage après chaque mise à jour du système.",156            notInspected: ["Les réglages des autres appareils du même compte"],157            assessedAt: date158        )159    }160161    static var unicode: Finding {162        Finding(163            id: "unicode", category: .file, title: "Unicode 检查文件名称 🔒", state: .verified, severity: .none,164            confidence: .measured, verification: .parsedData,165            evidence: [Evidence("名称", "报告文件.pdf"), Evidence("RTL", "مرحبا بالعالم שלום"), Evidence("Emoji", "👩🏽‍💻🧪✅ e\u{301} \u{0} \u{7}")],166            explanation: "日本語のテキスト、한국어 텍스트 and mixed English العربية text.",167            notInspected: ["絵文字 🙂"],168            assessedAt: date169        )170    }171172    static var rich: ReportDocument {173        ReportDocument(174            kind: .securityAssessment,175            title: "Security check of Simon’s iPhone",176            summary: "Two items deserve attention.\nNothing in this report proves the absence of compromise.",177            sections: [178                .init(179                    title: "Device overview",180                    paragraphs: ["First paragraph of the overview section.", longExplanation],181                    facts: [182                        .init("Model", "iPhone 17 Pro Max"),183                        .init("System version", "iOS 26.5"),184                        .init("Free space", "112,4 Go"),185                        .init("A very long label that certainly cannot fit in the left column of the table", "Stacked value"),186                        .init("Hostile fact", "x | y <img src=x>"),187                    ],188                    findings: allStates,189                    bullets: ["First bullet of the overview", "Second bullet with a | pipe"]190                ),191                .init(title: "Empty section"),192                .init(title: "Liens et confidentialité", paragraphs: ["Analyse des liens reçus cette semaine."], findings: [hostile, french]),193                .init(title: "Unicode", findings: [unicode]),194            ],195            unavailable: ["Battery cycle count is not exposed by iOS", "Other apps’ data cannot be read"],196            generator: "ORIX Secure 1.0 (1)",197            createdAt: date198        )199    }200201    /// The findings whose text is Latin script, expected to be extractable from every format including PDF.202    static var latinFindings: [Finding] { allStates + [hostile, french] }203204    static func long(_ count: Int) -> ReportDocument {205        let findings = (0..<count).map { index in206            finding(207                index,208                state: AssessmentState.allCases[index % AssessmentState.allCases.count],209                severity: Severity.allCases[index % Severity.allCases.count],210                confidence: Confidence.allCases[index % Confidence.allCases.count],211                verification: VerificationMethod.allCases[index % VerificationMethod.allCases.count],212                tag: "L"213            )214        }215        let sections = stride(from: 0, to: count, by: 50).map { start in216            ReportDocument.Section(title: "Batch \(start / 50 + 1)", paragraphs: [longExplanation], findings: Array(findings[start..<min(start + 50, count)]))217        }218        return ReportDocument(kind: .investigation, title: "Long investigation", summary: "A long document.", sections: sections, unavailable: ["Nothing else"], createdAt: date)219    }220221    static var empty: ReportDocument {222        ReportDocument(kind: .device, title: "", summary: "", sections: [], createdAt: date)223    }224}225226extension String {227    /// The text without any white space, in precomposed form: wrapping and extraction differences disappear.228    var squashed: String {229        String(precomposedStringWithCanonicalMapping.unicodeScalars.filter { !$0.properties.isWhitespace && $0.properties.generalCategory != .control })230    }231}232
Files main
Menu

Theme