Skip to content

Commit edff596

Browse files
committed
ci: validate secrets after bundling
1 parent e0b5773 commit edff596

File tree

6 files changed

+98
-2
lines changed

6 files changed

+98
-2
lines changed

ci/Jenkinsfile.linux

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,31 @@ pipeline {
125125
} }
126126
}
127127

128+
stage('Verify Credentials') {
129+
steps { script {
130+
sh """
131+
tar -xzf ${env.STATUS_CLIENT_TARBALL} -C ${env.WORKSPACE_TMP}
132+
"""
133+
134+
def appImagePath = sh(
135+
script: "basename ${env.STATUS_CLIENT_APPIMAGE}",
136+
returnStdout: true
137+
).trim()
138+
139+
sh """
140+
chmod +x ${env.WORKSPACE_TMP}/${appImagePath}
141+
"""
142+
143+
// Run verification inside the credentials context
144+
desktop.withCommonCredentials([]) {
145+
sh(
146+
script: "${env.WORKSPACE_TMP}/${appImagePath} --verify-credentials"
147+
)
148+
}
149+
150+
} }
151+
}
152+
128153
stage('Parallel Upload') {
129154
parallel {
130155
stage('Upload') {

ci/Jenkinsfile.macos

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,21 @@ pipeline {
140140
} }
141141
}
142142

143+
stage('Verify Credentials') {
144+
steps { script {
145+
sh "hdiutil attach ${env.STATUS_CLIENT_DMG} -mountpoint /tmp/status-mount"
146+
147+
desktop.withCommonCredentials([]) {
148+
sh(
149+
script: "/tmp/status-mount/Status.app/Contents/MacOS/nim_status_client --verify-credentials"
150+
)
151+
}
152+
153+
sh "hdiutil detach /tmp/status-mount"
154+
155+
} }
156+
}
157+
143158
stage('Notarize') {
144159
when { expression { utils.isReleaseBuild() } }
145160
steps { script {

ci/Jenkinsfile.windows

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ pipeline {
125125
} }
126126
}
127127

128+
stage('Verify Credentials') {
129+
steps { script {
130+
sh "7z x ${env.STATUS_CLIENT_7Z} -o${env.WORKSPACE_TMP}/extracted"
131+
132+
def exeName = sh(
133+
script: "basename ${env.STATUS_CLIENT_EXE}",
134+
returnStdout: true
135+
).trim()
136+
137+
desktop.withCommonCredentials([]) {
138+
sh(
139+
script: "${env.WORKSPACE_TMP}/extracted/bin/${exeName} --verify-credentials"
140+
)
141+
}
142+
143+
} }
144+
}
145+
128146
stage('Parallel Upload') {
129147
/* Uploads on Windows are slow. */
130148
parallel {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os, strutils, sequtils
2+
3+
proc runCredentialVerification*(): int =
4+
echo "Starting credential verification"
5+
6+
let thingsToCheck = getEnv("THINGS_TO_CHECK")
7+
if thingsToCheck.len == 0:
8+
echo "ERROR: THINGS_TO_CHECK environment variable not set"
9+
return 1
10+
11+
let credNames = thingsToCheck.splitLines().mapIt(it.strip()).filterIt(it.len > 0)
12+
if credNames.len == 0:
13+
echo "ERROR: No credentials to check"
14+
return 1
15+
16+
var missingCreds: seq[string] = @[]
17+
18+
for credName in credNames:
19+
if not existsEnv(credName):
20+
missingCreds.add(credName)
21+
echo "ERROR: Missing environment variable: ", credName
22+
23+
if missingCreds.len > 0:
24+
echo "ERROR: Credential verification failed. Missing ", missingCreds.len, " out of ", credNames.len, " credentials"
25+
return 1
26+
else:
27+
echo "SUCCESS: All ", credNames.len, " credentials verified successfully"
28+
return 0

src/env_cli_vars.nim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ type StatusDesktopConfig = object
296296
desc: "Sets address for prometheus metrics"
297297
name: "METRICS_ADDRESS"
298298
abbr: "metrics-address" .}: string
299+
verifyCredentials* {.
300+
defaultValue: false
301+
desc: "Verify that all required credentials are present and exit"
302+
name: "VERIFY_CREDENTIALS"
303+
abbr: "verify-credentials" .}: bool
299304

300305
# On macOS the first time when a user gets the "App downloaded from the
301306
# internet" warning, and clicks the Open button, the OS passes a unique process
@@ -310,4 +315,4 @@ else:
310315
if defined(macosx):
311316
cliParams.keepIf(proc(p: string): bool = not p.startsWith("-psn_"))
312317

313-
let desktopConfig = StatusDesktopConfig.load(cmdLine = cliParams, envVarsPrefix = RUN_TIME_PREFIX)
318+
let desktopConfig* = StatusDesktopConfig.load(cmdLine = cliParams, envVarsPrefix = RUN_TIME_PREFIX)

src/nim_status_client.nim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import
88

99
import status_go
1010
import app/core/main
11+
import app/core/credential_verifier
1112
import constants as main_constants
1213
import statusq_bridge
1314

1415
import app/global/global_singleton
1516
import app/global/local_app_settings
1617
import app/boot/app_controller
18+
import env_cli_vars
1719

1820
featureGuard KEYCARD_ENABLED:
1921
import keycard_go
@@ -118,7 +120,7 @@ proc ensureDirectories*(dataDir, tmpDir, logDir: string) =
118120
proc logHandlerCallback(messageType: cint, message: cstring, category: cstring, file: cstring, function: cstring, line: cint) {.cdecl, exportc.} =
119121
# Initialize Nim GC stack bottom for foreign threads
120122
# https://status-im.github.io/nim-style-guide/interop.html#calling-nim-code-from-other-languages
121-
when declared(setupForeignThreadGc):
123+
when declared(setupForeignThreadGc):
122124
setupForeignThreadGc()
123125
when declared(nimGC_setStackBottom):
124126
var locals {.volatile, noinit.}: pointer
@@ -154,6 +156,9 @@ proc logHandlerCallback(messageType: cint, message: cstring, category: cstring,
154156
warn "qt message of unknown type", messageType = int(messageType)
155157

156158
proc mainProc() =
159+
# used in CI
160+
if env_cli_vars.desktopConfig.verifyCredentials:
161+
quit(runCredentialVerification())
157162

158163
when defined(macosx) and defined(arm64):
159164
var signalStack: cstring = cast[cstring](allocShared(SIGSTKSZ))

0 commit comments

Comments
 (0)