-
Notifications
You must be signed in to change notification settings - Fork 1
CI-sichere Release-Signing-Konfiguration für app und humanoperator
#89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # CI Signing für Release-Builds | ||
|
|
||
| Die Module `app` und `humanoperator` erwarten für Release-Tasks eine Signing-Konfiguration über Umgebungsvariablen. | ||
|
|
||
| ## Benötigte CI-Secrets | ||
|
|
||
| - `ANDROID_KEYSTORE_PATH`: Absoluter oder relativ zum Projekt auflösbarer Pfad zur Keystore-Datei. | ||
| - `ANDROID_KEY_ALIAS`: Alias des Release-Keys. | ||
| - `ANDROID_KEYSTORE_PASSWORD`: Passwort der Keystore-Datei. | ||
| - `ANDROID_KEY_PASSWORD`: Passwort des Keys. | ||
|
|
||
| ## Verhalten bei fehlenden Variablen | ||
|
|
||
| - Für **Release-Tasks** (Taskname enthält `release`) wird der Build mit einer klaren Fehlermeldung abgebrochen, wenn eine der Variablen fehlt. | ||
| - Für Nicht-Release-Tasks bleibt die Signing-Config ungesetzt, damit lokale Debug-Builds weiter funktionieren. | ||
|
|
||
| ## Wichtiger Hinweis zu Firebase | ||
|
|
||
| `google-services.json` bleibt unverändert versioniert und ist **nicht** Teil der Signing-Logik. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,21 @@ plugins { | |
| id("com.google.gms.google-services") | ||
| } | ||
|
|
||
| val releaseSigningEnv = mapOf( | ||
| "ANDROID_KEYSTORE_PATH" to System.getenv("ANDROID_KEYSTORE_PATH"), | ||
| "ANDROID_KEY_ALIAS" to System.getenv("ANDROID_KEY_ALIAS"), | ||
| "ANDROID_KEYSTORE_PASSWORD" to System.getenv("ANDROID_KEYSTORE_PASSWORD"), | ||
| "ANDROID_KEY_PASSWORD" to System.getenv("ANDROID_KEY_PASSWORD"), | ||
| ) | ||
|
|
||
| val missingReleaseSigningEnv = releaseSigningEnv | ||
| .filterValues { it.isNullOrBlank() } | ||
| .keys | ||
|
|
||
| val isReleaseTaskRequested = gradle.startParameter.taskNames.any { task -> | ||
| task.contains("release", ignoreCase = true) | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.screenoperator.humanoperator" | ||
| compileSdk = 35 | ||
|
|
@@ -21,10 +36,25 @@ android { | |
| } | ||
| } | ||
|
|
||
| signingConfigs { | ||
| create("release") { | ||
| if (missingReleaseSigningEnv.isEmpty()) { | ||
| storeFile = file(releaseSigningEnv.getValue("ANDROID_KEYSTORE_PATH")!!) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛑 Security Vulnerability: Using Footnotes
|
||
| storePassword = releaseSigningEnv.getValue("ANDROID_KEYSTORE_PASSWORD") | ||
| keyAlias = releaseSigningEnv.getValue("ANDROID_KEY_ALIAS") | ||
| keyPassword = releaseSigningEnv.getValue("ANDROID_KEY_PASSWORD") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| buildTypes { | ||
| release { | ||
| isMinifyEnabled = false | ||
| proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
| if (missingReleaseSigningEnv.isEmpty()) { | ||
| signingConfig = signingConfigs.getByName("release") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -43,6 +73,13 @@ android { | |
| } | ||
| } | ||
|
|
||
| if (isReleaseTaskRequested && missingReleaseSigningEnv.isNotEmpty()) { | ||
| error( | ||
| "Release signing env vars missing for module :humanoperator: ${missingReleaseSigningEnv.joinToString(", ")}. " + | ||
| "Set ANDROID_KEYSTORE_PATH, ANDROID_KEY_ALIAS, ANDROID_KEYSTORE_PASSWORD and ANDROID_KEY_PASSWORD." | ||
| ) | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation("androidx.core:core-ktx:1.9.0") | ||
| implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛑 Security Vulnerability: Using
file()with environment variable path enables path traversal attacks1. An attacker controllingANDROID_KEYSTORE_PATHcould read arbitrary files from the build system (e.g.,../../../../etc/passwd). Validate the path resolves within expected directories or use absolute path validation before passing tofile().Footnotes
CWE-22: Path Traversal - https://cwe.mitre.org/data/definitions/22.html ↩