Skip to content

optimize export/import - #192

Merged
jwfing merged 7 commits into
devAug31from
fix/schema-apikey
Sep 4, 2025
Merged

jwfing merged 7 commits into
devAug31from
fix/schema-apikey

Conversation

@jwfing

@jwfing jwfing commented Sep 3, 2025 •

Copy link
Copy Markdown
Member
$ ./test-rawsql-export-import.sh 
🧪 Testing RawSQL, Export, and Import Endpoints...
Using admin credentials: [email protected]
1. Logging in as admin...
✅ Admin login successful
2. Creating large_table using RawSQL endpoint...
Creating basic table structure...
✅ Basic table created successfully
Setting up indexes, triggers and RLS...
✅ Table fully configured with indexes, triggers and RLS
3. Verifying table schema...
✅ Table schema retrieved successfully
✅ Required columns (user_id, created_at, updated_at) exist
✅ RLS is enabled on the table
4. Importing test data using Import endpoint...
✅ Data imported successfully
5. Verifying imported data...
Total records in large_table: 1506
✅ Table contains 1000+ records as expected
6. Testing Export endpoint...
✅ Database exported successfully
✅ Export contains table creation statement
✅ Export contains data insertion statements
✅ Export contains RLS policies
✅ Export contains update trigger
Number of INSERT statements in export: 1000
7. Testing Export with row limit...
✅ Export with row limit successful
INSERT statements in limited export: 10
✅ Row limit is working (limited export has fewer rows)

==========================================
RawSQL/Export/Import Test Complete
==========================================
✅ All tests passed!
🧹 Cleaning up test data...
Dropping large_table...
Table cleanup response: {"rows":[],"rowCount":null,"fields":[]}
🧹 Cleaning up test data...
No admin token available - some cleanup may be limited
No API key available - bucket cleanup may be limited
✅ Cleanup completed successfully

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want a sql sanitizer here as well? For sql injection attack prevention purpose

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 function is used while importing with rawSQL, sql injection doesnt apply here...

@tonychang04

Copy link
Copy Markdown
Member

nit: maybe can add some more in description about what's the optmization so we know better on what to look for

@tonychang04 tonychang04 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tests LGTM

@jwfing
jwfing merged commit 8c5549f into devAug31 Sep 4, 2025
tonychang04 added a commit that referenced this pull request Sep 10, 2026
* chore(deps): vitest 4.1.11, nodemailer 9.1.1, js-yaml 4.3.2

Clears 7 of the 11 open Dependabot alerts on this repo. The remaining 4 are
covered below with reasons, not left silent.

  vitest          ^4.1.8 / ^4.1.6 -> ^4.1.11 in backend, packages/ui and
                  packages/dashboard (each declares its own)        2 alerts, dev
  @vitest/mocker  lifts to 4.1.11 with vitest
  nodemailer      ^9.0.3 -> ^9.1.1                                  4 alerts, runtime
  js-yaml         override 5.2.3 -> ^4.3.2                          1 alert, dev, HIGH

nodemailer is NOT the 6.x -> 9.x major the alert ranges imply -- the repo is
already on 9.0.3, so this is a patch bump. Note 9.1.1 rather than 9.1.0: alert
#192 covers "<= 9.1.0", so 9.1.0 would still be flagged.

js-yaml is the interesting one. The root override pinned 5.2.3, but every
consumer wants ^4.1.x (@eslint/eslintrc, cosmiconfig, csv-to-pg), so a 5.x pin
could not apply to them and the root copy sat on the vulnerable 4.3.1 while the
override looked like it had handled it. ^4.3.2 is the patched release in the
line they actually resolve, so the override now does what it claims.

NOT FIXED, and not fixable:

  adm-zip #188   GHSA-vwc7-r8mq-g2x9, ">= 0.5.9, <= 0.6.0", first_patched_version
                 NONE. 0.6.0 is the latest published version, so there is no
                 upstream fix to take. Needs a risk acceptance or a replacement
                 dependency, not a bump.

NOT FIXED, deliberately, both unchanged from #2048:

  qs #182/#183   express@4 -> [email protected] pins qs@~6.15.1 and the patch
                 is 6.16.0, outside it. Needs an express 5 major.
  csv-parse #187 dev-only, via pgsql-seed -> [email protected] -> csv-parse ^6.2.1.
                 pg-seed@latest still requires ^6.2.1, so there is no upstream
                 fix. The runtime path is already on 7.0.2.

Lock regenerated with npm 11 (`npx npm@11 install --package-lock-only`): npm
10.9.4 fails on this repo with `Cannot read properties of null (reading
'edgesOut')`, which reproduces on clean main with the lock deleted and is not
caused by this change. lockfileVersion stays 3 and `npm ci` under npm 10
installs it cleanly.

Verified: `npm ci` clean; `npm run typecheck` 8/8 turbo tasks; backend suite
203 files / 2,425 tests passed, 21 skipped. First run showed 1 failure that
did not reproduce on re-run -- flake, not this change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015uMMufpCJ4VqNeavrDHJim

* fix(deps): regenerate the js-yaml subtree so no stale edge survives

Greptile's P2 is correct, and I had noticed this and waved it off, which was
wrong. After the override moved from 5.2.3 to ^4.3.2, the lockfile still pinned
`node_modules/@eslint/eslintrc/node_modules/js-yaml` at 5.2.3 -- a version that
satisfies NEITHER the new override NOR @eslint/eslintrc's own ^4.1.1. A
lock-based install and a fresh resolve would therefore have produced different
trees.

Not a security issue: 5.2.3 sits above the vulnerable `>=4.0.0 <4.3.2` range.
It is a lockfile correctness issue, which is worth fixing on its own terms.

Dropped the stale node and re-resolved. There is now exactly ONE js-yaml, at
4.3.2, satisfying both the override and eslintrc.

Verified: `npm ci` clean; `npm ls js-yaml --all` reports 4.3.2 as `overridden`
and `deduped` with NO `invalid` nodes; `npm run typecheck` 8/8 turbo tasks.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015uMMufpCJ4VqNeavrDHJim

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

3 participants