Skip to content

Fix xtrace helper logic inversion and set -e abort risk in util-common.sh#4692

Closed
Copilot wants to merge 6 commits intoehvs/ARO-24815from
copilot/sub-pr-4675
Closed

Fix xtrace helper logic inversion and set -e abort risk in util-common.sh#4692
Copilot wants to merge 6 commits intoehvs/ARO-24815from
copilot/sub-pr-4675

Conversation

Copy link

Copilot AI commented Mar 18, 2026

Two bugs in the xtrace save/restore helpers introduced in the ACR token protection work cause incorrect xtrace state and potential script abort under errexit.

Bugs fixed

  • Logic inversion in xtrace_set(): was checking XTRACE_IS_SET == XTRACE_UNSET — the opposite of the intended restore-if-was-on semantics. Result: xtrace was re-enabled when it was originally off, and not re-enabled when it was originally on.

  • set -e abort risk: (( cond )) && cmd returns non-zero when the condition is false. Since bootstrap scripts run with errexit, calling either helper when the condition doesn't hold would terminate the script.

Change

# Before
xtrace_unset() {
    (( XTRACE_IS_SET == XTRACE_SET )) && set +x
}
xtrace_set() {
    (( XTRACE_IS_SET == XTRACE_UNSET )) && set -x  # wrong condition, wrong behavior
}

# After
xtrace_unset() {
    if (( XTRACE_IS_SET == XTRACE_SET )); then
        set +x
    fi
}
xtrace_set() {
    if (( XTRACE_IS_SET == XTRACE_SET )); then  # restore only if was set
        set -x
    fi
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

s-fairchild and others added 5 commits March 17, 2026 14:32
To be extra safe and ensure no certificate details are logged via shell tracing.
Add shellcheck comments for warnings that can be safely ignored.
Improve function readability by formatting them all in the same style.
Several warnings were unaddressed. Some of them were disabled as they can be safely ignored.
Others were refactored as the warnings were legitimate.
@openshift-ci
Copy link

openshift-ci bot commented Mar 18, 2026

Hi @copilot. Thanks for your PR.

I'm waiting for a Azure member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@github-actions github-actions bot added the needs-rebase branch needs a rebase label Mar 18, 2026
@github-actions
Copy link

Please rebase pull request.

- xtrace_set() was checking XTRACE_IS_SET == XTRACE_UNSET but should
  check XTRACE_IS_SET == XTRACE_SET to restore xtrace when it was on
- Both xtrace_unset() and xtrace_set() used (( cond )) && cmd which
  returns non-zero when condition is false, potentially aborting scripts
  under set -e; changed to if-statements which always return 0

Co-authored-by: hlipsig <8000786+hlipsig@users.noreply.github.com>
Copilot AI changed the title [WIP] [ARO-24815] Prevent ACR refresh token exposure in audit logs Fix xtrace helper logic inversion and set -e abort risk in util-common.sh Mar 18, 2026
@hlipsig hlipsig closed this Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants