Consolidate trust logic into IsTrustedBuilder#2573
Conversation
…ilders Signed-off-by: Rune Soerensen <rsoerensen@salesforce.com>
Signed-off-by: Rune Soerensen <rsoerensen@salesforce.com>
ad1df62 to
85e15fc
Compare
|
@jjbustamante thanks for reviewing/merging #2571! This branch was based on that work, so I've rebased and marked the PR ready for review :) |
| h.AssertTrue(t, isTrusted) | ||
|
|
||
| // Known builder without tag should match any tag | ||
| isTrusted, err = bldr.IsTrustedBuilder(config.Config{}, "paketobuildpacks/builder-jammy-base:latest") |
There was a problem hiding this comment.
Should this test case reference: paketobuildpacks/builder-jammy-base?
There was a problem hiding this comment.
The :latest here is intentional - this case exercises the "known entry has no tag, match any tag in the same repository" branch of the new name.ParseReference logic, which is what #2572 is about and is also the example shown in the Before/After in the PR description.
The heroku/builder:24 case above covers the exact-tag branch. Switching to a bare paketobuildpacks/builder-jammy-base would collapse this into a bare-vs-bare repository match and stop exercising the "any tag" path.
Happy to expand the inline comment if it'd read more clearly, or add a second assertion with a different tag (e.g. :anything) to make the "any tag" intent more obvious - let me know what you'd prefer (or if I'm missing something obvious :)).
|
I accidentally opened duplicate PR #2619 after auditing #2572, then noticed this PR already covers the core fix. I closed #2619 in favor of this one. While doing that audit, I found one extra test angle that may be useful here: caller coverage in addition to
The reason I think caller coverage is useful is that |
Make IsKnownTrustedBuilder use the same name.ParseReference matching as IsTrustedBuilder so tagless known entries match any tag in the same repository. This fixes the SDK default at pkg/client/build.go and the "can't untrust a known builder" guard in config trusted-builders remove, both of which still relied on exact-string matching. Signed-off-by: Rune Soerensen <rsoerensen@salesforce.com>
Add regression coverage at the command layer to guard against future refactors that bypass the smart-matching helpers: build, builder inspect, and config trusted-builders add now each verify that a tagged reference (paketobuildpacks/builder-jammy-base:latest) is treated as trusted via the tagless known entry. Signed-off-by: Rune Soerensen <rsoerensen@salesforce.com>
…date-trusted-builder-logic
|
Thanks @TIR44 - good catch on the SDK default. You're right that Pushed two follow-up commits:
Could you take a look and let me know if this covers what you had in mind? |
Summary
Consolidate all trust checking into
IsTrustedBuilderso callers don't need to separately checkIsKnownTrustedBuilder(), and usename.ParseReferencefor consistent reference matching across both known and user-configured builders.IsTrustedBuildernow checks both known trusted builders and user-configured trusted buildersname.ParseReferencefor consistent reference matching across both sources - entries without a tag match any tag in the repository, entries with a tag require an exact match|| IsKnownTrustedBuilder()calls frombuild.go,config_trusted_builder.go, andbuilder_inspect.goOutput
Before
After
Documentation
Related
Resolves #2572