deploro 0.8.0 → 0.9.0
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/index.js +31 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -679,6 +679,36 @@ async function dbDropTableCommand(tableName, opts) {
|
|
|
679
679
|
await apiRequest(`/api/db/tables/${encodeURIComponent(tableName)}`, { method: "DELETE" });
|
|
680
680
|
console.log(`\u2713 Table "${tableName}" dropped`);
|
|
681
681
|
}
|
|
682
|
+
var SEVERITY_LABEL = {
|
|
683
|
+
error: "SECURITY",
|
|
684
|
+
warning: "WARNING",
|
|
685
|
+
info: "SUGGEST"
|
|
686
|
+
};
|
|
687
|
+
async function dbAdvisorsCommand(opts) {
|
|
688
|
+
const config = requireProject();
|
|
689
|
+
const data = await apiRequestNoProject(
|
|
690
|
+
`/api/projects/${config.projectId}/database/advisors`
|
|
691
|
+
);
|
|
692
|
+
if (opts.json) {
|
|
693
|
+
json(data.findings);
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (data.findings.length === 0) {
|
|
697
|
+
console.log("\u2713 No problems found. RLS, primary keys and foreign-key indexes all look right.");
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
for (const f of data.findings) {
|
|
701
|
+
console.log(`
|
|
702
|
+
[${SEVERITY_LABEL[f.severity]}] ${f.table}: ${f.title}`);
|
|
703
|
+
console.log(` ${f.detail}`);
|
|
704
|
+
if (f.fix) console.log(` Fix: ${f.fix}`);
|
|
705
|
+
}
|
|
706
|
+
const errors = data.findings.filter((f) => f.severity === "error").length;
|
|
707
|
+
console.log(`
|
|
708
|
+
${data.findings.length} finding${data.findings.length === 1 ? "" : "s"}${errors ? `, ${errors} security` : ""}.`);
|
|
709
|
+
console.log("Fix SQL is never run for you. Apply it as a migration (deploro migrate).");
|
|
710
|
+
if (errors) process.exitCode = 1;
|
|
711
|
+
}
|
|
682
712
|
|
|
683
713
|
// src/commands/auth.ts
|
|
684
714
|
function isPatToken(accessToken) {
|
|
@@ -2329,6 +2359,7 @@ db.command("info").description("Show database status and how to reach it from a
|
|
|
2329
2359
|
db.command("tables").description("List tables in the active project").action(dbTablesCommand);
|
|
2330
2360
|
db.command("rows <table>").description("List rows in a table").option("--limit <n>", "Rows per page (max 200)", "20").option("--page <n>", "Page number", "1").option("--json", "Output raw JSON").action(dbRowsCommand);
|
|
2331
2361
|
db.command("query <sql>").description("Run a read-only SQL query (project admin)").option("--param <value>", "Bind a value to $1, $2, ... in order (repeatable)", (v, prev) => [...prev, v], []).option("--json", "Output raw JSON").action(dbQueryCommand);
|
|
2362
|
+
db.command("advisors").description("Run database checks: RLS exposure, missing policies, primary keys, foreign-key indexes").option("--json", "Output raw JSON").action(dbAdvisorsCommand);
|
|
2332
2363
|
db.command("schema <table>").description("Show schema for a table").action(dbSchemaCommand);
|
|
2333
2364
|
db.command("insert <table>").description("Insert a row").requiredOption("--data <json>", "Row data as a JSON object").action(dbInsertCommand);
|
|
2334
2365
|
db.command("update <table> <id>").description("Update a row by id").requiredOption("--data <json>", "Fields to update as a JSON object").action(dbUpdateCommand);
|
package/package.json
CHANGED