mirror of
https://github.com/Dvorinka/Primora.git
synced 2026-10-28 07:41:23 +00:00
Stress-test remediation across MCP, CLI, and backend:
- primora_vault_exec rewritten as an allow-list (was deny-list):
colon-form single-token commands bypassed it, leaking every vault
secret; verbatim env-name injection allowed NODE_OPTIONS=--require
host RCE. Now fixed read-mostly command set, arg/path deny regex,
strict env-name grammar, loader-hook name blocklist. All prior
bypasses verified denied; allowed commands still inject.
- SSRF: webhook/job URL validation now blocks cloud metadata IPs
(169.254.169.254, fd00:ec2::254) inside the link-local allowance
and non-canonical IP encodings (decimal/hex bare hosts) smuggled
as "docker service names".
- Path params encodeURIComponent in all client consumers — encodeURI
left ?#& intact, smuggling query segments through {name} params.
- primora_upload_object strict-validates contentBase64 — Buffer.from
silently dropped invalid chars.
- MCP no-creds startup degrades instead of crashing mid-handshake.
- GET /api/v1/context — API-key self-discovery; fixes the CLI dead
end (login --api-key validates the key + seeds org/project,
use/context/whoami work under key auth).
- CLI: unknown commands / bare group exit 1 with hints; mri numeric
coercion reversed via raw-argv restore (007 stays "007");
login --json; orgs:rm / projects:rm / buckets:rm behind --yes;
fetch-failed errors name the cause.
- Error hygiene: pgx.ErrNoRows -> 404, pgconn codes -> clean
400/409 without SQLSTATE leaks, validator failures formatted,
services.InputError maps input faults to 400 (webhook URL/event
errors were 500s), presign on local driver -> 400.
- Webhook events accept wildcard patterns (*, ns.*, custom.*)
matched via SQL LIKE — client-published events can be webhooked.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
import { OrganizationsService, PlatformService } from "@primora/api-client";
|
|
|
|
import { loadConfig } from "../config.js";
|
|
import { configureClient, requireAuth } from "../http.js";
|
|
import { isJson, printJson, printTable, success } from "../out.js";
|
|
|
|
export async function cmdOrgsList(options: { json?: boolean }): Promise<void> {
|
|
const cfg = loadConfig();
|
|
requireAuth(cfg);
|
|
configureClient(cfg);
|
|
|
|
const me = await PlatformService.getMe();
|
|
if (isJson(options)) {
|
|
printJson(me.organizations);
|
|
return;
|
|
}
|
|
printTable(
|
|
["ID", "SLUG", "NAME", "ROLE"],
|
|
me.organizations.map((o) => [o.id, o.slug, o.name, o.membershipRole]),
|
|
);
|
|
}
|
|
|
|
export async function cmdOrgsCreate(
|
|
name: string,
|
|
options: { slug?: string; json?: boolean },
|
|
): Promise<void> {
|
|
const cfg = loadConfig();
|
|
requireAuth(cfg);
|
|
configureClient(cfg);
|
|
|
|
const slug = options.slug ?? name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
const org = await OrganizationsService.createOrganization({
|
|
requestBody: { name, slug },
|
|
});
|
|
if (isJson(options)) {
|
|
printJson(org);
|
|
return;
|
|
}
|
|
success(`Organization "${org.name}" created (${org.slug})`);
|
|
}
|
|
|
|
export async function cmdOrgsRemove(
|
|
orgRef: string,
|
|
options: { yes?: boolean; json?: boolean },
|
|
): Promise<void> {
|
|
const cfg = loadConfig();
|
|
requireAuth(cfg);
|
|
configureClient(cfg);
|
|
|
|
let organizationId = orgRef;
|
|
if (!isUuid(orgRef)) {
|
|
const me = await PlatformService.getMe();
|
|
const found = me.organizations.find((o) => o.id === orgRef || o.slug === orgRef || o.name === orgRef);
|
|
if (!found) throw new Error(`Organization "${orgRef}" not found — pass its id directly.`);
|
|
organizationId = found.id;
|
|
}
|
|
await confirmOrAbort(`Delete organization "${orgRef}"? Every project inside goes with it.`, options.yes);
|
|
await OrganizationsService.deleteOrganization({ organizationId });
|
|
if (isJson(options)) {
|
|
printJson({ deleted: organizationId });
|
|
} else {
|
|
success(`deleted organization ${orgRef}`);
|
|
}
|
|
}
|
|
|
|
function isUuid(v: string): boolean {
|
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v);
|
|
}
|