-
Notifications
You must be signed in to change notification settings - Fork 1
Enforce CI release signing with env vars and add documentation #90
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
bcf87c3
bf63556
e8dc25a
3f1fbba
af9a99c
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,23 @@ 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"), | ||
|
Comment on lines
+8
to
+11
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: Passwords in environment variables will be logged in Gradle build outputs1. Replace direct password access with secure property file handling or Gradle's built-in secrets management. At minimum, ensure CI systems mask these variables in logs. Footnotes
|
||
| ) | ||
|
|
||
| val missingReleaseSigningEnv = releaseSigningEnv | ||
| .filterValues { it.isNullOrBlank() } | ||
| .keys | ||
|
|
||
| val isReleaseTaskRequested = gradle.startParameter.taskNames.any { task -> | ||
| task.contains("release", ignoreCase = true) | ||
| } | ||
|
|
||
| val missingReleaseSigningEnvText = missingReleaseSigningEnv.joinToString(separator = ", ") | ||
|
|
||
| android { | ||
| namespace = "com.screenoperator.humanoperator" | ||
| compileSdk = 35 | ||
|
|
@@ -21,10 +38,22 @@ android { | |
| } | ||
| } | ||
|
|
||
| signingConfigs { | ||
| create("release") { | ||
| if (missingReleaseSigningEnv.isEmpty()) { | ||
| storeFile = file(releaseSigningEnv.getValue("ANDROID_KEYSTORE_PATH")!!) | ||
| 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") | ||
| signingConfig = if (missingReleaseSigningEnv.isEmpty()) signingConfigs.getByName("release") else null | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -43,6 +72,13 @@ android { | |
| } | ||
| } | ||
|
|
||
| if (isReleaseTaskRequested && missingReleaseSigningEnv.isNotEmpty()) { | ||
| error( | ||
| "Release signing env vars missing for module :humanoperator: ${missingReleaseSigningEnvText}. " + | ||
| "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: Passwords in environment variables will be logged in Gradle build outputs1. Replace direct password access with secure property file handling or Gradle's built-in secrets management. At minimum, ensure CI systems mask these variables in logs.
Footnotes
CWE-532: Insertion of Sensitive Information into Log File - https://cwe.mitre.org/data/definitions/532.html ↩