Skip to content

Restore verified production portal source and reconcile current dependencies - #738

Open
dansiegel wants to merge 11 commits into
masterfrom
codex/portal-source-integration-20261022
Open

dansiegel wants to merge 11 commits into
masterfrom
codex/portal-source-integration-20261022

Conversation

@dansiegel

@dansiegel dansiegel commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Restores the reviewed production portal source from restore/production-portal-source at 920d78b. PackageSearch.razor matches deployed SHA-256 c0124322597de179609ecae77a3fed88f6b5dd30aa14df6f1124dfb563999867. The provenance manifest documents eight matched Host/UI files and their limits. No private history, runtime configuration, credentials, binaries or local WIP is imported.

Reconciles dependency PR #735 at master 7508993, preserving newer OpenAPI versions, docs lockfile and MinIO qualification fixture. Generates required public CSS from the preserved npm lockfile. Supersedes #717's older layout/search scope without merging that branch.

Not ready to merge: the confirmed OCI repository/blob finding needs a complete repair and a legacy-availability decision. All original 19 test failures are resolved.

Validation:

  • At bbdf97a, CI passes restore/build/tests: 934 passed, zero failed, four existing skips (938 total).
  • Latest CI at 13d2e77ab27287b56a397c8ba9d281f9fb52b207 is green: restore/build/tests pass, including the additional vulnerability/npm fixes.
  • Separate preserved component suite: 73 passed, zero failures/skips, including public/private anonymous OCI issuance.
  • Combined portal content at dcef96e: 188 UI tests pass, zero failures/skips; admin/auth 265 passed; nine Chromium browser checks pass. This combined tree is preserved on codex/portal-combined-validation, not merged to master.

Original failures were reconciled without weakening private provider decisions: restored provider-defined anonymous NuGet reads (five new controls), rejected malformed credentials and anonymous writes, corrected seeded vulnerability array-contract tests, asserted lazy/immutable npm behavior, exercised trusted forwarded headers, corrected OCI service identities and token permission-intersection assertions, and fixed missing-credential OCI issuance.

Review findings validated against source:

Finding Evidence / disposition
Private vulnerability inventory Confirmed missing AuthorizedNuGetConsumerFilter. Fixed in 9fdb4da; 12 service-index/vulnerability tests pass, including anonymous 401/challenge and valid credential access to synthetic private inventory.
Mirrored npm shared basename Confirmed version rows and URLs collided. Fixed in 13d2e77 using canonical version URLs while retaining original upstream URLs. All 28 npm tests pass; three controls cover proxy-only, cached and existing colliding-cache data. Ambiguous old URLs fail safely.
Scoped OCI blob access Confirmed with real HTTP regression: token for repository A retrieves bytes uploaded under B via A's blob URL (200 where 404 expected). Failing regression preserved separately at bf9aa25 on codex/738-oci-blob-scope-regression. Existing OciBlob has feed/surface/digest only, and upload completion discards repository association. Complete repair needs durable repository/blob associations, upgrade handling and upload/mirror/manifest/GC coverage. Proposed source-only patch: OciRepositoryBlobs keyed by non-null RepositoryKey+Digest, repository FK, four provider migrations/snapshots, shared GET/HEAD and manifest-dependency enforcement, upload/mirror/index association maintenance and GC cleanup in existing transactions. Schema source was not tool-denied.
PostgreSQL case collision Confirmed in disposable PostgreSQL 16: old case-sensitive unique index accepts Foo/foo at the same feed/version; restored lower(Id)/lower(Version) index fails. No production data was accessed. Fixed fail-fast preflight in db1348a. It locks the table, reports collision groups/keys and aborts before index creation, preserving every package row. Ten disposable PostgreSQL tests pass, including failure/retry preservation, actionable report, distinct feeds/versions and successful uniqueness enforcement. Documented operator preflight remains read-only; any actual collision resolution is outside this task.

Collision preflight for review (not run on production):

SELECT lower("Id"), "FeedId", lower("Version"), count(*),
       array_agg("Key" ORDER BY "Key")
