Skip to content

[#158] Settings → Restrict custom provider to local development - #161

Merged
revett merged 5 commits into
8thpark:mainfrom
MFA-G:fix/local-custom-provider
Aug 10, 2026
Merged

[#158] Settings → Restrict custom provider to local development#161
revett merged 5 commits into
8thpark:mainfrom
MFA-G:fix/local-custom-provider

Conversation

@MFA-G

@MFA-G MFA-G commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Resolves #158

Problem

  • Production builds expose the Custom S3-compatible provider, which is intended only for contributors using the local MinIO setup
  • Hiding Custom without a replacement would leave production users with only R2, so the requested Amazon S3 provider needs its own safe configuration path

Changes

  • Add Amazon S3 as a persisted provider with a region-derived AWS endpoint
  • Show Custom only in non-production builds, using an esbuild-defined NODE_ENV
  • Render only the fields each provider needs and validate Amazon S3 region settings
  • Add unit coverage for provider normalization, options, endpoint derivation, completeness, and connection validation

Validation

  • npm run lint
  • npm run build
  • npm test (198 passed)
  • npm run check-versions
  • npm run audit
  • git diff --check

Integration tests were not run locally because Docker is not installed in this environment.

Greptile Summary

Adds Amazon S3 as a persisted storage provider while restricting the custom S3-compatible provider to development builds.

  • Derives Amazon S3 endpoints from validated region identifiers.
  • Adds provider-specific settings fields, completeness checks, and connection validation.
  • Defines the build environment through esbuild and expands unit and technical documentation coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the S3 endpoint is now produced only when the persisted region passes a restrictive alphabet-and-shape check that excludes URL authority and path delimiters.

Important Files Changed

Filename Overview
src/settings/settings.ts Adds the S3 provider, derives its endpoint only after restrictive region validation, and updates provider normalization and completeness checks.
src/settings/tab.ts Adds provider-specific S3 region input and hides the custom provider from production builds.
src/storage/storage.ts Updates connection validation so Amazon S3 requires a valid region while custom providers retain endpoint and region requirements.
esbuild.config.mjs Defines process.env.NODE_ENV consistently for production and development bundles.
src/settings/settings.test.ts Covers S3 persistence, endpoint derivation, malicious region rejection, provider options, and connection completeness.
src/storage/storage.test.ts Adds coverage for missing Amazon S3 region validation.

Reviews (2): Last reviewed commit: "Update docs" | Re-trigger Greptile

Context used:

@revett

revett commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@greptileai Review PR

Comment thread src/settings/settings.ts
@revett

revett commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@MFA-G Can you address the comment and 3/5 confidence please?

@revett

revett commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

@MFA-G Do you need any help with this PR?

@revett revett changed the title Settings → Restrict custom provider to local development [#158] Settings → Restrict custom provider to local development Aug 2, 2026
endpointFor interpolates the persisted region straight into the URL
authority for the s3 provider, so a region containing authority
delimiters (x@attacker.example:443#) redirects signed connection and
sync requests, vault data included, to an unintended host.

Validate the region as an AWS region identifier: endpointFor returns ""
for anything else, hasConnectionConfig treats it as incomplete, and
testConnection reports it as a missing region with an example.
@MFA-G

MFA-G commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the delay @revett — no help needed, addressed now in 2e77bf7.

Greptile P1 (region can redirect S3 requests): valid. endpointFor interpolated the persisted region straight into the URL authority for the s3 provider, so a region like x@attacker.example:443# sends signed requests (vault data included) to another host.

The fix validates the region as an AWS region identifier before it can reach a URL:

  • isAwsRegion/^[a-z]{2}(-[a-z]+){1,2}-\d{1,2}$/, a restricted alphabet that admits no character able to terminate or redirect an authority. Covers us-east-1, eu-west-2, ap-southeast-1, us-gov-west-1.
  • endpointFor returns "" for an s3 region that doesn't match, rather than a host we never meant to talk to.
  • hasConnectionConfig treats a non-region as incomplete, so the UI won't offer to connect with one.
  • missingFieldFor reports region (for example us-east-1) so a typo gets an actionable message instead of an opaque signing failure.

r2 is untouched (it signs with auto) and custom keeps its explicit endpoint.

Added 16 test cases including the exact x@attacker.example:443# payload, a path-separator variant, and a newline injection. npm test 214/214 pass, npm run lint and npm run build clean.

@revett

revett commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@MFA-G Great! Thanks for the update 🙏

Could you resolve the conflicts?

Resolves conflicts in settings.ts, tab.ts, settings.test.ts and storage.ts
against the prefix (8thpark#154) and endpoint-normalization (8thpark#79) work on main.
All conflicting hunks were additive on both sides, so both are kept.
@MFA-G

MFA-G commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Conflicts resolved in 97abfc5 (merged main, not a force-push, so the review history above stays intact).

The overlap was with the prefix work (#154) and the endpoint normalization (#79) that landed while this was open. Every conflicting hunk was additive on both sides, so both sides are kept:

  • src/settings/settings.tsConnectionStatus, normalizePrefix/prefixError and isCurrentConnectionResult from main sit alongside this PR's Provider union and isAwsRegion.
  • src/settings/tab.ts — the import list keeps isCurrentConnectionResult/prefixError and providerOptions.
  • src/storage/storage.tsisAwsRegion joins the normalizePrefix/prefixError/deadline imports.
  • both test files keep both sets of cases.

One thing worth flagging: main's normalizeEndpoint (#79) only applies to custom, so it doesn't overlap with the S3 region validation — endpointFor still returns "" for an s3 region that isn't an AWS region identifier.

npm test 406/406 pass, npm run lint and npm run build clean.

@revett

revett commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@greptileai Review PR

@revett
revett merged commit a66541d into 8thpark:main Aug 10, 2026
11 checks passed
@revett

revett commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@MFA-G Thanks for another PR! 🍪

I finished it off, as it is needed for the 0.1.0 release.

Please keep contributing and sharing the project

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.

Settings → Only allow custom provider for local dev

2 participants