Repository navigation
Consolidate trust logic into IsTrustedBuilder - #2573
jjbustamante merged 6 commits into
Conversation
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 |
|
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? |
|
@jjbustamante Please could we have a re-review? :-) |
|
@jjbustamante @jabrown85 Could we have a re-review here? This blocks a stack of PRs which leads to us being able to trust |
…ilders Signed-off-by: Rune Soerensen <rsoerensen@salesforce.com>
Signed-off-by: Rune Soerensen <rsoerensen@salesforce.com>
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>
fa3cc50 to
ea64e23
Compare
|
I've asked for review here: |
referencesMatch compared Context().RepositoryStr() for tagless trusted entries, and that drops the registry. Since IsKnownTrustedBuilder now shares this matching, it widened the hardcoded trust list rather than only fixing the tag comparison: example.com/paketobuildpacks/builder-jammy-base resolved as trusted, where an exact string match had rejected it. It applied to all nine tagless paketobuildpacks entries; the tagged ones compare Name(), which carries the registry, and were unaffected. Trusting a builder places registry credentials on its build image and KnownBuilders needs no user opt-in, so compare Context().Name() instead. Tagless entries still match any tag, now within one registry only. This also scopes user-configured entries, which were already registry blind before this branch. Trusting a mirror now means configuring it by its full name. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Juan Bustamante <bustamantejj@gmail.com>
jjbustamante
left a comment
There was a problem hiding this comment.
Thank you for this @runesoerensen , sorry for taking so long to merge it
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