-
Notifications
You must be signed in to change notification settings - Fork 56
Avoid potential leaks #1167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Avoid potential leaks #1167
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
09ce341
snc.sh: avoid leaking the temporary kubeadmin password
kpouget d4a7f45
tools.sh: don't leak the kubeadmin password
kpouget 516209d
systemd/crc-cluster-status.sh: don't leak the kubeadmin password
kpouget fdde370
systemd/crc-pullsecret.sh: don't leak the pull secrets
kpouget 9bbf5e0
systemd/ocp-userpasswords.sh: don't leak the kubeadmin password
kpouget File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,32 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -o pipefail | ||
| set -o errexit | ||
| set -o nounset | ||
| set -o errtrace | ||
| set -x | ||
|
|
||
| source /usr/local/bin/crc-systemd-common.sh | ||
| export KUBECONFIG="/opt/kubeconfig" | ||
|
|
||
| wait_for_resource secret | ||
|
|
||
| set +x # disable the logging to avoid leaking the pull secrets | ||
|
|
||
| # check if existing pull-secret is valid if not add the one from /opt/crc/pull-secret | ||
| existingPsB64=$(oc get secret pull-secret -n openshift-config -o jsonpath="{['data']['\.dockerconfigjson']}") | ||
| existingPs=$(echo "${existingPsB64}" | base64 -d) | ||
|
|
||
| echo "${existingPs}" | jq -e '.auths' | ||
|
|
||
| if [[ $? != 0 ]]; then | ||
| pullSecretB64=$(base64 -w0 < /opt/crc/pull-secret) | ||
| oc patch secret pull-secret -n openshift-config --type merge -p "{\"data\":{\".dockerconfigjson\":\"${pullSecretB64}\"}}" | ||
| # check if the .auths field is there | ||
| if echo "${existingPs}" | jq -e 'has("auths")' >/dev/null 2>&1; then | ||
| echo "Cluster already has the pull secrets, nothing to do" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Cluster doesn't have the pull secrets. Setting them from /opt/crc/pull-secret ..." | ||
| pullSecretB64=$(base64 -w0 < /opt/crc/pull-secret) | ||
| # Create the JSON patch in memory and pipe it to the oc command | ||
| printf '{"data":{".dockerconfigjson": "%s"}}' "${pullSecretB64}" | \ | ||
| oc patch secret pull-secret -n openshift-config --type merge --patch-file=/dev/stdin | ||
|
|
||
| exit 0 | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard against missing local pull secret before patching.
If
/opt/crc/pull-secretis absent/unreadable,base64/oc patchwill fail with opaque errors. Add an explicit check.📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 I'll add that to #1168
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kpouget Thank you for acknowledging the suggestion! Sounds good—I'll keep an eye out for the fix in #1168. 🙂