Skip to content
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

Guard against os-release panic #1488

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

jonjohnsonjr
Copy link
Contributor

No description provided.

@jonjohnsonjr jonjohnsonjr marked this pull request as ready for review January 21, 2025 23:14
for _, line := range strings.Split(releaseStr, "\n") {
if line != "" {
if len(strings.Split(line, "=")) < 2 {
return nil, fmt.Errorf("invalid os-release line: %q", line)
Copy link
Contributor

Choose a reason for hiding this comment

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

The format of this file is described at https://www.freedesktop.org/software/systemd/man/latest/os-release.html

Lines beginning with "#" are treated as comments. Blank lines are permitted and ignored.

does above handle this requirement?

Copy link
Contributor

Choose a reason for hiding this comment

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

Depending on needs it can be a broken symlink to unmounted /usr partition too.

The file /etc/os-release takes precedence over /usr/lib/os-release. Applications should check for the former, and exclusively use its data if it exists, and only fall back to /usr/lib/os-release if that is missing.

Copy link
Member

Choose a reason for hiding this comment

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

No - this seems like a likely culprit though. It might be worth making our own parser?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's interesting. The osr.Parse code doesn't seem to handle comments, that's probably our root cause.

continue
}

if strings.HasPrefix(line, "#") {
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a comment into the good test just to be safe.

@jonjohnsonjr jonjohnsonjr merged commit 2221938 into chainguard-dev:main Jan 22, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants