Skip to content

Commit e56bf40

Browse files
committed
feat: add option to disable blob verification
Updated PR helm#131 Signed-off-by: Marco Lecheler <marco.lecheler@mercedes-benz.com>
1 parent 2e29406 commit e56bf40

3 files changed

Lines changed: 70 additions & 12 deletions

File tree

.github/workflows/test-action.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,36 @@ jobs:
111111
- name: Run chart-testing (install)
112112
if: steps.list-changed.outputs.changed == 'true'
113113
run: ct install --chart-dirs=testdata --target-branch ${{ github.event.repository.default_branch }}
114+
115+
test_ct_action_noverify:
116+
runs-on: ubuntu-latest
117+
118+
name: Install chart-testing without verifiing blob and test presence in path
119+
steps:
120+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
121+
with:
122+
fetch-depth: 0
123+
- name: Install chart-testing
124+
uses: ./
125+
with:
126+
verify_blob: 'false'
127+
- name: Check install!
128+
run: |
129+
ct version
130+
CT_VERSION_OUTPUT=$(ct version 2>&1 /dev/null)
131+
ACTUAL_VERSION=$(echo "$CT_VERSION_OUTPUT" | grep Version | rev | cut -d ' ' -f1 | rev)
132+
if [[ $ACTUAL_VERSION != 'v3.14.0' ]]; then
133+
echo 'should be v3.14.0'
134+
exit 1
135+
else
136+
exit 0
137+
fi
138+
shell: bash
139+
- name: Check root directory
140+
run: |
141+
if [[ $(git diff --stat) != '' ]]; then
142+
echo 'should be clean'
143+
exit 1
144+
else
145+
exit 0
146+
fi

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ branding:
55
color: blue
66
icon: anchor
77
inputs:
8+
verify_blob:
9+
description: "determines whether the download blob should be verified (default: true)"
10+
required: false
11+
default: 'true'
812
version:
913
description: "The chart-testing version to install"
1014
required: false
@@ -25,12 +29,14 @@ runs:
2529
using: composite
2630
steps:
2731
- uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
32+
if: ${{ inputs.verify_blob != 'false' }}
2833
- uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
2934
with:
3035
version: ${{ inputs.uv_version }}
3136
- run: |
3237
cd $GITHUB_ACTION_PATH \
3338
&& ./ct.sh \
39+
--verify-blob ${{ inputs.verify_blob }} \
3440
--version ${{ inputs.version }} \
3541
--yamllint-version ${{ inputs.yamllint_version }} \
3642
--yamale-version ${{ inputs.yamale_version }}

ct.sh

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -o nounset
55
set -o pipefail
66

77
DEFAULT_CHART_TESTING_VERSION=3.14.0
8+
DEFAULT_VERIFY_BLOB=true
89
DEFAULT_YAMLLINT_VERSION=1.33.0
910
DEFAULT_YAMALE_VERSION=6.0.0
1011

@@ -19,6 +20,7 @@ EOF
1920

2021
main() {
2122
local version="${DEFAULT_CHART_TESTING_VERSION}"
23+
local verify_blob="${DEFAULT_VERIFY_BLOB}"
2224
local yamllint_version="${DEFAULT_YAMLLINT_VERSION}"
2325
local yamale_version="${DEFAULT_YAMALE_VERSION}"
2426

@@ -34,6 +36,16 @@ parse_command_line() {
3436
show_help
3537
exit
3638
;;
39+
--verify-blob)
40+
if [[ -n "${2:-}" ]]; then
41+
verify_blob="${2#v}"
42+
shift
43+
else
44+
echo "ERROR: '--verify-blob' cannot be empty." >&2
45+
show_help
46+
exit 1
47+
fi
48+
;;
3749
-v|--version)
3850
if [[ -n "${2:-}" ]]; then
3951
version="${2#v}"
@@ -88,21 +100,28 @@ install_chart_testing() {
88100
local cache_dir="${RUNNER_TOOL_CACHE}/ct/${version}/${arch}"
89101
local venv_dir="${cache_dir}/venv"
90102

103+
curl --retry 5 --retry-delay 1 -sSLo ct.tar.gz \
104+
"https://github.com/helm/chart-testing/releases/download/v${version}/chart-testing_${version#v}_linux_${arch}.tar.gz"
105+
echo "Installing chart-testing v${version}..."
106+
91107
if [[ ! -d "${cache_dir}" ]]; then
92108
mkdir -p "${cache_dir}"
93109

94-
echo "Installing chart-testing v${version}..."
95-
CT_CERT=https://github.com/helm/chart-testing/releases/download/v${version}/chart-testing_${version#v}_linux_${arch}.tar.gz.pem
96-
CT_SIG=https://github.com/helm/chart-testing/releases/download/v${version}/chart-testing_${version#v}_linux_${arch}.tar.gz.sig
97-
98-
curl --retry 5 --retry-delay 1 -sSLo ct.tar.gz "https://github.com/helm/chart-testing/releases/download/v${version}/chart-testing_${version#v}_linux_${arch}.tar.gz"
99-
cosign verify-blob --certificate "${CT_CERT}" --signature "${CT_SIG}" \
100-
--certificate-identity "https://github.com/helm/chart-testing/.github/workflows/release.yaml@refs/heads/main" \
101-
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" ct.tar.gz
102-
retVal=$?
103-
if [[ "${retVal}" -ne 0 ]]; then
104-
log_error "Unable to validate chart-testing version: v${version}"
105-
exit 1
110+
if [[ "${verify_blob}" != "false" ]]; then
111+
echo "Verifing blob..."
112+
CT_CERT=https://github.com/helm/chart-testing/releases/download/v${version}/chart-testing_${version#v}_linux_${arch}.tar.gz.pem
113+
CT_SIG=https://github.com/helm/chart-testing/releases/download/v${version}/chart-testing_${version#v}_linux_${arch}.tar.gz.sig
114+
115+
cosign verify-blob --certificate "${CT_CERT}" --signature "${CT_SIG}" \
116+
--certificate-identity "https://github.com/helm/chart-testing/.github/workflows/release.yaml@refs/heads/main" \
117+
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" ct.tar.gz
118+
retVal=$?
119+
if [[ "${retVal}" -ne 0 ]]; then
120+
log_error "Unable to validate chart-testing version: v${version}"
121+
exit 1
122+
fi
123+
else
124+
echo "Skipping verifing blob..."
106125
fi
107126

108127
tar -xzf ct.tar.gz -C "${cache_dir}"

0 commit comments

Comments
 (0)