Skip to content

Commit 4543c69

Browse files
committed
ci: validate secrets after bundling
Introduces --verify-credentials flag which can be passed to status app and it will check for all the necessary credentials provided by status-jenkins-lib. related changes are here : status-im/status-jenkins-lib#120 Adds an Audit stage in jenkins which checks for these credentials, this is an integration test in CI to ensure that bundled app has all the necessary secrets.
1 parent ac2ac73 commit 4543c69

11 files changed

+106
-10
lines changed

ci/Jenkinsfile.combined

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env groovy
22

3-
library 'status-jenkins-lib@v1.9.27'
3+
library 'status-jenkins-lib@refactor-common-secrets'
44

55
/* Object to store public URLs for description. */
66
urls = [:]

ci/Jenkinsfile.linux

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env groovy
2-
library 'status-jenkins-lib@v1.9.27'
2+
library 'status-jenkins-lib@refactor-common-secrets'
33

44
/* Options section can't access functions in objects. */
55
def isPRBuild = utils.isPRBuild()
@@ -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.linux-nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env groovy
22

3-
library 'status-jenkins-lib@v1.9.27'
3+
library 'status-jenkins-lib@refactor-common-secrets'
44

55
/* Options section can't access functions in objects. */
66
def isPRBuild = utils.isPRBuild()

ci/Jenkinsfile.macos

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env groovy
2-
library 'status-jenkins-lib@v1.9.27'
2+
library 'status-jenkins-lib@refactor-common-secrets'
33

44
/* Options section can't access functions in objects. */
55
def isPRBuild = utils.isPRBuild()
@@ -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.tests-e2e

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env groovy
2-
library 'status-jenkins-lib@v1.9.16'
2+
library 'status-jenkins-lib@refactor-common-secrets'
33

44
pipeline {
55

ci/Jenkinsfile.tests-nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env groovy
2-
library 'status-jenkins-lib@v1.9.16'
2+
library 'status-jenkins-lib@refactor-common-secrets'
33

44
/* Options section can't access functions in objects. */
55
def isPRBuild = utils.isPRBuild()

ci/Jenkinsfile.tests-ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env groovy
2-
library 'status-jenkins-lib@v1.9.16'
2+
library 'status-jenkins-lib@refactor-common-secrets'
33

44
/* Options section can't access functions in objects. */
55
def isPRBuild = utils.isPRBuild()

ci/Jenkinsfile.windows

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env groovy
2-
library 'status-jenkins-lib@v1.9.27'
2+
library 'status-jenkins-lib@refactor-common-secrets'
33

44
/* Options section can't access functions in objects. */
55
def isPRBuild = utils.isPRBuild()
@@ -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)

0 commit comments

Comments
 (0)