Skip to content

PSS: Add interactive confirmation of state storage provider trust when initialising a state store for the first time#38395

Open
SarahFrench wants to merge 14 commits intomainfrom
pss/TF-33680-interactive-confirm-pss-providers
Open

PSS: Add interactive confirmation of state storage provider trust when initialising a state store for the first time#38395
SarahFrench wants to merge 14 commits intomainfrom
pss/TF-33680-interactive-confirm-pss-providers

Conversation

@SarahFrench
Copy link
Copy Markdown
Member

@SarahFrench SarahFrench commented Apr 16, 2026

Closes https://hashicorp.atlassian.net/browse/TF-33680

This is a reworking of discovery in #38205. Following design changes, we no longer expect a new flag to be used in this feature.

The security features added in this PR will be active during init only. They'll only be active when the state store provider is being installed for the first time, via HTTP. We believe using provider from a local cache or filesystem mirror shows that trust has already been established for the provider so the prompt is not shown then. See the ticket for more information.

Given that all changes to a state store are going to be implemented in a new state migrate command (see #38388), the work in this PR will need to be replicated in the new state migrate command.

Reviewer 👋🏻

It's worth going commit by commit in this PR, given that I start with this change 7f9c48c because that obscures how I later change the callbacks slightly in getProvidersFromConfig

Hang in there! 😉

Target Release

1.16.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Apr 16, 2026
@SarahFrench SarahFrench changed the base branch from main to pss/TF-36273-no-pss-upgrade-in-init April 16, 2026 15:31
@github-actions

This comment was marked as resolved.

@SarahFrench SarahFrench force-pushed the pss/TF-33680-interactive-confirm-pss-providers branch 2 times, most recently from 2988e59 to 2a398fd Compare April 17, 2026 18:47
@SarahFrench SarahFrench changed the title Pss/tf 33680 interactive confirm pss providers PSS: Add interactive confirmation of state storage provider trust when initialising a state store for the first time Apr 17, 2026
@SarahFrench SarahFrench force-pushed the pss/TF-36273-no-pss-upgrade-in-init branch from cb46802 to aa50304 Compare April 21, 2026 11:45
@SarahFrench SarahFrench force-pushed the pss/TF-33680-interactive-confirm-pss-providers branch from e65292f to 7945eb3 Compare April 21, 2026 11:48
@AndrewCharlesHay

This comment was marked as resolved.

Base automatically changed from pss/TF-36273-no-pss-upgrade-in-init to main April 23, 2026 06:51
@SarahFrench SarahFrench force-pushed the pss/TF-33680-interactive-confirm-pss-providers branch 3 times, most recently from c47c251 to 03f4de7 Compare April 23, 2026 07:27
@SarahFrench SarahFrench marked this pull request as ready for review April 23, 2026 12:48
@SarahFrench SarahFrench requested a review from a team as a code owner April 23, 2026 12:48
Comment on lines +432 to +437
var authentication string
if authResult != nil && authResult.KeyID != "" {
authentication = fmt.Sprintf("%s, key ID %s", authResult.String(), authResult.KeyID)
} else {
authentication = authResult.String()
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As the (AI?) comment also noted, this is an area that I'd like to get some feedback on in the review process. I think that the auth result is only populated when I download a provider from the Registry, which makes it hard to test.

Given that the prompt is only shown when a provider is downloaded via HTTP I think we always expect there to be an auth result when a prompt is shown. My test simulating download via HTTP is highly artificial, and it's unclear to me right now what the gap is there versus downloading a provider from a Registry or a network mirror.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Researching this some more today...

Copy link
Copy Markdown
Member Author

@SarahFrench SarahFrench Apr 24, 2026

Choose a reason for hiding this comment

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

Ok, so here's my understanding:

The process of installing providers gets meta data for a given provider here. An installer can include multiple sources of providers, and the presence of Authentication metadata (that this thread focuses on) depends on the source that's in play.

Irrelevant sources, which just wrap other sources: MemoizeSource, MultiSource
Sources used by end-users:

Sources used in our tests:


The Authentication metadata returned from these sources vary:


The features in this PR are only active when a provider is downloaded via HTTP. So, only HTTPMirrorSource and RegistrySource are relevant. The only time when we'd have a lack of Authentication data is when using a network mirror and that network mirror doesn't include any hash data for the state store provider.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I could look at enabling tests to use an HTTPMirrorSource in combination with a test server - I'll look into that next week.

Copy link
Copy Markdown
Member Author

@SarahFrench SarahFrench Apr 27, 2026

Choose a reason for hiding this comment

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

Rebased to pull in changes from #38447 merged to main. I've added the test in a11fa85

@SarahFrench SarahFrench removed the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Apr 28, 2026
@SarahFrench SarahFrench force-pushed the pss/TF-33680-interactive-confirm-pss-providers branch from d67c9ab to c6c30a6 Compare April 28, 2026 12:10
@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Apr 28, 2026
SarahFrench

This comment was marked as resolved.

…ing the new newMockProviderSourceUsingTestHttpServer method
…ow finer control of callbacks when implementing security related features
… method

I originally added this to have more control over what we render in the prompt, but I'm walking this back before seeking feedback in review. Could (*PackageAuthenticationResult) .String() be sufficient?
@SarahFrench SarahFrench force-pushed the pss/TF-33680-interactive-confirm-pss-providers branch from 972ac1f to 95bd13f Compare April 28, 2026 16:29
Copy link
Copy Markdown
Member Author

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

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

Some quick comments for reviewers

Comment thread internal/command/init.go
return "Prepare your working directory for other commands"
}

// Returns a reused callback function for the ProviderAlreadyInstalled event in a providercache.InstallerEvents struct.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This section of many, many callbacks was essentially a copy-paste job from getProvidersFromConfig and then working out what variables were previously caught by closures and now needed to be explicit arguments for creating the callback.

Comment thread internal/command/init.go
Comment on lines +489 to +491
// 2. Call the shared callback for FetchPackageSuccess
cb := fetchPackageSuccessCallback(view)
cb(provider, version, localDir, authResult)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Whereas PendingProviders and QueryPackagesBegin have their own logic above due to needing specific message content to send to the view, the FetchPackageSuccess callback is handling distinct tasks and I think using a callback like this helps highlight what's special logic for this calling code .

Copy link
Copy Markdown
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

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

love the changes to events, thank you!

Comment thread internal/command/init.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Add this to your PR if the change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants