Skip to content

fix: guard against short paths in changelog GitHub URL redirect - #9688

Merged
olblak merged 2 commits into
updatecli:mainfrom
AruneshDwivedi:fix/dockerimage-changelog-panic
Jul 22, 2026
Merged

olblak merged 2 commits into
updatecli:mainfrom
AruneshDwivedi:fix/dockerimage-changelog-panic

Conversation

@AruneshDwivedi

Copy link
Copy Markdown
Contributor

redirectToGitHubRawContent splits the changelog URL path on "/" and reads index 3 without checking the length, so a github.com changelog URL with fewer than four path segments panics with index out of range. Since the URL comes from the org.opencontainers.image.changelog image annotation, a short value like https://github.com/CHANGELOG.md crashes the run.

Split once, check the slice has more than three elements before touching index 3, and leave short paths unchanged.

Signed-off-by: Arunesh Dwivedi <arunesh.dwivedi@example.com>
@olblak

olblak commented Jul 20, 2026

Copy link
Copy Markdown
Member

Hi @AruneshDwivedi,
I am not familiar with those short changelog url.
Do you have an example of a failing pipeline due to this?

@AruneshDwivedi

AruneshDwivedi commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@olblak good question it's a real panic, not a theoretical one.
An image annotated with org.opencontainers.image.changelog: https://github.com/CHANGELOG.md (short URL, changelog at repo root) hits redirectToGitHubRawContent, which does strings.Split(u.Path, "/")[3]. That path only has two segments, so it panics with index out of range [3] with length 2 and kills the whole run. Any pipeline doing dockerimage changelog autodiscovery over such an image crashes. put up a fix in #9689 with a test that repros it. The example in my earlier message used a 4-segment URL by mistake that one doesn't panic; the 2-segment github.com/CHANGELOG.md is the actual trigger.

@olblak

olblak commented Jul 21, 2026

Copy link
Copy Markdown
Member

Thanks for the explanation, why did you created two differernt pullrequest with the same content
#9688 vs #9689

@olblak olblak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pullrequest

@olblak
olblak enabled auto-merge (squash) July 22, 2026 06:27
@olblak
olblak merged commit f66ba0d into updatecli:main Jul 22, 2026
8 checks passed
@olblak olblak added bug Something isn't working resource-dockerfile Resource of kind Dockerfile labels Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working resource-dockerfile Resource of kind Dockerfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants