Skip to content

Move pg-proto-parser and @pgsql/cli to @constructive-io/protobufjs 7.6.6 - #407

Merged
devin-ai-integration[bot] merged 10 commits into
mainfrom
devin/1795641530-drop-launchql-protobufjs
Nov 25, 2026
Merged

devin-ai-integration[bot] merged 10 commits into
mainfrom
devin/1795641530-drop-launchql-protobufjs

Conversation

@pyramation

@pyramation pyramation commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #405. pg-proto-parser and @pgsql/cli pinned @launchql/protobufjs@7.2.6, which is based on protobufjs 7.2.6 and misses 11 upstream security fixes. The fork (constructive-io/protobuf.js, rebased in constructive-io/protobuf.js#1) now sits on upstream protobufjs 7.6.6 / protobufjs-cli 1.3.3 and is published as @constructive-io/protobufjs@7.6.6 and @constructive-io/protobufjs-cli@1.3.3. This PR moves both packages to those versions.

  • Fork patch kept unchanged: Field.prototype.applyJsonName, called from parse, renames fields to their json_name (select_stmt becomes SelectStmt). Plain upstream drops these fields silently when it encodes a real AST.
  • The old Type.add workaround for a field named constructor is no longer needed, because upstream 7.6.6 Namespace.get checks own properties only.
  • proto-fetch: the generated module now defaults to @constructive-io/protobufjs/minimal. pbjs comes from @constructive-io/protobufjs-cli/pbjs.
  • 8.x was not used: it drops an explicitly set proto3 enum zero that 7.x encodes, so its wire output changes.

Tests

New tests: a json_name reflection test and a proto-fetch encode/decode round trip on a parsed SELECT 42 AST. Both fail on plain upstream protobufjs and pass on the fork.

Verification against the published npm packages:

  • All 114 generated files are byte-identical.
  • SELECT 42 round-trips with matching wire bytes on PG 13–18.
  • PG18 fixtures cross-decode 312/312; PG17 311/312, where the one failure is rejected by the parser itself.
  • proto-parser has 46 tests and 36 snapshots, and the CLI has 18 tests; all pass.

libpg-query and parser opened this PR for Dan
Implemented in session Remove vulnerable protobufjs fork from pg-proto-parser
Review with Devin · Open in Devin Desktop


@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@luxor-code-review

luxor-code-review Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


The migration from the @launchql protobufjs fork to upstream packages is coherent: all import sites were updated, the lockfile already resolves protobufjs 7.6.x / protobufjs-cli 1.3.x, the removed allowBuilds waiver matches the dropped postinstall dependency, and no residual @launchql/protobufjs references remain. The new getFieldName helper preserves existing snake_case generated output for the repo's protos, and the in-process pbjs call correctly routes errors through the promise wrapper.

Files Change
packages/pgsql-cli/src/commands/proto-fetch* proto-fetch command now invokes pbjs in-process via protobufjs-cli/pbjs and defaults to upstream protobufjs/minimal; covered by updated CLI tests
packages/proto-parser/src/** Import swap to upstream protobufjs, plus getFieldName in utils.ts and its use in the runtime-schema generator so generated field specs honor proto json_name annotations; new runtime-schema unit test pins the behavior
packages/*/package.json, pnpm-policy.yaml, pnpm-workspace.yaml Dependency swap and cleanup of the fork's allowBuilds entry; pins consistent across manifests
packages/pgsql-cli/README.md Documentation updated for the new dependency names

Reviewed commit: 3701af3

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The parser and CLI switch to upstream protobufjs packages. Runtime-schema generation uses JSON field names. Proto-fetch generates JavaScript in-process and defaults to protobufjs/minimal.

Changes: Protobuf.js migration and proto-fetch

