-
Notifications
You must be signed in to change notification settings - Fork 598
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
snap, snap/pack: disallow pack and install of snapd, base and os with specific configure hooks #13117
snap, snap/pack: disallow pack and install of snapd, base and os with specific configure hooks #13117
Conversation
203749a
to
b490ccc
Compare
b490ccc
to
c10b5b3
Compare
Thu Feb 20 07:47:21 UTC 2025 Failures:Executing:
|
c10b5b3
to
b6a8698
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #13117 +/- ##
=========================================
Coverage ? 77.86%
=========================================
Files ? 1167
Lines ? 156856
Branches ? 0
=========================================
Hits ? 122130
Misses ? 27139
Partials ? 7587
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
7990b70
to
6e7c4f6
Compare
4d8c591
to
4d38e1d
Compare
4d38e1d
to
7a4f5ec
Compare
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.
lgtm
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.
LGTM
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.
some comments
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.
thanks for the changes, something seems a bit off with the error message building logic though, otoh made a different suggestion
snap/validate.go
Outdated
} | ||
|
||
if info.SnapType == TypeSnapd || info.SnapType == TypeBase || (info.SnapType == TypeOS && info.InstanceName() != "core") { | ||
if info.SnapType == TypeSnapd || info.SnapType == TypeBase || info.SnapType == TypeOS { | ||
var hookNames strings.Builder | ||
if hasDefaultConfigureHook { | ||
hookNames.WriteString(`"default-configure"`) | ||
if hasConfigureHook { |
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.
this now needs to become the same check as below, no? but then I'm unsure using a strings.Builder is the best approach, wouldn't a []string and using Join with " or " be simpler?
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.
thanks, corrected and simplified this and corresponding test
…nfigure and configure
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.
thank you, @ernestl this has changed a bit since. maybe you can get one of the original reviewers to do a quick 2nd pass?
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.
Looks good, just some comments on testing
snap/pack/pack_test.go
Outdated
configureHooks := []string{"configure"} | ||
c.Assert(os.Mkdir(filepath.Join(sourceDir, "meta", "hooks"), 0755), IsNil) | ||
for _, hook := range configureHooks { | ||
c.Assert(os.WriteFile(filepath.Join(sourceDir, "meta", "hooks", hook), []byte("#!/bin/sh"), 0755), IsNil) | ||
} |
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.
configureHooks := []string{"configure"} | |
c.Assert(os.Mkdir(filepath.Join(sourceDir, "meta", "hooks"), 0755), IsNil) | |
for _, hook := range configureHooks { | |
c.Assert(os.WriteFile(filepath.Join(sourceDir, "meta", "hooks", hook), []byte("#!/bin/sh"), 0755), IsNil) | |
} | |
c.Assert(os.Mkdir(filepath.Join(sourceDir, "meta", "hooks"), 0755), IsNil) | |
c.Assert(os.WriteFile(filepath.Join(sourceDir, "meta", "hooks", "configure"), []byte("#!/bin/sh"), 0755), IsNil) |
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.
thanks, improved
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.
looks good, thanks for the clarification
It is currently possible to pack and install
snapd
,base
andcore
snaps withdefault-configure
andconfigure
hooks, but those hooks are ignored during installation and option setting. My proposal is to extend the snap validation check (covers packing and installation) to prevent these unintended snap/hook combinations and possible silent failure.Spec:
Implements part of draft spec
Prohibit user-defined configuration hooks for specific essential snaps
Approach:
Extend
snap/validate.go
hook check that was introduced in #13097 as follows:default-configure
hook forsnapd
,base
oros
configure
hook forsnapd
,base
configure
hook foros
to prevent new errors forcore
orubuntu-core
with existingconfigure
hookKey covered paths: Snap Pack, Firstboot, Store Install, Sideload Install
JIRA: https://warthogs.atlassian.net/browse/SNAPDENG-7297
This PR builds on #13097