FROM "Packages"
GROUP BY lower("Id"), "FeedId", lower("Version")
HAVING count(*) > 1;

Separate scoped bug PRs #739 (Closes #736) and #740 (Closes #737) target this integration branch. #740 also preserves generic anonymous readiness while restricting detailed Host feed health/metrics; its documented monitoring compatibility change needs consumer coordination before rollout.

Adding the existing component project to solution CI with a logger reference was rejected by automatic approval review under the separate dependency-owner restriction; no dependency change was made. Existing master automation publishes internal NuGet artifacts and docs Pages after merge. No manual deployment, production migration, live configuration, credential, access-grant or recovery release change is performed.

Latest source head: db1348a; exact-head CI is pending. No production migration or retained-data repair was attempted.

OCI legacy compatibility decision: reconstructing layer/config membership from old manifest references would reintroduce disclosure. Pre-fix Published manifests could contain foreign references; mirrored manifests prove only their own fetched bytes. Origin metadata cannot establish edge provenance. Safe default: retain direct tagged-manifest access, establish blob ownership through verified requested-repository upstream retrieval or reupload, and leave other unmapped legacy bytes stored but unavailable through repository blob endpoints. A separately reviewed ownership import could restore specified historical associations; no automatic graph import or general trust switch is proposed. This can affect legacy image layers, not only unreferenced uploads.