Layer / File(s) Summary
Upstream protobufjs migration
packages/proto-parser/package.json, packages/proto-parser/src/ast/*, packages/proto-parser/src/parser.ts, packages/proto-parser/src/store.ts, packages/proto-parser/src/utils/*, packages/proto-parser/test-utils/index.ts, packages/proto-parser/__tests__/utilities.test.ts, packages/pgsql-cli/package.json, pnpm-policy.yaml, pnpm-workspace.yaml
The parser and CLI dependencies and imports switch to upstream protobufjs. Package versions change, and the install-script allowlists remove @launchql/protobufjs.
Runtime-schema field names
packages/proto-parser/src/runtime-schema/generator.ts, packages/proto-parser/__tests__/runtime-schema.test.ts
Runtime-schema generation obtains field names through getFieldName. Tests check SelectStmt naming and JSON field names for PG18 aggregate nodes.
Proto-fetch generation and runtime package
packages/pgsql-cli/src/commands/proto-fetch.ts, packages/pgsql-cli/src/commands/proto-fetch/helpers.ts, packages/pgsql-cli/src/commands/proto-fetch/static-module.d.ts, packages/pgsql-cli/src/utils/help.ts, packages/pgsql-cli/README.md, packages/pgsql-cli/__tests__/cli.test.ts
Proto-fetch loads schemas and generates static-module JavaScript in-process, applies JSON field names, and writes output. The CLI defaults to protobufjs/minimal and replaces package references only when the configured values differ. Tests cover imports, JSON field aliases, runtime package selection, and protobuf round-trips.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other · Severity of issue fixed: High

Sequence Diagram(s)

sequenceDiagram
  participant protoFetchCommand
  participant generateProtoJS
  participant protobufjs
  participant staticModule
  participant outputFile
  protoFetchCommand->>generateProtoJS: Pass schema and generation options
  generateProtoJS->>protobufjs: Load schema and resolve imports
  protobufjs-->>generateProtoJS: Return parsed root
  generateProtoJS->>staticModule: Generate JavaScript from root
  staticModule-->>generateProtoJS: Return generated JavaScript
  generateProtoJS->>outputFile: Write UTF-8 output
  protoFetchCommand->>outputFile: Replace runtime package reference when configured values differ
Loading
Merge Risk: Minimal · previous review bb222 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Security architecture risk: Minimal · up to bb222

The migration removes the shell invocation without adding a new caller or granting broader privileges. Generation errors are reported before the output file is opened. The final write is still non-atomic, but the review found no material regression in security or failure containment.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — For the inspected CLI callers, exposure is tied to the invoking account: local or downloaded schemas are parsed with that account’s filesystem access, and generation writes to the caller-selected output path. Moving generation in-process does not add credentials or a remote service entrypoint on these paths.

Trust Boundaries and Controls

  • observed — Input and output paths no longer pass through shell interpretation. Schema imports still enter filesystem resolution; local results take precedence over the bundled fallback, and the resolver is not a filesystem sandbox.
  • observed — Before passing rewritten reflection names to the static generator, the CLI rejects invalid identifiers and selected reserved or prototype-sensitive names.

Resilience and Maintainability Implications

  • observed — Each attempt builds a fresh reflection root and completes generation before opening the output. The final write and any subsequent package rewrite are separate, non-atomic operations; the helper does not coordinate concurrent writers to the same path.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the @launchql/protobufjs fork is replaced by upstream protobufjs 7.6.6. The summaries confirm this across package.json files, imports in pg-proto-parser and pgsql-cli,…
Linked Issues check Passed Issue #405 lists three coding options. This PR uses the upstream-migration option. At head, packages/proto-parser/package.json depends on protobufjs 7.6.6, which is at or above the 7.6.3 fix level nam…
Out of Scope Changes check Passed Each changed area supports removing the fork or preserving json_name under upstream protobufjs. The proto-fetch default --with-pkg change, the conditional replacement, and the README and help text fol…
Full details: Title check

Explanation

The title names the main change: the @launchql/protobufjs fork is replaced by upstream protobufjs 7.6.6. The summaries confirm this across package.json files, imports in pg-proto-parser and pgsql-cli, and the pnpm allowBuilds lists. The title is short and specific. It omits the proto-fetch behavior changes and the json_name handling, which is acceptable because the title does not need to cover every detail.

Full details: Linked Issues check

Explanation

Issue #405 lists three coding options. This PR uses the upstream-migration option. At head, packages/proto-parser/package.json depends on protobufjs 7.6.6, which is at or above the 7.6.3 fix level named in the issue. Per the previous assessment and the PR summary, @pgsql/cli also uses protobufjs 7.6.6 and protobufjs-cli 1.3.3. The fork is removed from package.json files and pnpm-policy.yaml and pnpm-workspace.yaml. The json_name behavior is kept: getFieldName in the proto-parser runtime-schema generator, and applyJsonFieldNames in packages/pgsql-cli/src/commands/proto-fetch/helpers.ts (read at head). A runtime-schema test covers JsonObjectAgg. The GitHub advisory and npm deprecate steps are non-coding and are not assessed. Test results were not re-run by this assessment. They rely on the PR author's report and the test files present in the diff.

Full details: Out of Scope Changes check

Explanation

Each changed area supports removing the fork or preserving json_name under upstream protobufjs. The proto-fetch default --with-pkg change, the conditional replacement, and the README and help text follow from removing the fork. The helpers.ts changes replace the shell pbjs exec with the protobufjs-cli API and apply json_name. The google/ import resolution in helpers.ts (resolvePath using the installed protobufjs include directory) supports the same change, because the API call no longer inherits the import paths of the pbjs executable. The commit intent 'Resolve bundled Google API proto imports' matches this code. The static-module.d.ts declaration supports the protobufjs-cli import. Version bumps and the import-path edits in proto-parser match the dependency change. No unrelated change was found in the reviewed summary.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2aeaffe and bb22257.

Files selected for processing: 2

  • packages/pgsql-cli/__tests__/cli.test.ts
  • packages/pgsql-cli/src/commands/proto-fetch/helpers.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​constructive-io/​protobufjs-cli@​1.3.37610010091100
Added@​constructive-io/​protobufjs@​7.6.6100100100100100

View full report

@devin-ai-integration devin-ai-integration Bot changed the title Replace @launchql/protobufjs fork with upstream protobufjs 7.6.6 Move pg-proto-parser and @pgsql/cli to @constructive-io/protobufjs 7.6.6 Nov 25, 2026
@devin-ai-integration
devin-ai-integration Bot merged commit 3430265 into main Nov 25, 2026
23 checks passed
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.

@launchql/protobufjs (pinned by pg-proto-parser) is missing the upstream protobufjs security fixes

1 participant