Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/swift/Demo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SquidGate sample — Swift (intentional vulnerabilities for demo)
let apiKey = "swift-demo-secret-key-not-real"

Check failure on line 2 in examples/swift/Demo.swift

View workflow job for this annotation

GitHub Actions / SquidGate

Hardcoded API Key / Secret

HIGH [high] An API key is hardcoded directly in source code as a string literal. This exposes credentials in version control and can lead to secret leakage even if labeled as demo/not-real. Recommendation: Remove hardcoded secrets. Load from environment variables or a secure vault, e.g. let apiKey = ProcessInfo.processInfo.environment["API_KEY"] ?? "" CWE: CWE-798 OWASP: A07:2021

func findUser(id: String) -> String {
// SQL injection
return "SELECT * FROM users WHERE id = '\(id)'"
}

Check failure on line 7 in examples/swift/Demo.swift

View workflow job for this annotation

GitHub Actions / SquidGate

SQL Injection

HIGH [high] User-controlled 'id' parameter is directly interpolated into a SQL query string using string interpolation without escaping or parameterization. Recommendation: Use parameterized queries or a safe ORM. Example: Use SQLite.swift or similar with prepared statements instead of string concatenation. CWE: CWE-89 OWASP: A03:2021

func runShell(_ input: String) {
// command injection
let task = Process()
task.launchPath = "/bin/sh"
task.arguments = ["-c", "echo \(input)"]
task.launch()
}

Check failure on line 15 in examples/swift/Demo.swift

View workflow job for this annotation

GitHub Actions / SquidGate

OS Command Injection

HIGH [high] Untrusted 'input' is passed unsanitized into a shell command via Process.launchPath with /bin/sh -c and string interpolation in arguments, allowing arbitrary command execution. Recommendation: Avoid shell invocation with user input. Use Process with separate arguments array without shell, or validate/sanitize input strictly. Example: task.arguments = ["-c", "echo", input] but better to avoid shell entirely. CWE: CWE-78 OWASP: A03:2021
Loading