Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : QYVORA7// File : security/policies/semgrep/qyvora-parsers.swift8// Module : Security9// Repository : https://git.spboucher.ai/qyvora10// Project Website : Not specified11// Created : 2026-12-0412// Last Modified : 2026-12-0413//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : None specified (no license file in this repository)33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041// Test snippets of qyvora-parsers.yaml (`semgrep --test security/policies/semgrep`). Never compiled.4243func parse(_ input: [UInt8], text: String, declaredLength: Int) throws -> [UInt8] {44 // ruleid: qyvora-parser-try-bang45 let a = try! decode(input)46 // ok: qyvora-parser-try-bang47 let b = try decode(input)48 // ok: qyvora-parser-try-bang49 let c = try? decode(input)5051 // ruleid: qyvora-parser-trap-call52 if input.isEmpty { fatalError("empty") }53 // ruleid: qyvora-parser-trap-call54 precondition(input.count == 32)55 // ruleid: qyvora-parser-trap-call56 preconditionFailure("unreachable")57 // ok: qyvora-parser-trap-call58 guard input.count == 32 else { throw ParseError.length }5960 // ruleid: qyvora-parser-force-unwrap61 let d = input.first!62 // ruleid: qyvora-parser-force-unwrap63 let e = UInt8(text)! + 164 // ruleid: qyvora-parser-force-unwrap65 let f = value as! [UInt8]66 // ok: qyvora-parser-force-unwrap67 let g = input.first ?? 068 // ok: qyvora-parser-force-unwrap69 if a != b && !flag { return c ?? [] }7071 // ruleid: qyvora-parser-unchecked-length-arithmetic72 var out = [UInt8](repeating: 0, count: declaredLength)73 // ruleid: qyvora-parser-unchecked-length-arithmetic74 out.reserveCapacity(length)75 // ok: qyvora-parser-unchecked-length-arithmetic76 var fixed = [UInt8](repeating: 0, count: 32)77 return out + fixed + [d, e] + f + [g]78}79