Read-only deployed monitoring inventory could not be completed from this cloud environment: no AWS/Azure/Kubernetes credential context, no deployment connector, and only a local Docker socket are available. Repository samples/documentation are evidence of intended consumers, not proof of deployed scrapers. No access or credential reconfiguration was attempted.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T14:43:27.253086Z db1348a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc182c58df

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +65 to +68
|| OciRouteParser.TryParse(request.HttpContext.Request.Path, out var route)
&& (route.Kind == OciRouteKind.Catalog
? request.Operation == FeedOperation.Pull && Allows(ticket, "catalog", request.Operation, "registry")
: route.RepositoryName is { } repository && Allows(ticket, repository, request.Operation)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind scoped blob access to the authorized repository

When a bearer token grants pull access only to repository A, this check authorizes /v2/A/blobs/<digest-from-B> because it validates only the repository name in the request path. OciRegistryService.GetBlobAsync then returns any matching blob from the surface-wide digest store at lines 210-215 without verifying that the digest belongs to A, so knowledge of a digest bypasses the repository scope and exposes content from B. Require a repository-to-blob association before serving locally stored blobs.

Useful? React with 👍 / 👎.

Comment on lines +28 to +30
app.MapGet("v3/vulnerabilities/vulnerabilities-base.json", GetVulnerabilityPage)
.AllowAnonymous()
.WithTags(nameof(Vulnerability));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require feed authentication for vulnerability data

On a private feed where anonymous pulls are disabled, this new endpoint remains anonymously callable and returns every vulnerable package ID, advisory URL, severity, and affected range. Other NuGet endpoints use AuthorizedNuGetConsumerFilter after AllowAnonymous() to enforce feed credentials, but this route omits that filter, exposing private package inventory and security metadata to unauthenticated requests.

Useful? React with 👍 / 👎.

Comment on lines +12 to +13
CREATE UNIQUE INDEX "IX_Packages_CaseInsensitiveIdentity"
ON "Packages" (lower("Id"), "FeedId", lower("Version"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve case-colliding rows before creating the unique index

When upgrading a PostgreSQL feed that already contains IDs differing only by case at the same feed and normalized version, such as Foo and foo, the existing case-sensitive unique index permits both rows but this statement fails with a duplicate-key error and prevents the application from completing migrations or starting. Reconcile or explicitly migrate these pre-existing collisions before creating the case-insensitive unique index.

Useful? React with 👍 / 👎.

{
continue;
}

UpsertDistTag(package, entry.Key, version, feedId);
var storagePath = $"{EncodePackagePath(normalizedName)}/-/{tarballFileName}";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Give each mirrored npm version a unique tarball path

When an upstream packument gives two versions tarball URLs with the same basename, which npm permits because dist.tarball is an arbitrary URL, both rows receive this identical local path and their packument entries are rewritten to the same local URL. GetTarballAsync then selects a version by TarballPath alone, so caching or downloading either URL can return the other version's bytes and make installs fail integrity checks. Derive the local filename from the package version while retaining the original upstream URL in metadata.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db1348a6dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +85 to +88
(await _packageAuthentication.AuthenticateForOperationAsync(
string.Empty,
FeedOperation.Pull,
cancellationToken)).Succeeded;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restrict anonymous provider checks to read operations

When an operation-aware authentication provider permits an empty credential for Pull but denies Push, every unauthenticated OCI write is nevertheless accepted because this helper always checks Pull, and AuthenticateAsync uses its successful result before considering request.Operation. This allows anonymous blob uploads and manifest publication on providers that intentionally support anonymous reads; apply this shortcut only to pull/login requests or evaluate the actual requested operation.

Useful? React with 👍 / 👎.

Comment on lines +40 to +42
authentication is IOperationAwarePackageAuthenticationService operationAware
? WithLoginFallbackAsync(op => operationAware.AuthenticateAsync(username, token, op, cancellationToken), operation)
: authentication.AuthenticateAsync(username, token, cancellationToken);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve publisher checks for legacy Basic credentials

For a custom provider implementing only the legacy IPackageAuthenticationService, the username/token overload is the consumer check while the token-only overload is the publisher check. The NuGet and OCI adapters now pass Basic-authenticated pushes through this fallback, which always invokes the consumer overload regardless of FeedOperation.Push, so a read-only consumer credential can upload packages or OCI artifacts. Legacy push handling must use the token-only publisher overload or reject Basic credentials.

Useful? React with 👍 / 👎.

Comment on lines +115 to +118
using var stream = entry.Open();
using var ms = new MemoryStream();
stream.CopyTo(ms);
return ms.ToArray();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bound expanded NuGet entries before buffering

When a published or mirrored package contains a highly compressed DLL with a very large expanded size, opening its Diff tab calls ReadZipBytes for every assembly while building the tree, and this unbounded copy materializes the entire expanded entry in memory. A small zip bomb can therefore exhaust the server heap from a single comparison request; reject oversized entries and enforce cumulative expanded-size and entry-count limits before copying, as the npm and Helm inspectors already do.

Useful? React with 👍 / 👎.

Comment on lines +731 to +733
if (await _context.NpmVersions.IgnoreQueryFilters().AnyAsync(v => v.FeedId == feedId && v.PackageKey == package.Key && v.Version == version, cancellationToken))
throw new NpmRegistryException(409, "EPUBLISHCONFLICT", "A package version is immutable. Publish a new version instead.");
await _blobStore.PutAsync(storagePath, bufferedTarball, cancellationToken);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Prevent losing publish transactions from writing package bytes

When two clients publish different tarballs for the same new version concurrently on PostgreSQL, both serializable transactions can pass the absence check before either commits, while this external blob write is neither serialized nor rolled back with the database transaction. The transaction that ultimately loses can still replace the object on S3, and stores that return Conflict are also unsafe because PathBlobStore discards that result, leaving the winning NpmVersion shasum and packument describing different bytes than the tarball served to clients. Use a per-attempt staging path or a conditional write whose result is tied to the winning catalog insert.

Useful? React with 👍 / 👎.

Description = metadata.Description,
ReleaseNotes = metadata.ReleaseNotes,
HasReadme = false,
HasEmbeddedIcon = !string.IsNullOrWhiteSpace(metadata.IconFile),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid advertising uncached embedded icons as local

When live upstream metadata describes an IconFile, this transient package is marked as having a local embedded icon even though its nupkg has not been cached. GetPackageInfo consequently emits the feed's local icon endpoint, which the package-detail browser requests automatically; that endpoint calls MirrorAsync, so merely viewing metadata downloads and caches the entire package, while a ProxyOnly source downloads it and still returns no icon because no local row was created. Do not mark transient upstream models as locally embedded, or expose an icon path that can proxy the asset without implicitly importing the package.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant