Skip to content

Commit 96a00e5

Browse files
committed
Boilerplate: Update to 5fea264b458ec33913afb04eda6ff87d8013d9f4
Conventions: - openshift/golang-osd-operator: Update --- openshift/boilerplate@0ba6566...5fea264 commit: e6753c2a4252695328187dad83370e63f308e355 author: Christopher Collins Updates the version of the openshift-operator-registry image Updates the version of the openshift-operator-registry image to 4.8.0, to address several high vulnerabilities found in the 4.7.0 image. REF: [OSD-6831](https://issues.redhat.com/browse/OSD-6831) Signed-off-by: Christopher Collins <collins.christopher@gmail.com> commit: c35da9dd532d5ed389e4e93f83c75fe9e51e98c9 author: Eric Fried Fix generated-files-checker for go 1.16 go 1.16 is stricter about go.sum being up to date for things like `go -list`. Fix up the test (case & project) accordingly. Also add test loops for missing supported asdk versions. Not sure when we missed those. Also fix the backing image -- it was hacking the go lib/cache permissions too early. Also make it possible to override the backing image used by `container-make`, to ease debugging when writing commits like this. commit: 0acfc9d8d31942977df26f49ec043038d2fd3320 author: Rob Rati Update to use golang 1.16 commit: c49cf6f755ffab5c6e2ce6e4118b743e83093248 author: Eric Fried Fix unbound local variable error ...noted in https://ci.int.devshift.net/job/app-sre-deployment-validation-operator-gh-build-master/60/console commit: 3bcb750bd6dc9120f5458aa44d82fff6973d2171 author: Eric Fried Improve `subscriber report release` This commit improves the `subscriber report release` tool in the following ways: - It now requires a list of subscribers, or `ALL`, with the same semantics as `subscriber propose update`. - It now produces a diff with which you can `patch -R` what's in the release repository to make it conform. commit: 9062716c4df7b01b72ba4308e106b4c932ab5649 author: Christopher Collins Adds .gitattributes to unacceptable_deltas "ignores" list With a recent update to boilerplate, a .gitattributes file is created during the bootstrap process. This is causing failures in the "framework/04-update-from-master-and-revert" test, which currently doesn't expect the .gitattributes file to exist, uncommitted, after the test bootstrap. This adds the .gitattributes file to the "ignores" list in the unacceptable_deltas function of boilerplate/update. Also runs `./boilerplate/_lib/boilerplate-commit` to "clean" before the next test run. Signed-off-by: Christopher Collins <collins.christopher@gmail.com> commit: 69519b47fcbd219aa4d30aeb28377c2113ea8272 author: Eric Fried Secure freeze-check, enable hiding boilerplate deltas - Document the "trust and ignore" philosophy that subscribers should adopt when reviewing PRs that include boilerplate updates. - Secure `freeze-check` so you actually _can_ trust such changes. - Lay down .gitattributes content such that, if a subscriber decides to suppress boilerplate deltas by default, certain files will still always be shown: - Because an attacker could attempt to subvert `freeze-check` by modifying that script or its dependencies, we explicitly exclude those from the hiding-by-default. - Because an attacker could try to subvert the hiding by appending entries to .gitattributes, we exclude THAT file from the hiding-by-default as well. Security is hard.
1 parent 247d013 commit 96a00e5

File tree

14 files changed

+156
-53
lines changed

14 files changed

+156
-53
lines changed

.ci-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: boilerplate
33
namespace: openshift
4-
tag: image-v0.5.2
4+
tag: image-v1.0.0

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### BEGIN BOILERPLATE GENERATED -- DO NOT EDIT ###
2+
### This block must be the last thing in your ###
3+
### .gitattributes file; otherwise the 'validate' ###
4+
### CI check will fail. ###
5+
# Used to ensure nobody mucked with boilerplate files.
6+
boilerplate/_lib/freeze-check linguist-generated=false
7+
# Show the boilerplate commit hash update. It's only one line anyway.
8+
boilerplate/_data/last-boilerplate-commit linguist-generated=false
9+
# Used by freeze-check. Good place for attackers to inject badness.
10+
boilerplate/update linguist-generated=false
11+
# Make sure attackers can't hide changes to this configuration
12+
.gitattributes linguist-generated=false
13+
### END BOILERPLATE GENERATED ###
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
image-v0.5.2
1+
image-v1.0.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0ba6566d544d0df9993a92b2286c131eb61f3e88
1+
5fea264b458ec33913afb04eda6ff87d8013d9f4

boilerplate/_lib/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,4 @@ if [[ -z "$LATEST_IMAGE_TAG" ]]; then
197197
fi
198198
fi
199199
# The public image location
200-
IMAGE_PULL_PATH=quay.io/app-sre/$IMAGE_NAME:$LATEST_IMAGE_TAG
200+
IMAGE_PULL_PATH=${IMAGE_PULL_PATH:-quay.io/app-sre/$IMAGE_NAME:$LATEST_IMAGE_TAG}

boilerplate/_lib/freeze-check

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
#!/usr/bin/env bash
22

3+
# NOTE: For security reasons, everything imported or invoked (even
4+
# indirectly) by this script should be audited for vulnerabilities and
5+
# explicitly excluded from `linguist-generated` in the consuming
6+
# repository's .gitattributes. In other words, we want PRs to show
7+
# deltas to this script and all its dependencies by default so that
8+
# attempts to inject or circumvent code are visible.
9+
310
set -e
411

512
REPO_ROOT=$(git rev-parse --show-toplevel)
6-
source $REPO_ROOT/boilerplate/_lib/common.sh
13+
# Hardcoded rather than sourced to reduce attack surface.
14+
BOILERPLATE_GIT_REPO=https://github.com/openshift/boilerplate.git
715

816
# Validate that no subscribed boilerplate artifacts have been changed.
917
# PR checks may wish to gate on this.
@@ -28,7 +36,8 @@ source $REPO_ROOT/boilerplate/_lib/common.sh
2836
# seriously ticked off if something went wrong and lost my in-flight
2937
# changes.
3038
if ! [ -z "$(git status --porcelain)" ]; then
31-
err "Can't validate boilerplate in a dirty repository. Please commit your changes and try again."
39+
echo "Can't validate boilerplate in a dirty repository. Please commit your changes and try again." >&2
40+
exit 1
3241
fi
3342

3443
# We glean the last boilerplate commit from the
@@ -52,19 +61,19 @@ git remote add origin $BOILERPLATE_GIT_REPO
5261
git fetch origin $(cat $LBCF) --tags
5362
git reset --hard FETCH_HEAD
5463

55-
# Now invoke the update script, bypassing the exec step because we
56-
# already downloaded what we want
64+
# Now invoke the update script, overriding the source repository we've
65+
# just downloaded at the appropriate commit.
66+
# We invoke the script explicitly rather than via the make target to
67+
# close a security hole whereby the latter is overridden.
5768
echo "Running update"
5869
cd $REPO_ROOT
59-
boilerplate/update $TMPD
70+
BOILERPLATE_GIT_CLONE="git clone $TMPD" boilerplate/update
6071

6172
# Okay, if anything has changed, that's bad.
6273
if [[ $(git status --porcelain | wc -l) -ne 0 ]]; then
63-
err "Your boilerplate is dirty!
64-
Run 'git diff' to see what we think you shouldn't have changed.
65-
You can commit those changes to pass this check.
66-
Or you can run 'git reset --hard HEAD' to get back to where you were before."
67-
74+
echo "Your boilerplate is dirty!" >&2
75+
git status --porcelain
76+
exit 1
6877
fi
6978

7079
echo "Your boilerplate is clean!"

boilerplate/_lib/release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Failed to determine consumer name"
2424
#
2525
# E.g. "master"
2626
# This will produce something like refs/remotes/origin/master
27-
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/upstream/HEAD || git symbolic-ref refs/remotes/origin/HEAD || echo defaulting/to/master)
27+
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/upstream/HEAD 2>/dev/null || git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null || echo defaulting/to/master)
2828
# Strip off refs/remotes/{upstream|origin}/
2929
DEFAULT_BRANCH=${DEFAULT_BRANCH##*/}
3030
[[ -z "$DEFAULT_BRANCH" ]] && err "

boilerplate/_lib/subscriber-propose-update

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,18 @@ source $REPO_ROOT/boilerplate/_lib/subscriber.sh
3333
# Arguments are required
3434
[[ $# -eq 0 ]] && usage
3535

36-
declare -A to_update
37-
38-
ALL=0
39-
if [[ $# -eq 1 ]] && [[ "$1" == ALL ]]; then
40-
ALL=1
41-
shift
42-
fi
43-
for subscriber in $(subscriber_list onboarded); do
44-
to_update[$subscriber]=$ALL
45-
done
46-
47-
# Parse specified subscribers
48-
for a in "$@"; do
49-
[[ $a == ALL ]] && err "Can't specify ALL with explicit subscribers"
50-
51-
[[ -n "${to_update[$a]}" ]] || err "Not an onboarded subscriber: '$a'"
52-
if [[ "${to_update[$a]}" -eq 1 ]]; then
53-
echo "Ignoring duplicate: '$a'"
54-
continue
55-
fi
56-
to_update[$a]=1
57-
done
58-
5936
TMPD=$(mktemp -d)
6037
trap "rm -fr $TMPD" EXIT
6138

6239
propose_update() {
6340
local subscriber=$1
6441
local proj=${subscriber#*/}
6542

43+
if [[ -z "$DRY_RUN" ]]; then
44+
echo "DRY RUN: Would propose update for $subscriber"
45+
return 0
46+
fi
47+
6648
(
6749
# Clone my fork of the subscriber repo
6850
cd $TMPD
@@ -93,8 +75,7 @@ propose_update() {
9375

9476
bp_master=$(git rev-parse master)
9577

96-
for subscriber in "${!to_update[@]}"; do
97-
[[ "${to_update[$subscriber]}" -eq 1 ]] || continue
78+
for subscriber in $(subscriber_args "$@"); do
9879

9980
# Does this one need an update?
10081
lbc=$(last_bp_commit $subscriber)

boilerplate/_lib/subscriber-report-release

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,26 @@ source $REPO_ROOT/boilerplate/_lib/release.sh
66

77
usage() {
88
cat <<EOF
9-
$CMD
9+
$CMD SUBSCRIBER ...
1010
1111
Analyzes the openshift/release footprint of onboarded boilerplate
1212
subscribers. For each subscriber, prints the delta, if any, between the
1313
existing and expected prow configuration.
14+
15+
Arguments:
16+
SUBSCRIBER One or more subscriber repositories of the form
17+
"org/name" (e.g. "openshift/deadmanssnitch-operator");
18+
or the special keyword "ALL" to report on all onboarded
19+
subscribers.
1420
EOF
1521
exit -1
1622
}
1723

1824
source $REPO_ROOT/boilerplate/_lib/subscriber.sh
1925

26+
# Arguments are required
27+
[[ $# -eq 0 ]] && usage
28+
2029
## prow_config ORG PROJ
2130
#
2231
# Downloads the ci-operator configuration file from openshift/release for the
@@ -33,20 +42,21 @@ prow_config() {
3342
f=$org-$proj-$branch.yaml
3443
local c="$(curl -s $p/$f)"
3544
if [[ "$c" != "404: Not Found" ]]; then
36-
# Remove the zz_generated_metadata section
37-
echo "$c" | yq d - zz_generated_metadata > $TMPD/$f
45+
echo "$c" > $TMPD/$f
3846
echo $TMPD/$f
3947
return
4048
fi
4149
done
4250
}
4351

44-
## expected_prow_config PROJ
52+
## expected_prow_config ORG PROJ BRANCH
4553
#
46-
# Prints to stdout (most of) the expected prow configuration for the specified
47-
# PROJ. The `zz_generated_metadata` section is omitted.
54+
# Prints to stdout the expected prow configuration for the specified
55+
# ORG/PROJ.
4856
expected_prow_config() {
49-
local consumer_name=$1
57+
local org=$1
58+
local consumer_name=$2
59+
local branch=$3
5060
# TODO: DRY this with what's in prow-config.
5161
# Do it by making it a template in the convention dir.
5262
cat <<EOF
@@ -94,21 +104,28 @@ tests:
94104
commands: make validate
95105
container:
96106
from: src
107+
zz_generated_metadata:
108+
branch: ${branch}
109+
org: ${org}
110+
repo: ${consumer_name}
97111
EOF
98112
}
99113

100114
TMPD=$(mktemp -d)
101115
trap "rm -fr $TMPD" EXIT
102116

103-
for subscriber in $(subscriber_list onboarded); do
117+
for subscriber in $(subscriber_args "$@"); do
104118
banner $subscriber
105119
org=${subscriber%/*}
106120
proj=${subscriber#*/}
107121
pc=$(prow_config $org $proj)
122+
# Filename is of the form ...-$branch.yaml
123+
branch=${pc##*-}
124+
branch=${branch%.yaml}
108125
if [[ -z "$pc" ]]; then
109126
echo "=== No configuration ==="
110127
else
111-
d="$(expected_prow_config $proj | diff -w - $pc)"
128+
d="$(expected_prow_config $org $proj $branch | diff - $pc)"
112129
if [[ -z "$d" ]]; then
113130
echo "=== A-OK ==="
114131
else

boilerplate/_lib/subscriber.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,47 @@ commits_behind_bp_master() {
111111
git rev-list --count --merges $range
112112
}
113113

114+
## subscriber_args SUBSCRIBER ...
115+
#
116+
# Processes arguments as a list of onboarded subscribers of the form
117+
# "org/name" (e.g. "openshift/deadmanssnitch-operator"); or the special
118+
# keyword "ALL".
119+
#
120+
# Outputs to stderr a space-separated list of subscribers. If "ALL" was
121+
# specified, these are all onboarded subscribers.
122+
#
123+
# Errors if:
124+
# - "ALL" is specified along with one or more explicit subscriber names.
125+
# - Any specified subscriber is nonexistent or not listed as onboarded
126+
# in the config.
127+
subscriber_args() {
128+
local -A to_process
129+
local ALL=0
130+
local subscriber
131+
local a
132+
133+
if [[ $# -eq 1 ]] && [[ "$1" == ALL ]]; then
134+
ALL=1
135+
shift
136+
fi
137+
for subscriber in $(subscriber_list onboarded); do
138+
to_process[$subscriber]=$ALL
139+
done
140+
141+
# Parse specified subscribers
142+
for a in "$@"; do
143+
[[ $a == ALL ]] && err "Can't specify ALL with explicit subscribers"
144+
145+
[[ -n "${to_process[$a]}" ]] || err "Not an onboarded subscriber: '$a'"
146+
if [[ "${to_process[$a]}" -eq 1 ]]; then
147+
echo "Ignoring duplicate: '$a'" >&2
148+
continue
149+
fi
150+
to_process[$a]=1
151+
done
152+
153+
for subscriber in "${!to_process[@]}"; do
154+
[[ "${to_process[$subscriber]}" -eq 1 ]] || continue
155+
echo -n "${subscriber} "
156+
done
157+
}

0 commit comments

Comments
 (0)