Skip to content

Commit 134d282

Browse files
Merge pull request #103 from steveb/pipeline-secure
Harden build pipeline: pin build-time dependencies and secure credential handling
2 parents 5ed44ad + fda5078 commit 134d282

3 files changed

Lines changed: 33 additions & 8 deletions

File tree

bootc/install-repo-setup.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
set -eux
44

5+
# Pin repo-setup to a specific commit on the stable branch
6+
# To update: change REPO_SETUP_COMMIT, download the new archive, and update REPO_SETUP_SHA256
7+
REPO_SETUP_COMMIT=85321f7e0af502d7f06f845886058daf09da34f6
8+
REPO_SETUP_SHA256=1050e4ed0472098165c4bde84a9991a6a13171426d16862f6651e28635d1727f
9+
510
pushd output
6-
curl -sL https://github.com/openstack-k8s-operators/repo-setup/archive/refs/heads/main.tar.gz | tar xvz
7-
pushd repo-setup-main
11+
curl -sL -o repo-setup.tar.gz \
12+
"https://github.com/openstack-k8s-operators/repo-setup/archive/${REPO_SETUP_COMMIT}.tar.gz"
13+
echo "${REPO_SETUP_SHA256} repo-setup.tar.gz" | sha256sum -c -
14+
tar xzf repo-setup.tar.gz
15+
pushd "repo-setup-${REPO_SETUP_COMMIT}"
816
python3 -m venv ./venv
917
source ./venv/bin/activate
1018
PBR_VERSION=0.0.0 python3 -m pip install ./

bootc/rhsm.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
set -eux
3+
set -eu
44

55
# Edit RHSM_ values for the subscription configuration
66
RHSM_USER=unset
@@ -13,8 +13,19 @@ RHSM_REPOS=${RHSM_REPOS:-"--enable=rhoso-18.0-for-rhel-${RHEL_MAJOR}-x86_64-rpms
1313
RHSM_POOL=""
1414

1515
rm -f /etc/yum.repos.d/*.repo
16-
subscription-manager register --username=$RHSM_USER --password=$RHSM_PASSWORD
16+
# Disable subscription-manager container detection so that registration
17+
# works during container builds. subscription-manager checks for
18+
# /etc/rhsm-host (a symlink to ../run/secrets/rhsm) to detect
19+
# container mode.
20+
if [ -L /etc/rhsm-host ]; then
21+
rm -f /etc/rhsm-host
22+
fi
23+
24+
# Suppress xtrace to avoid leaking credentials to the build log
25+
set +x
26+
subscription-manager register --username="$RHSM_USER" --password="$RHSM_PASSWORD"
27+
set -x
1728
if [ -n "${RHSM_POOL}" ]; then
18-
subscription-manager attach --pool=$RHSM_POOL
29+
subscription-manager attach --pool="$RHSM_POOL"
1930
fi
2031
subscription-manager repos $RHSM_REPOS

dib/repo-setup/pre-install.d/00-03-repo-setup

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ if [ -n "${DIB_YUM_REPO_CONF:-}" ] ; then
99
exit 0
1010
fi
1111

12-
# Install latest version of repo-setup without installing pip or git
12+
# Install repo-setup pinned to a specific commit on the stable branch
13+
# To update: change REPO_SETUP_COMMIT, download the new archive, and update REPO_SETUP_SHA256
14+
REPO_SETUP_COMMIT=85321f7e0af502d7f06f845886058daf09da34f6
15+
REPO_SETUP_SHA256=1050e4ed0472098165c4bde84a9991a6a13171426d16862f6651e28635d1727f
1316
cd /tmp
14-
curl -sL https://github.com/openstack-k8s-operators/repo-setup/archive/refs/heads/main.tar.gz | tar xvz
15-
cd repo-setup-main
17+
curl -sL -o repo-setup.tar.gz \
18+
"https://github.com/openstack-k8s-operators/repo-setup/archive/${REPO_SETUP_COMMIT}.tar.gz"
19+
echo "${REPO_SETUP_SHA256} repo-setup.tar.gz" | sha256sum -c -
20+
tar xzf repo-setup.tar.gz
21+
cd "repo-setup-${REPO_SETUP_COMMIT}"
1622
python3 -m venv ./venv
1723
source ./venv/bin/activate
1824
PBR_VERSION=0.0.0 python3 -m pip install ./

0 commit comments

Comments
 (0)