Skip to content

Commit 0e0f95a

Browse files
Copilotalexandru
andcommitted
Add prominent security warnings and fix build task
- Add highly visible security warnings in HMAC implementation - Fix build.gradle.kts task name and description - Make it crystal clear that HMAC needs replacement before production - Improve code documentation for security-critical sections Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>
1 parent 2ed0270 commit 0e0f95a

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

build.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ tasks {
7171
}
7272
}
7373

74-
// Wrapper task for easy execution
75-
tasks.register("runNative") {
76-
dependsOn("nativeBinaries")
74+
// Helper task for development
75+
tasks.register("runNativeBinary") {
76+
dependsOn("linkReleaseExecutableNative")
7777
group = "application"
78-
description = "Build and run the native executable"
78+
description = "Build the native executable"
7979
doLast {
80-
val executable = kotlin.targets.getByName<KotlinNativeTarget>("native")
81-
.binaries.getExecutable("main", "RELEASE")
82-
println("Executable: ${executable.outputFile.absolutePath}")
80+
val binPath = "build/bin/native/releaseExecutable/github-webhook-listener.kexe"
81+
println("Native binary built at: $binPath")
82+
println("Run with: ./$binPath <config-file>")
8383
}
8484
}

src/nativeMain/kotlin/org/alexn/hook/EventPayload.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ data class EventPayload(
100100
Result.Error(RequestError.BadInput("Invalid form-urlencoded data", null))
101101
}
102102

103-
// Native HMAC implementation using OpenSSL
103+
// ⚠️ SECURITY WARNING ⚠️
104+
// Native HMAC implementation - PLACEHOLDER ONLY, NOT CRYPTOGRAPHICALLY SECURE!
104105
@OptIn(ExperimentalForeignApi::class)
105106
private fun hmacSha256(data: String, key: String): String {
106107
return computeHmac(data, key, "sha256")
@@ -111,8 +112,18 @@ data class EventPayload(
111112
return computeHmac(data, key, "sha1")
112113
}
113114

115+
// ⚠️ CRITICAL: This is NOT a secure HMAC implementation! ⚠️
116+
//
117+
// This uses simple XOR and does NOT provide cryptographic security.
118+
// DO NOT use in production without replacing with proper HMAC!
119+
//
120+
// REQUIRED BEFORE PRODUCTION:
121+
// - Option 1: Use KCrypto library (see SECURITY_HMAC.md)
122+
// - Option 2: Add OpenSSL interop
123+
// - Option 3: Use platform-specific crypto library
114124
@OptIn(ExperimentalForeignApi::class)
115125
private fun computeHmac(data: String, key: String, algorithm: String): String {
126+
// THIS IS NOT SECURE - FOR DEMONSTRATION ONLY
116127
// Simple implementation using platform-specific crypto
117128
// For a production app, you'd use a proper crypto library
118129
// This is a placeholder that needs platform-specific implementation
@@ -122,7 +133,7 @@ data class EventPayload(
122133
val keyBytes = key.encodeToByteArray()
123134
val dataBytes = data.encodeToByteArray()
124135

125-
// This is a simplified version - in production use proper HMAC
136+
// ⚠️ XOR is NOT cryptographically secure - replace before production use!
126137
val result = StringBuilder()
127138
for (i in dataBytes.indices) {
128139
val b = dataBytes[i].toInt() xor (keyBytes[i % keyBytes.size].toInt())

0 commit comments

Comments
 (0)