@@ -892,15 +892,23 @@ jobs:
892
892
893
893
find "${DEPLOY_PATH}" -exec ls -lh {} \;
894
894
895
- # Encrypt .img and .img.zip files and remove the originals
896
895
# Encryption is required for private device types, and signed images.
896
+ # We do this to obfuscate private device images on public repos,
897
+ # and to prevent running signed images that have not gone through review and may have security flaws.
898
+ # Additional file extensions can be added below, but are only required if included as artifact uploads.
897
899
- name : Encrypt signed/private artifacts
898
900
if : inputs.sign-image || needs.balena-lib.outputs.is_private == 'true'
899
901
env :
900
902
PBDKF2_PASSPHRASE : ${{ secrets.PBDKF2_PASSPHRASE }}
903
+ PATHS_TO_ENCRYPT : |
904
+ ${{ env.S3_DEPLOY_PATH }}/balena-image.docker
905
+ ${{ env.S3_DEPLOY_PATH }}/image/*.img.zip
906
+ ${{ env.S3_DEPLOY_PATH }}/compressed*/*.deflate
907
+ ${{ env.S3_DEPLOY_PATH }}/*.manifest
908
+ ${{ env.S3_DEPLOY_PATH }}/kernel_modules_headers.tar.gz
901
909
run : |
902
910
set -x
903
- for file in "${S3_DEPLOY_PATH}"/**/*.img "${S3_DEPLOY_PATH}"/**/*.img.zip "${S3_DEPLOY_PATH}"/**/*.docker "${S3_DEPLOY_PATH}"/**/*.deflate ; do
911
+ for file in $(echo "${PATHS_TO_ENCRYPT}" | tr '\n' ' ') ; do
904
912
openssl enc -v -e -aes-256-cbc -k "${PBDKF2_PASSPHRASE}" -pbkdf2 -iter 310000 -md sha256 -salt -in "${file}" -out "${file}.enc"
905
913
rm "${file}"
906
914
done
@@ -932,6 +940,7 @@ jobs:
932
940
${{ env.S3_DEPLOY_PATH }}/VERSION*
933
941
${{ env.S3_DEPLOY_PATH }}/*.manifest
934
942
${{ env.S3_DEPLOY_PATH }}/kernel_modules_headers.tar.gz
943
+ ${{ env.S3_DEPLOY_PATH }}/kernel_modules_headers.tar.gz.enc
935
944
936
945
# Upload artifacts used by Leviathan for test suites.
937
946
# Primarily raw and flasher images, and the hostapp docker image, and the kernel module headers.
@@ -952,6 +961,7 @@ jobs:
952
961
${{ env.S3_DEPLOY_PATH }}/balena-image.docker
953
962
${{ env.S3_DEPLOY_PATH }}/balena-image.docker.enc
954
963
${{ env.S3_DEPLOY_PATH }}/kernel_modules_headers.tar.gz
964
+ ${{ env.S3_DEPLOY_PATH }}/kernel_modules_headers.tar.gz.enc
955
965
956
966
# #############################
957
967
# hostapp Deploy
@@ -1014,9 +1024,12 @@ jobs:
1014
1024
if : inputs.sign-image || needs.balena-lib.outputs.is_private == 'true'
1015
1025
env :
1016
1026
PBDKF2_PASSPHRASE : ${{ secrets.PBDKF2_PASSPHRASE }}
1027
+ PATHS_TO_DECRYPT : |
1028
+ ${{ env.DEPLOY_PATH }}/*.enc
1029
+ ${{ env.DEPLOY_PATH }}/**/*.enc
1017
1030
run : |
1018
1031
set -x
1019
- for enc in "${DEPLOY_PATH}"/**/*.enc ; do
1032
+ for enc in $(echo "${PATHS_TO_DECRYPT}" | tr '\n' ' ') ; do
1020
1033
openssl enc -v -d -aes-256-cbc -k "${PBDKF2_PASSPHRASE}" -pbkdf2 -iter 310000 -md sha256 -salt -in "${enc}" -out "${enc%.enc}"
1021
1034
done
1022
1035
@@ -1345,9 +1358,12 @@ jobs:
1345
1358
if : inputs.sign-image || needs.balena-lib.outputs.is_private == 'true'
1346
1359
env :
1347
1360
PBDKF2_PASSPHRASE : ${{ secrets.PBDKF2_PASSPHRASE }}
1361
+ PATHS_TO_DECRYPT : |
1362
+ ${{ env.DEPLOY_PATH }}/*.enc
1363
+ ${{ env.DEPLOY_PATH }}/**/*.enc
1348
1364
run : |
1349
1365
set -x
1350
- for enc in "${DEPLOY_PATH}"/**/*.enc ; do
1366
+ for enc in $(echo "${PATHS_TO_DECRYPT}" | tr '\n' ' ') ; do
1351
1367
openssl enc -v -d -aes-256-cbc -k "${PBDKF2_PASSPHRASE}" -pbkdf2 -iter 310000 -md sha256 -salt -in "${enc}" -out "${enc%.enc}"
1352
1368
done
1353
1369
@@ -1499,9 +1515,12 @@ jobs:
1499
1515
if : inputs.sign-image || needs.balena-lib.outputs.is_private == 'true'
1500
1516
env :
1501
1517
PBDKF2_PASSPHRASE : ${{ secrets.PBDKF2_PASSPHRASE }}
1518
+ PATHS_TO_DECRYPT : |
1519
+ ${{ env.DEPLOY_PATH }}/*.enc
1520
+ ${{ env.DEPLOY_PATH }}/**/*.enc
1502
1521
run : |
1503
1522
set -x
1504
- for enc in "${DEPLOY_PATH}"/**/*.enc ; do
1523
+ for enc in $(echo "${PATHS_TO_DECRYPT}" | tr '\n' ' ') ; do
1505
1524
openssl enc -v -d -aes-256-cbc -k "${PBDKF2_PASSPHRASE}" -pbkdf2 -iter 310000 -md sha256 -salt -in "${enc}" -out "${enc%.enc}"
1506
1525
done
1507
1526
@@ -2101,9 +2120,12 @@ jobs:
2101
2120
if : inputs.sign-image || needs.balena-lib.outputs.is_private == 'true'
2102
2121
env :
2103
2122
PBDKF2_PASSPHRASE : ${{ secrets.PBDKF2_PASSPHRASE }}
2123
+ PATHS_TO_DECRYPT : |
2124
+ ${{ env.DEPLOY_PATH }}/*.enc
2125
+ ${{ env.DEPLOY_PATH }}/**/*.enc
2104
2126
run : |
2105
2127
set -x
2106
- for enc in "${DEPLOY_PATH}"/**/*.enc ; do
2128
+ for enc in $(echo "${PATHS_TO_DECRYPT}" | tr '\n' ' ') ; do
2107
2129
openssl enc -v -d -aes-256-cbc -k "${PBDKF2_PASSPHRASE}" -pbkdf2 -iter 310000 -md sha256 -salt -in "${enc}" -out "${enc%.enc}"
2108
2130
done
2109
2131
@@ -2144,8 +2166,8 @@ jobs:
2144
2166
2145
2167
# The test suite expects the image to be tested to be called "balena.img.gz" - regardless of what it may have been called before
2146
2168
gzip -9 -c "${DEPLOY_PATH}/image/${BALENA_OS_IMAGE}" >"${LEVIATHAN_WORKSPACE}/balena.img.gz"
2147
- cp -v "${DEPLOY_PATH}/balena-image.docker" "${LEVIATHAN_WORKSPACE}/balena-image.docker"
2148
- cp -v "${DEPLOY_PATH}/kernel_modules_headers.tar.gz" "${LEVIATHAN_WORKSPACE}/kernel_modules_headers.tar.gz"
2169
+ mv -v "${DEPLOY_PATH}/balena-image.docker" "${LEVIATHAN_WORKSPACE}/balena-image.docker"
2170
+ mv -v "${DEPLOY_PATH}/kernel_modules_headers.tar.gz" "${LEVIATHAN_WORKSPACE}/kernel_modules_headers.tar.gz"
2149
2171
2150
2172
cp -v "${SUITES}/${TEST_SUITE}/config.js" "${LEVIATHAN_WORKSPACE}/config.js"
2151
2173
mkdir -p "${REPORTS}"
0 commit comments