@runa-ai/runa-cli 0.5.71 → 0.5.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/db/apply/actors.d.ts.map +1 -1
- package/dist/commands/db/apply/helpers/index.d.ts +1 -1
- package/dist/commands/db/apply/helpers/index.d.ts.map +1 -1
- package/dist/commands/db/apply/helpers/plan-validator.d.ts +26 -0
- package/dist/commands/db/apply/helpers/plan-validator.d.ts.map +1 -1
- package/dist/commands/db/apply/helpers/retry-logic.d.ts.map +1 -1
- package/dist/index.js +138 -55
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/apply/actors.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA8FlD,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/apply/actors.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA8FlD,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAkgCD;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB;WAExB,YAAY;eAAa,MAAM;UAAQ,KAAK,GAAG,MAAM;gCA+C9D,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB;WAEnB,YAAY;eAAa,MAAM;gCA0RxC,CAAC;AAkCH;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;cACjB,MAAM,EAAE;;WACX,YAAY;eAAa,MAAM;gCAwBxC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;aACV,OAAO;;WACT,YAAY;eAAa,MAAM;gCAmExC,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { acquireAdvisoryLock, MIGRATION_LOCK_ID, releaseAdvisoryLock, } from './advisory-lock.js';
|
|
7
7
|
export type { FilterResult, PlanHazard, PlanStatement, ValidatedPlan } from './plan-validator.js';
|
|
8
|
-
export { filterIdempotentProtectedStatements, isDropStatementForProtectedObject, parsePlanOutput, validatePlanForExecution, } from './plan-validator.js';
|
|
8
|
+
export { ALLOWED_DDL_PREFIXES, BLOCKED_SQL_PATTERNS, filterIdempotentProtectedStatements, isDropStatementForProtectedObject, parsePlanOutput, validatePlanForExecution, validateStatementTypes, } from './plan-validator.js';
|
|
9
9
|
export type { IdempotentProtectedObjects, ParsedHazard, PartitionPrivilegeDetection, PgSchemaDiffPlanOptions, } from './pg-schema-diff-helpers.js';
|
|
10
10
|
export type { ShadowDbConfig, ShadowDbResult } from './shadow-db-manager.js';
|
|
11
11
|
export { buildAllowedHazards, detectDropTableStatements, detectPartitionPrivilegeError, displayCheckModeResults, displayHazardsWithContext, executePgSchemaDiffPlan, filterFalsePositiveHazards, formatPartitionPrivilegeHint, getIdempotentProtectedObjects, getIdempotentProtectedTables, getIdempotentRoles, handleHazardsWithContext, handleProductionAuthzProtection, handleProductionDataProtection, isIdempotentRoleHazard, parseHazardsWithContext, PG_SCHEMA_DIFF_APPLY_TIMEOUT_MS, resetIdempotentRolesCache, verifyDatabaseConnection, verifyPgSchemaDiffBinary, } from './pg-schema-diff-helpers.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EACL,mCAAmC,EACnC,iCAAiC,EACjC,eAAe,EACf,wBAAwB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mCAAmC,EACnC,iCAAiC,EACjC,eAAe,EACf,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE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,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC"}
|
|
@@ -95,6 +95,32 @@ export declare function filterIdempotentProtectedStatements(plan: ValidatedPlan,
|
|
|
95
95
|
export { isDropStatementForProtected as _isDropStatementForProtected };
|
|
96
96
|
export { extractProtectedSchemas as _extractProtectedSchemas };
|
|
97
97
|
export { isDropSchemaForProtected as _isDropSchemaForProtected };
|
|
98
|
+
/**
|
|
99
|
+
* Allowed DDL statement prefixes. Only these statement types are permitted
|
|
100
|
+
* in pg-schema-diff plan output. Checked against the normalized first keyword(s)
|
|
101
|
+
* of each statement's SQL.
|
|
102
|
+
*/
|
|
103
|
+
export declare const ALLOWED_DDL_PREFIXES: readonly ["CREATE TABLE", "ALTER TABLE", "DROP TABLE", "CREATE INDEX", "CREATE UNIQUE INDEX", "DROP INDEX", "CREATE SCHEMA", "ALTER SCHEMA", "DROP SCHEMA", "CREATE FUNCTION", "CREATE OR REPLACE FUNCTION", "ALTER FUNCTION", "DROP FUNCTION", "CREATE TRIGGER", "ALTER TRIGGER", "DROP TRIGGER", "CREATE VIEW", "CREATE OR REPLACE VIEW", "CREATE MATERIALIZED VIEW", "ALTER VIEW", "DROP VIEW", "DROP MATERIALIZED VIEW", "CREATE TYPE", "ALTER TYPE", "DROP TYPE", "CREATE SEQUENCE", "ALTER SEQUENCE", "DROP SEQUENCE", "CREATE POLICY", "ALTER POLICY", "DROP POLICY", "CREATE ROLE", "ALTER ROLE", "DROP ROLE", "CREATE EXTENSION", "ALTER EXTENSION", "DROP EXTENSION", "GRANT", "REVOKE", "SET", "COMMENT ON"];
|
|
104
|
+
/**
|
|
105
|
+
* Explicitly blocked SQL patterns. These are DML or dangerous statements
|
|
106
|
+
* that should never appear as the leading keyword of a plan statement.
|
|
107
|
+
*
|
|
108
|
+
* Note: SELECT/INSERT inside CREATE FUNCTION bodies are safe because
|
|
109
|
+
* the leading keyword is CREATE FUNCTION, not SELECT/INSERT.
|
|
110
|
+
*/
|
|
111
|
+
export declare const BLOCKED_SQL_PATTERNS: ReadonlyArray<{
|
|
112
|
+
pattern: RegExp;
|
|
113
|
+
label: string;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Validate that all statements in the plan use allowed DDL types.
|
|
117
|
+
*
|
|
118
|
+
* Defense-in-depth: blocks DML (INSERT/UPDATE/DELETE) and dangerous SQL
|
|
119
|
+
* (DO $$, COPY, EXECUTE) that should never appear in a schema migration plan.
|
|
120
|
+
*
|
|
121
|
+
* @throws Error if any statement uses a blocked or unrecognized SQL type
|
|
122
|
+
*/
|
|
123
|
+
export declare function validateStatementTypes(plan: ValidatedPlan): void;
|
|
98
124
|
/**
|
|
99
125
|
* Validate that all hazards in the plan are in the allowed list.
|
|
100
126
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-validator.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/plan-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAM9E,eAAO,MAAM,gBAAgB;;;
|
|
1
|
+
{"version":3,"file":"plan-validator.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/plan-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAM9E,eAAO,MAAM,gBAAgB;;;iBAO3B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;iBAI9B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;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B,yrBA0CvB,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAUlF,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CA2ChE;AAMD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI,CAehG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-logic.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/retry-logic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"retry-logic.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/retry-logic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAU9E,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,OAAO,CAAC;AAClC,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,SAAuB,GAAG,MAAM,CAIhG;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAO/D;AAMD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKnD;AAMD;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;CAC/C;AAED;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAsHtB"}
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import path12__default, { join, dirname, resolve, basename, isAbsolute, relative
|
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import * as fs5 from 'fs';
|
|
7
7
|
import fs5__default, { existsSync, readFileSync, unlinkSync, rmSync, readdirSync, mkdtempSync, writeFileSync, mkdirSync, copyFileSync, createWriteStream, statSync, lstatSync, realpathSync, promises, accessSync, constants, chmodSync } from 'fs';
|
|
8
|
-
import { execSync, spawnSync,
|
|
8
|
+
import { execSync, spawnSync, spawn, execFileSync, exec } from 'child_process';
|
|
9
9
|
import { createCLILogger, cacheClear, CacheClearOutputSchema, CLIError, cachePrune, CachePruneOutputSchema, cacheStats, CacheStatsOutputSchema, cacheList, CacheListOutputSchema, cacheInvalidate, CacheInvalidateOutputSchema, syncFromProduction, SUPABASE_SYSTEM_SCHEMAS, dbGenerateDiagram, DbDiagramGenerateOutputSchema, createDbSnapshot, syncDatabase, emitDbPushFailureCapsule, emitDbAnnotations, writeDbPushStepSummary, exportDbReportJson, DbSyncOutputSchema, databasePaths, detectRequiredServices, formatDetectionResults, dbStart, DbLifecycleStartOutputSchema, dbStop, DbLifecycleStopOutputSchema, dbReset, DbLifecycleResetOutputSchema, dbValidateSchemas, DbSchemaValidateOutputSchema, DbSchemaRisksOutputSchema, dbDetectSchemaRisks, dbApplySchemas, DbSchemaApplyOutputSchema, dbGenerateTypes, DbSchemaGenerateOutputSchema, extractSchemaFilter, dbSeedInit, DbSeedInitOutputSchema, dbSeedValidate, DbSeedValidateOutputSchema, dbSeedGenerate, DbSeedGenerateOutputSchema, dbVerifySeeds, DbSeedVerifyOutputSchema, DbSnapshotCreateOutputSchema, restoreDbSnapshot, DbSnapshotRestoreOutputSchema, listDbSnapshots, DbSnapshotListOutputSchema, dbGeneratePgTapTests, DbTestGenOutputSchema, dbUpdateGoldenRecord, DbTestUpdateGoldenOutputSchema, repairRunaConfig, detectExistingInitConfig, initProject, validateInitResult, linkCliGlobally, LinkCliOutputSchema, unlinkCliGlobally, UnlinkCliOutputSchema, checkRepoStatus, CheckRepoStatusOutputSchema, enableTelemetry, disableTelemetry, getTelemetryStatus, uploadTelemetry, TelemetryUploadOutputSchema, runTest, TestRunOutputSchema, runTestService, TestServiceOutputSchema, runTestIntegration, TestIntegrationOutputSchema, runTestStatic, TestStaticOutputSchema, generateOwaspTop10Tests, TestOwaspGenerateOutputSchema, updateGoldenRecord, generateE2ETests, generateSecurityTests, generateUnitTests, generateApiTests, generateComponentTests, generateE2EScaffold, validateConfig, ValidateConfigOutputSchema, deploySchemaToProduction, WorkflowNotifyOutputSchema, devopsSync, workflowSync, validateInfrastructure, emitWorkflowValidateFailureCapsule, emitWorkflowAnnotations, writeWorkflowValidateStepSummary, exportWorkflowReportJson, WorkflowValidateInfrastructureOutputSchema, createSuccessEnvelopeSchema, CLI_CONTRACT_VERSION, BASE_PORTS, runChecks, RunCheckOutputSchema, formatDuration as formatDuration$1, GITHUB_API, loadRunaConfig, getClassificationForProfile, loadRunaConfigOrThrow, recordSchemaAudit, RecordSchemaAuditOutputSchema, createBackup, CreateBackupOutputSchema, listBackups, ListBackupsOutputSchema, getBackupMetadata, restoreBackup, RestoreBackupOutputSchema, deleteBackup, DeleteBackupOutputSchema, detectSchemaNames, resolveAvailablePorts, calculatePortOffset, dbSeedApply, writeDbSeedStepSummary, DbSeedApplyOutputSchema, emitDbSeedFailureCapsule, syncEnvironment, EnvSyncOutputSchema, detectDatabasePackage, findProjectRoot as findProjectRoot$1, TelemetryEnableOutputSchema, TelemetryDisableOutputSchema, TelemetryStatusOutputSchema, workflowNotify, DevOpsSyncOutputSchema, WorkflowSyncOutputSchema, formatCLIError, getStatusIcon as getStatusIcon$1, findWorkspaceRoot as findWorkspaceRoot$1, checkExtensionConfig, getPortsWithOffset, UpgradeTransaction, readRunaVersion, syncTemplates, SyncOutputSchema, DATABASE_PACKAGE_CANDIDATES, ErrorEnvelopeSchema, preCheckSync, findConflictFiles, TestUnitGenOutputSchema, TestE2EGenerateOutputSchema, TestSecurityGenOutputSchema, TestApiGenOutputSchema, TestComponentGenOutputSchema } from '@runa-ai/runa';
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
import fs9, { mkdir, writeFile, appendFile, readFile, rm, stat, realpath, cp, readdir, lstat } from 'fs/promises';
|
|
@@ -1161,7 +1161,7 @@ var CLI_VERSION, HAS_ADMIN_COMMAND;
|
|
|
1161
1161
|
var init_version = __esm({
|
|
1162
1162
|
"src/version.ts"() {
|
|
1163
1163
|
init_esm_shims();
|
|
1164
|
-
CLI_VERSION = "0.5.
|
|
1164
|
+
CLI_VERSION = "0.5.72";
|
|
1165
1165
|
HAS_ADMIN_COMMAND = false;
|
|
1166
1166
|
}
|
|
1167
1167
|
});
|
|
@@ -20454,8 +20454,8 @@ function releaseAdvisoryLock(_dbUrl, verbose) {
|
|
|
20454
20454
|
// src/commands/db/apply/helpers/plan-validator.ts
|
|
20455
20455
|
init_esm_shims();
|
|
20456
20456
|
var PlanHazardSchema = z.object({
|
|
20457
|
-
type: z.string().min(1),
|
|
20458
|
-
message: z.string()
|
|
20457
|
+
type: z.string().min(1).max(100).regex(/^[\w-]+$/),
|
|
20458
|
+
message: z.string().max(1e3)
|
|
20459
20459
|
});
|
|
20460
20460
|
var PlanStatementSchema = z.object({
|
|
20461
20461
|
index: z.number().int().nonnegative(),
|
|
@@ -20677,6 +20677,93 @@ function filterIdempotentProtectedStatements(plan, protectedTables, protectedObj
|
|
|
20677
20677
|
removedStatements: removed
|
|
20678
20678
|
};
|
|
20679
20679
|
}
|
|
20680
|
+
var ALLOWED_DDL_PREFIXES = [
|
|
20681
|
+
"CREATE TABLE",
|
|
20682
|
+
"ALTER TABLE",
|
|
20683
|
+
"DROP TABLE",
|
|
20684
|
+
"CREATE INDEX",
|
|
20685
|
+
"CREATE UNIQUE INDEX",
|
|
20686
|
+
"DROP INDEX",
|
|
20687
|
+
"CREATE SCHEMA",
|
|
20688
|
+
"ALTER SCHEMA",
|
|
20689
|
+
"DROP SCHEMA",
|
|
20690
|
+
"CREATE FUNCTION",
|
|
20691
|
+
"CREATE OR REPLACE FUNCTION",
|
|
20692
|
+
"ALTER FUNCTION",
|
|
20693
|
+
"DROP FUNCTION",
|
|
20694
|
+
"CREATE TRIGGER",
|
|
20695
|
+
"ALTER TRIGGER",
|
|
20696
|
+
"DROP TRIGGER",
|
|
20697
|
+
"CREATE VIEW",
|
|
20698
|
+
"CREATE OR REPLACE VIEW",
|
|
20699
|
+
"CREATE MATERIALIZED VIEW",
|
|
20700
|
+
"ALTER VIEW",
|
|
20701
|
+
"DROP VIEW",
|
|
20702
|
+
"DROP MATERIALIZED VIEW",
|
|
20703
|
+
"CREATE TYPE",
|
|
20704
|
+
"ALTER TYPE",
|
|
20705
|
+
"DROP TYPE",
|
|
20706
|
+
"CREATE SEQUENCE",
|
|
20707
|
+
"ALTER SEQUENCE",
|
|
20708
|
+
"DROP SEQUENCE",
|
|
20709
|
+
"CREATE POLICY",
|
|
20710
|
+
"ALTER POLICY",
|
|
20711
|
+
"DROP POLICY",
|
|
20712
|
+
"CREATE ROLE",
|
|
20713
|
+
"ALTER ROLE",
|
|
20714
|
+
"DROP ROLE",
|
|
20715
|
+
"CREATE EXTENSION",
|
|
20716
|
+
"ALTER EXTENSION",
|
|
20717
|
+
"DROP EXTENSION",
|
|
20718
|
+
"GRANT",
|
|
20719
|
+
"REVOKE",
|
|
20720
|
+
"SET",
|
|
20721
|
+
"COMMENT ON"
|
|
20722
|
+
];
|
|
20723
|
+
var BLOCKED_SQL_PATTERNS = [
|
|
20724
|
+
{ pattern: /^\s*INSERT\s+INTO\b/i, label: "INSERT" },
|
|
20725
|
+
{ pattern: /^\s*UPDATE\s+\S/i, label: "UPDATE" },
|
|
20726
|
+
{ pattern: /^\s*DELETE\s+FROM\b/i, label: "DELETE" },
|
|
20727
|
+
{ pattern: /^\s*TRUNCATE\b/i, label: "TRUNCATE" },
|
|
20728
|
+
{ pattern: /^\s*COPY\b/i, label: "COPY" },
|
|
20729
|
+
{ pattern: /^\s*DO\s+\$/i, label: "DO (anonymous block)" },
|
|
20730
|
+
{ pattern: /^\s*EXECUTE\b/i, label: "EXECUTE" },
|
|
20731
|
+
{ pattern: /^\s*SELECT\b/i, label: "SELECT" },
|
|
20732
|
+
{ pattern: /^\s*CALL\b/i, label: "CALL" }
|
|
20733
|
+
];
|
|
20734
|
+
function validateStatementTypes(plan) {
|
|
20735
|
+
if (plan.totalStatements === 0) return;
|
|
20736
|
+
const violations = [];
|
|
20737
|
+
for (const stmt of plan.statements) {
|
|
20738
|
+
const normalized = stmt.sql.replace(/\s+/g, " ").trim();
|
|
20739
|
+
const upper = normalized.toUpperCase();
|
|
20740
|
+
for (const blocked of BLOCKED_SQL_PATTERNS) {
|
|
20741
|
+
if (blocked.pattern.test(stmt.sql)) {
|
|
20742
|
+
violations.push(
|
|
20743
|
+
`Statement ${stmt.index}: Blocked SQL type "${blocked.label}" \u2014 ${normalized.slice(0, 80)}`
|
|
20744
|
+
);
|
|
20745
|
+
break;
|
|
20746
|
+
}
|
|
20747
|
+
}
|
|
20748
|
+
if (violations.length > 0 && violations[violations.length - 1].startsWith(`Statement ${stmt.index}:`)) {
|
|
20749
|
+
continue;
|
|
20750
|
+
}
|
|
20751
|
+
const isAllowed = ALLOWED_DDL_PREFIXES.some((prefix) => upper.startsWith(prefix));
|
|
20752
|
+
if (!isAllowed) {
|
|
20753
|
+
violations.push(
|
|
20754
|
+
`Statement ${stmt.index}: Unrecognized SQL type \u2014 ${normalized.slice(0, 80)}`
|
|
20755
|
+
);
|
|
20756
|
+
}
|
|
20757
|
+
}
|
|
20758
|
+
if (violations.length > 0) {
|
|
20759
|
+
throw new Error(
|
|
20760
|
+
`Plan contains non-DDL or dangerous SQL statements:
|
|
20761
|
+
${violations.map((v) => ` - ${v}`).join("\n")}
|
|
20762
|
+
|
|
20763
|
+
Only DDL statements (CREATE, ALTER, DROP, GRANT, REVOKE, SET, COMMENT ON) are allowed in schema migration plans.`
|
|
20764
|
+
);
|
|
20765
|
+
}
|
|
20766
|
+
}
|
|
20680
20767
|
function validatePlanForExecution(plan, allowedHazardTypes) {
|
|
20681
20768
|
if (plan.totalStatements === 0) return;
|
|
20682
20769
|
const allHazards = plan.statements.flatMap((s) => s.hazards);
|
|
@@ -21503,6 +21590,7 @@ async function executePlanSqlWithRetry(dbUrl, initialPlanSql, verbose, config) {
|
|
|
21503
21590
|
if (config?.allowedHazardTypes) {
|
|
21504
21591
|
validatePlanForExecution(plan, config.allowedHazardTypes);
|
|
21505
21592
|
}
|
|
21593
|
+
validateStatementTypes(plan);
|
|
21506
21594
|
if (verbose) {
|
|
21507
21595
|
logger5.debug(`Plan validated: ${plan.totalStatements} statement(s)`);
|
|
21508
21596
|
}
|
|
@@ -22468,60 +22556,42 @@ function verifyDataIntegrity(dbUrl, schemasDir, preApplyCounts, verbose, allowDa
|
|
|
22468
22556
|
logger8.debug(`Data integrity check passed (${preApplyCounts.size} table(s) verified)`);
|
|
22469
22557
|
}
|
|
22470
22558
|
}
|
|
22471
|
-
async function
|
|
22559
|
+
async function applyWithRetry(dbUrl, schemasDir, includeSchemas, input3, planOutput, hazards, protectedTables, protectedObjects, tempDbDsn, pgSchemaDiffDir) {
|
|
22472
22560
|
logger8.step("Applying schema changes (plan+psql)...");
|
|
22473
|
-
const
|
|
22474
|
-
|
|
22475
|
-
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22481
|
-
|
|
22482
|
-
|
|
22483
|
-
|
|
22484
|
-
|
|
22485
|
-
|
|
22486
|
-
rePlanFn: () => {
|
|
22487
|
-
const { planOutput: freshPlan } = executePgSchemaDiffPlan(
|
|
22488
|
-
dbUrl,
|
|
22489
|
-
pgSchemaDiffDir ?? schemasDir,
|
|
22490
|
-
includeSchemas,
|
|
22491
|
-
input3.verbose,
|
|
22492
|
-
{ tempDbDsn }
|
|
22493
|
-
);
|
|
22494
|
-
if (!freshPlan.trim() || freshPlan.includes("No changes")) {
|
|
22495
|
-
return null;
|
|
22496
|
-
}
|
|
22497
|
-
return freshPlan;
|
|
22498
|
-
}
|
|
22499
|
-
});
|
|
22500
|
-
if (!result.success) {
|
|
22501
|
-
throw result.error || new Error("Migration failed");
|
|
22502
|
-
}
|
|
22503
|
-
if (input3.verbose && result.attempts > 0) {
|
|
22504
|
-
logger8.debug(
|
|
22505
|
-
`Retry metrics: ${result.attempts} attempts, ${result.totalWaitMs}ms total wait`
|
|
22506
|
-
);
|
|
22507
|
-
}
|
|
22508
|
-
logger8.success("Schema changes applied");
|
|
22509
|
-
return {
|
|
22510
|
-
sql: planOutput,
|
|
22511
|
-
hazards,
|
|
22512
|
-
applied: true,
|
|
22513
|
-
retryAttempts: result.attempts,
|
|
22514
|
-
retryWaitMs: result.totalWaitMs
|
|
22515
|
-
};
|
|
22516
|
-
} finally {
|
|
22517
|
-
try {
|
|
22518
|
-
releaseAdvisoryLock(dbUrl, input3.verbose);
|
|
22519
|
-
} catch (lockError) {
|
|
22520
|
-
logger8.warn(
|
|
22521
|
-
`Failed to release advisory lock: ${lockError instanceof Error ? lockError.message : "Unknown error"}`
|
|
22561
|
+
const allowedHazardTypes = buildAllowedHazards(input3);
|
|
22562
|
+
const result = await executePlanSqlWithRetry(dbUrl, planOutput, input3.verbose, {
|
|
22563
|
+
maxDelayMs: input3.maxLockWaitMs,
|
|
22564
|
+
allowedHazardTypes,
|
|
22565
|
+
protectedTables,
|
|
22566
|
+
protectedObjects,
|
|
22567
|
+
rePlanFn: () => {
|
|
22568
|
+
const { planOutput: freshPlan } = executePgSchemaDiffPlan(
|
|
22569
|
+
dbUrl,
|
|
22570
|
+
pgSchemaDiffDir ?? schemasDir,
|
|
22571
|
+
includeSchemas,
|
|
22572
|
+
input3.verbose,
|
|
22573
|
+
{ tempDbDsn }
|
|
22522
22574
|
);
|
|
22575
|
+
if (!freshPlan.trim() || freshPlan.includes("No changes")) {
|
|
22576
|
+
return null;
|
|
22577
|
+
}
|
|
22578
|
+
return freshPlan;
|
|
22523
22579
|
}
|
|
22580
|
+
});
|
|
22581
|
+
if (!result.success) {
|
|
22582
|
+
throw result.error || new Error("Migration failed");
|
|
22524
22583
|
}
|
|
22584
|
+
if (input3.verbose && result.attempts > 0) {
|
|
22585
|
+
logger8.debug(`Retry metrics: ${result.attempts} attempts, ${result.totalWaitMs}ms total wait`);
|
|
22586
|
+
}
|
|
22587
|
+
logger8.success("Schema changes applied");
|
|
22588
|
+
return {
|
|
22589
|
+
sql: planOutput,
|
|
22590
|
+
hazards,
|
|
22591
|
+
applied: true,
|
|
22592
|
+
retryAttempts: result.attempts,
|
|
22593
|
+
retryWaitMs: result.totalWaitMs
|
|
22594
|
+
};
|
|
22525
22595
|
}
|
|
22526
22596
|
var ROLE_PASSWORD_CONFIGS = [
|
|
22527
22597
|
{
|
|
@@ -22760,6 +22830,12 @@ ${content}`;
|
|
|
22760
22830
|
}
|
|
22761
22831
|
}
|
|
22762
22832
|
const includeSchemas = detectAppSchemas(schemasDir, input3.verbose);
|
|
22833
|
+
const lockAcquired = await acquireAdvisoryLock(dbUrl, input3.verbose);
|
|
22834
|
+
if (!lockAcquired) {
|
|
22835
|
+
throw new Error(
|
|
22836
|
+
"Could not acquire migration lock. Another migration may be running. Wait for it to complete or manually release the lock."
|
|
22837
|
+
);
|
|
22838
|
+
}
|
|
22763
22839
|
cleanPartitionAclsForPgSchemaDiff(dbUrl, includeSchemas, input3.verbose);
|
|
22764
22840
|
const { planOutput } = executePgSchemaDiffPlan(
|
|
22765
22841
|
dbUrl,
|
|
@@ -22847,7 +22923,7 @@ ${content}`;
|
|
|
22847
22923
|
}
|
|
22848
22924
|
}
|
|
22849
22925
|
const preApplyCounts = getTableRowEstimates(dbUrl, schemasDir, input3.verbose);
|
|
22850
|
-
const applyResult = await
|
|
22926
|
+
const applyResult = await applyWithRetry(
|
|
22851
22927
|
dbUrl,
|
|
22852
22928
|
schemasDir,
|
|
22853
22929
|
includeSchemas,
|
|
@@ -22867,6 +22943,13 @@ ${content}`;
|
|
|
22867
22943
|
dataViolations: dataViolationCount > 0 ? dataViolationCount : void 0
|
|
22868
22944
|
};
|
|
22869
22945
|
} finally {
|
|
22946
|
+
try {
|
|
22947
|
+
releaseAdvisoryLock(dbUrl, input3.verbose);
|
|
22948
|
+
} catch (lockError) {
|
|
22949
|
+
logger8.warn(
|
|
22950
|
+
`Failed to release advisory lock: ${lockError instanceof Error ? lockError.message : "Unknown error"}`
|
|
22951
|
+
);
|
|
22952
|
+
}
|
|
22870
22953
|
if (shadowDb) {
|
|
22871
22954
|
try {
|
|
22872
22955
|
await shadowDb.cleanup();
|