Skip to content

Instantly share code, notes, and snippets.

View quangDecember's full-sized avatar
💭
my new year resolution is to not force unwrapped optionals

Quang quangDecember

💭
my new year resolution is to not force unwrapped optionals
View GitHub Profile

Package Management exploitation

Presented by Quang and Nikolas

Background

Authors

  • Justin Gardner and Alex Birsan are two “Bug Bounty Hunters”.
  • Bug Bounties: Software organizations will compensate individuals for disclosing any bugs (including security vulnerabilities) found on their platform.
  • In the summer of 2020, they were targeting Paypal to see if they could find any security vulnerabilities worth reporting.

Project Dependencies

@quangDecember
quangDecember / Technical limitations Swift framework modularity.md
Last active June 10, 2020 07:05
Technical limitations when working with in Swift modular frameworks

Technical limitations when working with modularity in Swift frameworks

The following Gist list the technical challenges and some decision making while attempting to updating a binary frameworks to a modular architecture with multiple binary frameworks.

Bypassing the access modifiers

So far this is the biggest challenge when working with Swift modularity.

Private Header with Objective-C

@quangDecember
quangDecember / Simple-browser-WKWebView-UIKit.md
Last active November 2, 2023 08:45
Creating Simple Web Browser with WKWebView & UINavigationController

WKWebView was first introduced on iOS 8. With Apple finally release a deadline for all apps to migrate away from UIWebView, this series and this post is here to help you explore the features of WKWebView. In this blog post you will create a simple web browser with some basic features such as displaying content, back and forward.

Setup Previews for your project

One of the most interesting things coming out with Xcode 11 is SwiftUI's PreviewProvider, which provides a way to preview the UI during development instantly on multiple devices, multiple settings at the same time.

To preview UIViewController and UIView, you need to download previewing code from NSHipster

Since we are making this browser with a navigation bar, our main UIViewController needs to be embedded inside a UINavigationController. Therefore the previewing code would be like this:

@quangDecember
quangDecember / Device-orientation-Observable-Object.swift
Created November 22, 2019 04:54
Combine ObservableObject for SwiftUI to refresh with orientation
@available(iOS 13.0, *)
class DeviceOrientationObservable : ObservableObject {
@Published var orientation = UIDevice.current.orientation
init () {
NotificationCenter.default.addObserver(self, selector: #selector(isRotated), name: UIDevice.orientationDidChangeNotification, object: nil)
}
@objc func isRotated() {
self.orientation = UIDevice.current.orientation
}
}
@quangDecember
quangDecember / UserDefaults+Codable+propertyWrapper.swift
Created November 21, 2019 02:29
property wrappers for saving to UserDefaults, generics or Codable
import Foundation
@propertyWrapper
struct UserDefault<T> {
let key: String
let defaultValue: T
init(_ key: String, defaultValue: T) {
self.key = key
@quangDecember
quangDecember / wrapper+AES+CommonCrypto.swift
Created November 13, 2019 10:53
property wrappers for encryption, using builtin Apple library
import Foundation
import CommonCrypto
struct AES256 : Codable {
private var key: Data
private var iv: Data
public init(key: Data, iv: Data) throws {
guard key.count == kCCKeySizeAES256 else {
@quangDecember
quangDecember / build-xcframework.sh
Last active February 19, 2024 10:05
Build XCFramework (universal) framework, create new Aggregate target, add to New Run Script Phase
env > env.txt
instruments -s devices > devices.txt
#! /bin/sh -e
# This script demonstrates archive and create action on frameworks and libraries
# Based on script by @author Boris Bielik
# Release dir path
OUTPUT_DIR_PATH="${PROJECT_DIR}/XCFramework"
function archivePathSimulator {
protocol APIRequest {
func mockURLProtocolClass() -> AnyClass?
}
extension APIRequest {
func mockURLProtocolClass() -> AnyClass? {
return nil
}
}
class EmployeeInfoRequest {
#if MOCK_URL_PROTOCOL
class iMockURLProtocol: MockURLProtocol {
override func startLoading() {
iMockURLProtocol.requestHandler = { request in
let response = HTTPURLResponse.init(url: request.url!, statusCode: 200, httpVersion: "2.0", headerFields: nil)!
return (response,mockEmployeeInfoData)
}
super.startLoading()
let employeeInfo = """
{
"employeeID":156789,
"name": "Harris Smith"
}
"""
MockURLProtocol.requestHandler = { request in
let response = HTTPURLResponse.init(url: request.url!, statusCode: 200, httpVersion: "2.0", headerFields: nil)!
return (response,employeeInfo.data(using: .utf8)!)
}