mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-01 23:59:50 +08:00
* feat(auth): integrate Google One Tap across cloud backend, Studio web, and desktop handoff (#1047) * feat(auth): integrate Google One Tap across cloud backend, desktop handoff, and studio web * fix(auth): address L1 review findings for One Tap S2S, desktop handoff, and cloud tracking * fix(auth): resolve all round-2 L1 review blockers for Google One Tap * fix(motion): harden One Tap K8s egress, atomic provenance, post-commit logout barrier, consent, tracking retry, and loopback CSP * fix(motion): propagate AMR sessionProof across One Tap, OIDC, and desktop handoff-ticket flows * fix(motion): close R4 L1 blockers (post-proof logout barrier, upgrade-handoff 503 fail-closed, atomic getdel, server consent cookie) * fix(motion): enforce One Tap logout revocation inside resolveBrowserSession and block unbound Pricing redirect on active-session 401/403 * fix(motion): align One Tap binding revocation TTL to full 7-day session lifetime and keep upgrade-handoff 401 fail-closed on reload * fix(motion): fail closed on Redis/DB errors in One Tap revocation check and never downgrade expired om_session on upgrade-handoff * fix(motion): retain One Tap revocation binding for full session TTL and bind upgrade-handoff 503 retries to requireAuth/expectedAppUserId * fix(motion): cryptographically bind upgrade-handoff 503 retries to originating session before DB/AMR enrichment * fix(motion): bind signed-in PricingEntry and 503 reload cookie to originating session/account and guard readSessionProof errors * fix(motion): redirect unbound upgrade-handoff 503 via same-origin 303 to session-bound URL so F5 reloads never lose binding * fix(k8s): align AMR One Tap internal URL and NetworkPolicy with nexu namespace * fix(ci): narrow desktop-handoff union types and remove false-positive secret/internal-link hits in One Tap files * fix(studio): align One Tap 2s delay, SHOW-04 reload recovery, and ERR-06/07 failure CTA * fix(studio): align One Tap banned account copy with standalone login page (OPEND-5763) * fix(auth): address PR #1047 review findings (upgrade-handoff recovery, CSP, unified tracking privacy & rate limit, source scan) * fix(auth): gate upgrade-handoff on isOneTapConfigured, decouple tracking toggle from deviceIdConsented, and bound logout-epoch map * fix(ci): resolve backend typecheck, dock short-host floor, ci-scope, and source privacy scan (cherry picked from commit19a75ca0ec) * test(mcp): expect the connected-environment line appended to server instructions initialize instructions, but the registry discovery test still compared the whole string against the registry-only guide. * test(auth): isolate One Tap route tests from the runner's telemetry opt-out CI exports OPENMOTION_TELEMETRY=0 for the cloud job, which disables the PostHog dispatcher and locks tracking preferences, so the One Tap tracking cases failed only in CI. Clear OPENMOTION_TELEMETRY and DO_NOT_TRACK for the suite and restore them afterwards. Ported onto main without #1066. Adaptations to main: logout keeps main's server-side OIDC end-session and never returns endSessionUrl, so the od_onetap_suppress post-logout redirect hint and OIDC_POST_LOGOUT_REDIRECT_URI are dropped (client-side One Tap suppression still runs on confirmed sign-out) and main's oidcIdTokenCacheKey replaces the separate id_token store. Browser telemetry stays on main's createCloudTracking pipeline with deployment-locked preferences; the separate PostHog dispatcher and per-user tracking toggle are dropped, while attested app_user_id filtering, the tracking attestation cookie and device-ID consent are added to main's /motion-api/tracking (createApiApp accepts an optional cloudTracking handle for tests). The upgrade-handoff link builder moves into main's buildSubscriptionUrl, and the desktop loopback response deferral follows main's nullable-server attempt lifecycle. --------- Co-authored-by: heggria <bshengtao@gmail.com> (cherry picked from commit4616728e07) * fix(studio): report the One Tap document CSP instead of enforcing it main serves Studio documents without a CSP and still embeds third-party frames that the One Tap allowlist does not cover (for example external playable games such as littleprince.dev in the game catalog). Enforcing frame-src would block them. GIS does not need a CSP, so ship the policy as Content-Security-Policy-Report-Only and keep Permissions-Policy and COOP enforced; enforce the CSP once every embedded frame source is listed. * fix(auth): keep main's tracking identity and optional One Tap manifest refs - /motion-api/tracking no longer stamps the session app_user_id onto events that did not carry one; those events stay installation-scoped exactly as on main. Attested One Tap attribution is unchanged. - deploy/k8s: the One Tap internal URL/token refs are optional so clusters without One Tap still start (the API already fails closed), and the ingress no longer adds a configuration-snippet, which default ingress-nginx admission rejects and which duplicated headers the API already sets on Studio documents. * fix(studio): create the browser tracker on first use AccountSettings now imports googleOneTap, which imports the Studio tracking module. That module created the browser tracker and attached window/document listeners at import time, so node-environment suites that reach AccountSettings (compositionStackExport, agentToolsExport, PropertyPanel, AssetsTab and others) failed with 'window is not defined'. Create the tracker and its flush listeners on first use; nothing can be pending before then, so browser behavior is unchanged. * refactor(tracking): drop the unused sender channel option No caller sets the PostHog sender's channel since the cloud API hands browser batches to the cloud tracking pipeline, so the option only suggested a cloud path that does not exist. Sender events keep the standalone channel. * refactor(auth): share the metrics consent cookie contract The device-ID consent cookie name and its granted/denied values were spelled separately in the auth routes, the tracking API and the tests. Export them from the session module next to the other auth cookies and use the shared constants everywhere, so the One Tap attribution gate and the consent writer cannot drift apart. * fix(tracking): use the session app user id before AMR enrichment Signed-in browser tracking batches looked up the AMR identity for every request even though the session membership already carries the projected AMR app user id. Attribute from the membership first and call verifyAndEnrichAuthContext only for sessions without a projected app user id. A failed fallback still treats the batch as guest telemetry. * fix(auth): render upgrade notices with the design system The billing handoff notice pages carried their own dark-only palette and button styles. Load the shared /design-system/ui.css on a data-motion-ui root instead, so the pages follow the system light/dark preference, and render the actions as ui-button / ui-button--primary controls. Only page layout stays local and it references design-system tokens. The notice CSP now allows the same-origin stylesheet and the fonts its @font-face rules load (style-src 'self' 'unsafe-inline'; font-src 'self') and keeps default-src 'none' for everything else. * fix(auth): honor One Tap session proof expiry The One Tap exchange stored AMR's session proof for the full Motion session lifetime and ignored sessionProofExpiresAt, so an expired proof kept being sent to the handoff-ticket endpoint and every rejection showed the retryable 503 page, which retrying can never fix. Store the proof for at most the time AMR advertises, capped by the session lifetime; an unparseable expiry falls back to the session lifetime and an expiry in the past stores no proof. When the handoff ticket is rejected terminally (401 SESSION_PROOF_INVALID for an invalid, expired or mismatched proof, or 404 USER_NOT_FOUND), drop the stored proof and return the existing REAUTH_REQUIRED fresh sign-in path. A banned or frozen account (403 ACCOUNT_BANNED / ACCOUNT_FROZEN) gets the 403 account notice. Network failures, timeouts, 5xx responses and a 401 without a proof code (internal token rejected) keep the session-bound retry page and the stored proof. * refactor(auth): stop issuing the tracking attestation cookie The signed om_track_att cookie let /motion-api/tracking accept a browser-supplied app_user_id that the server had attested. Since the merge with the cloud tracking overhaul the endpoint resolves the user from the live session and rejects any packet that carries a user id, so nothing reads the cookie any more. Stop setting it on OIDC callback, One Tap sign-in, desktop handoff and /auth/me, and remove its signing helpers. The derived secret stays: it still binds upgrade-handoff retry URLs to the originating session. * refactor(auth): share one OpenDesign handoff URL guard The browser upgrade handoff and the desktop Pricing handoff each carried a line-for-line copy of the check that decides whether an AMR-issued handoff URL may be followed. Export isSafeOpenDesignHandoffUrl from the desktop handoff module next to the other handoff helpers and use it from both. The rules are unchanged: no control characters or credentials, an origin from OPENDESIGN_API_URL, OPENDESIGN_CONSOLE_URL or OPENDESIGN_PRICING_URL, and https unless one of those is configured as http. Add unit coverage for the shared guard. * refactor(auth): share the One Tap session proof cache key Session revocation deleted the stored AMR session proof through a string literal while the auth routes built the same key with a local helper. Export oneTapSessionProofCacheKey from the session module beside the other One Tap cache keys and use it for saving, reading and deleting the proof and in the route tests. * refactor(auth): drop the unwired One Tap telemetry hook AuthRoutesDeps.onOneTapTelemetry was called from seven places in the One Tap exchange, but no caller ever supplied it and the onetap_* events are registered with the Studio as their only producer, which already reports them from the browser. Remove the field and its call sites. * refactor(auth): remove the dormant device-ID consent path No product surface ever granted the metrics consent, so the consent route, shared cookie constants and Studio consent reader only kept an unreachable device-ID forwarding branch alive. - Delete POST /motion-api/tracking/consent and shared/metrics-consent.ts; the tracking route is back to main's shape. - The One Tap attribution sanitizer now always drops odDeviceId and odDeviceIdConsent, whatever the client claims. - Studio no longer reads od_device_id from the URL, localStorage or the od_attr cookie, never persists it and never sends it in odEntry; ref, UTM and other od_* attribution are unchanged. * refactor(studio): reuse the shared plan-tier normalizer onetap_login_success normalized planTier with a local copy of the tier list. Use normalizeDesktopHandoffPlanTier from shared/desktop-auth-handoff.ts instead so Studio, the desktop shell and the server share one tier list. Output is unchanged: the five tiers map to themselves and anything else maps to 'unknown'. --------- Co-authored-by: open-design-crew[bot] <299007234+open-design-crew[bot]@users.noreply.github.com> Co-authored-by: heggria <bshengtao@gmail.com>
208 lines
13 KiB
JavaScript
208 lines
13 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { createHash } from 'node:crypto';
|
|
import { createReadStream } from 'node:fs';
|
|
import { createGunzip } from 'node:zlib';
|
|
import { cp, lstat, mkdir, mkdtemp, readFile, readdir, rm, writeFile, chmod } from 'node:fs/promises';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { download, runFile, sha256, writeJSON } from '../../scripts/runtime-assets.mjs';
|
|
import { checkReleaseVersion, releaseTemplateEnvironment } from '../../scripts/release-version.mjs';
|
|
|
|
const root = fileURLToPath(new URL('../../', import.meta.url));
|
|
export const scannerVersion = '8.30.1';
|
|
const scannerHashes = {
|
|
'linux_x64': '551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb',
|
|
'darwin_arm64': 'b40ab0ae55c505963e365f271a8d3846efbc170aa17f2607f13df610a9aeb6a5',
|
|
};
|
|
|
|
export async function installScanner(directory) {
|
|
const target = `${process.platform}_${process.arch}`;
|
|
assert(scannerHashes[target], 'Use the supported Linux x64 or Mac arm64 scanner runner');
|
|
await mkdir(directory, { recursive: true });
|
|
const archive = path.join(directory, 'gitleaks.tar.gz');
|
|
await download({ url: `https://github.com/gitleaks/gitleaks/releases/download/v${scannerVersion}/gitleaks_${scannerVersion}_${target}.tar.gz`, sha256: scannerHashes[target] }, archive);
|
|
await runFile('tar', ['-xzf', archive, '-C', directory, 'gitleaks']);
|
|
const binary = path.join(directory, 'gitleaks'); await chmod(binary, 0o755);
|
|
return binary;
|
|
}
|
|
|
|
// tar terminates its listings with LF on Linux and CRLF on Windows, so every line is normalised
|
|
// before the safety rules run; a stray \r must not read as a forbidden control character.
|
|
// tar terminates its listing with CRLF on Windows, so a trailing CR is removed per line before the
|
|
// safety rules run. Only the terminator is stripped: a CR inside an entry name is still a control
|
|
// character, and the assertions below have to reject it.
|
|
const listingLines = listing => listing.trim().split('\n').map(line => line.endsWith('\r') ? line.slice(0, -1) : line);
|
|
|
|
export function archivePaths(listing) {
|
|
const names = listingLines(listing);
|
|
assert(names.length && names.length < 20_000, 'Archive has too many entries');
|
|
for (const name of names) {
|
|
assert(name && !/[\\\x00-\x1f]/.test(name) && !path.posix.isAbsolute(name) && !/^[a-z]:/i.test(name)
|
|
&& !name.split('/').includes('..'), 'Unsafe archive entry');
|
|
}
|
|
return names;
|
|
}
|
|
|
|
export async function unpackChecked(archive, directory, run = runFile) {
|
|
assert((await lstat(archive)).size < 150 * 1024 * 1024, 'Archive exceeds release size limit');
|
|
let expanded = 0;
|
|
for await (const chunk of createReadStream(archive).pipe(createGunzip())) {
|
|
expanded += chunk.length; assert(expanded < 350 * 1024 * 1024, 'Expanded archive exceeds release size limit');
|
|
}
|
|
archivePaths(await run('tar', ['-tzf', archive]));
|
|
const details = listingLines(await run('tar', ['-tvzf', archive]));
|
|
assert(details.every(line => /^[-d]/.test(line)), 'Archive links and special files are forbidden');
|
|
await mkdir(directory, { recursive: true });
|
|
await run('tar', ['-xzf', archive, '-C', directory]);
|
|
}
|
|
|
|
export function privacyFindings(name, text, kind = 'source') {
|
|
const findings = [], add = rule => findings.push({ path: name, rule });
|
|
// Public DEV routing and synthetic redaction fixtures are intentional, not credentials or employee paths.
|
|
if (name === 'prism-templates.ts' || name === './prism-templates.ts') text = text.replace(/https:\/\/r\.powerformer\.net/g, 'https://dev.example.invalid');
|
|
if (kind === 'source') {
|
|
if (name === 'desktop/src/auth-handoff.ts' || name === './desktop/src/auth-handoff.ts') {
|
|
text = text.replace(/https:\/\/open-design\.powerformer\.net\/pricing(?=['"\s`]|$)/g, 'https://test.example.invalid/pricing');
|
|
}
|
|
if (name === 'desktop/tests/one-tap-handoff.test.mjs' || name === './desktop/tests/one-tap-handoff.test.mjs') {
|
|
text = text.replace(/https:\/\/(?:motion\.open-design\.powerformer\.net|open-design\.powerformer\.net\/pricing)(?=['"\s`]|$)/g, 'https://test.example.invalid/pricing');
|
|
}
|
|
const fixtures = {
|
|
'studio/src/components/feedback/projectProvenance.test.ts': /\/Users\/me\/x/g,
|
|
'studio/src/player/store/previewQualitySlice.test.ts': /\/Users\/a\/film\.mp3/g,
|
|
'studio/src/telemetry/breadcrumbs.test.ts': /\/Users\/someone\/(?:private\/path\.html|project\.ts)/g,
|
|
};
|
|
if (fixtures[name]) text = text.replace(fixtures[name], '/synthetic/redaction-fixture');
|
|
}
|
|
if (/(?:^|\/)(?:outputs|research|node_modules|\.artifacts|\.motion-data(?:-dev)?)(?:\/|$)/.test(name)
|
|
|| /(?:^|\/)(?:\.npmrc|\.DS_Store|id_rsa|id_ed25519)$/.test(name)
|
|
|| /\.(?:log|pem|key|p12|pfx)$/.test(name)) add('private-file');
|
|
if (/(?:^|\/)\.env(?:\.|$)/.test(name) && !(kind === 'source' && /(?:^|\/)\.env\.(?:example|development)$/.test(name))) add('environment-file');
|
|
// Only the owner-approved public Feishu invitation in the product READMEs, the shared community link and its
|
|
// bundled Studio asset is exempt. Pin the complete URL by digest so adjacent private URLs and changed invitations fail.
|
|
const publicCommunityFiles = ['README.md', 'README.zh-CN.md', 'docs/README.zh-CN.md', 'docs/README.ja.md', 'studio/src/motion/CommunityLink.tsx'];
|
|
// The npm installer archive keeps the same files under its single `package/` root.
|
|
const publicCommunityFile = kind === 'package' ? name.replace(/^package\//, '') : name;
|
|
const isBundledStudioAsset = /^studio\/build\/editor-assets\/[^/]+\.js$/.test(publicCommunityFile);
|
|
const publicCommunity = publicCommunityFiles.includes(publicCommunityFile) || isBundledStudioAsset;
|
|
const urls = text.match(/https?:\/\/[^\s"'<>)]*/gi) || [];
|
|
const approvedBundledCollectorDigests = new Set([
|
|
// Owner-approved public Tracert browser collector endpoint embedded inside @powerformer/tracert.
|
|
'01324266d31db8b1c48c229933538e72f57a7025dd585776f57973b6ff35ac9e',
|
|
]);
|
|
if (urls.some(url => {
|
|
if (!/(?:powerformer\.(?:net|com)|feishu\.(?:cn|com)|larksuite\.com)/i.test(url)) return false;
|
|
const digest = createHash('sha256').update(url).digest('hex');
|
|
if (publicCommunity && digest === 'd3337d48607e553372bf4a64d1fb41299487d510b1cc95d565698ff4540003b3') return false;
|
|
if (isBundledStudioAsset && approvedBundledCollectorDigests.has(digest)) return false;
|
|
return true;
|
|
})) add('internal-link');
|
|
if (/\/(?:Users|home)\/[a-zA-Z0-9_.-]+\/|[a-z]:\\Users\\[^\\\s]+\\|\/var\/folders\//i.test(text)) add('personal-path');
|
|
return findings;
|
|
}
|
|
|
|
async function scanTree(directory, kind, binary) {
|
|
const findings = []; let files = 0, bytes = 0;
|
|
const visit = async (dir, prefix = '') => {
|
|
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
const name = prefix + entry.name, filename = path.join(dir, entry.name);
|
|
assert(!entry.isSymbolicLink(), 'Release scan does not follow links');
|
|
if (entry.isDirectory()) await visit(filename, name + '/');
|
|
else {
|
|
assert(entry.isFile(), 'Special file in release');
|
|
const data = await readFile(filename); files++; bytes += data.length;
|
|
assert(bytes < 350 * 1024 * 1024 && files < 20_000, 'Expanded release exceeds scan limit');
|
|
findings.push(...privacyFindings(name, data.includes(0) ? '' : data.toString('utf8'), kind));
|
|
}
|
|
}
|
|
};
|
|
await visit(directory);
|
|
const work = await mkdtemp(path.join(os.tmpdir(), 'motion-secrets-'));
|
|
try {
|
|
const report = path.join(work, 'secrets.json'), ignore = path.join(work, 'empty.ignore'); await writeFile(ignore, '');
|
|
const env = { ...process.env }; delete env.GITLEAKS_CONFIG; delete env.GITLEAKS_CONFIG_TOML;
|
|
let failure;
|
|
try { await runFile(binary, ['dir', directory, '--no-banner', '--redact', '--ignore-gitleaks-allow', '--gitleaks-ignore-path', ignore,
|
|
'--config', path.join(root, '.github/gitleaks.toml'), '--report-format', 'json', '--report-path', report], { cwd: work, env }); }
|
|
catch (error) { failure = error; }
|
|
let secrets;
|
|
try { secrets = JSON.parse(await readFile(report, 'utf8')); }
|
|
catch { throw new Error('Credential scanner did not produce a valid report'); }
|
|
for (const hit of secrets) findings.push({ path: path.relative(directory, hit.File), rule: hit.RuleID, line: hit.StartLine });
|
|
assert(!failure || secrets.length, 'Credential scanner failed before completing');
|
|
// Never expose matched values or the scanner's raw stdout/report.
|
|
if (findings.length) throw new Error('Release content rejected: ' + JSON.stringify(findings));
|
|
return { status: 'passed', kind, files, bytes, scanner: `gitleaks-${scannerVersion}`,
|
|
policySHA256: createHash('sha256').update(await readFile(path.join(root, '.github/gitleaks.toml'))).update(await readFile(fileURLToPath(import.meta.url))).digest('hex') };
|
|
} finally { await rm(work, { recursive: true, force: true }); }
|
|
}
|
|
|
|
export async function scanSource(source, binary) {
|
|
const names = (await runFile('git', ['ls-files', '-z'], { cwd: source })).split('\0').filter(Boolean);
|
|
const work = await mkdtemp(path.join(os.tmpdir(), 'motion-source-scan-'));
|
|
try {
|
|
// Scan the gallery and source catalog separately within the unchanged per-batch budget.
|
|
const batches = new Set();
|
|
for (const name of names) {
|
|
assert(!name.split('/').includes('..') && !path.isAbsolute(name), 'Unsafe tracked path');
|
|
const file = path.join(source, name); assert((await lstat(file)).isFile(), 'Tracked links are forbidden');
|
|
let batch = 'source';
|
|
if (name.startsWith('docs/readme/')) batch = 'gallery';
|
|
if (name.startsWith('library/templates/catalog/')) batch = 'catalog';
|
|
batches.add(batch);
|
|
const destination = path.join(work, batch, name);
|
|
await mkdir(path.dirname(destination), { recursive: true }); await cp(file, destination);
|
|
}
|
|
const reports = [];
|
|
for (const batch of batches) reports.push(await scanTree(path.join(work, batch), 'source', binary));
|
|
if (!reports.length) return await scanTree(work, 'source', binary);
|
|
return { ...reports[0], files: reports.reduce((n, report) => n + report.files, 0),
|
|
bytes: reports.reduce((n, report) => n + report.bytes, 0) };
|
|
} finally { await rm(work, { recursive: true, force: true }); }
|
|
}
|
|
|
|
export async function scanPackage(tgz, binary) {
|
|
const work = await mkdtemp(path.join(os.tmpdir(), 'motion-package-scan-'));
|
|
try {
|
|
await unpackChecked(tgz, path.join(work, 'outer'));
|
|
const outer = path.join(work, 'outer/package');
|
|
const pkg = JSON.parse(await readFile(path.join(outer, 'package.json')));
|
|
assert.equal(pkg.name, '@openmotion/app'); assert.equal(pkg.private, false);
|
|
const manifest = JSON.parse(await readFile(path.join(outer, 'payload/release-npm.json')));
|
|
assert.equal(manifest.format, 'npm'); assert.equal(manifest.templateEnvironment, releaseTemplateEnvironment(pkg.version)); assert.equal(manifest.version, pkg.version);
|
|
const appName = manifest.application.url.replace(/^\.\//, ''); assert.equal(path.basename(appName), appName);
|
|
const appArchive = path.join(outer, 'payload', appName); assert.equal(await sha256(appArchive), manifest.application.sha256);
|
|
await unpackChecked(appArchive, path.join(work, 'application'));
|
|
assert.equal(await sha256(path.join(work, 'application/package-lock.json')), manifest.locks.npm);
|
|
assert.equal(await sha256(path.join(work, 'application/scripts/runtime-lock.json')), manifest.locks.native);
|
|
const applicationPkg = JSON.parse(await readFile(path.join(work, 'application/package.json'))); assert.equal(applicationPkg.version, pkg.version);
|
|
const templates = JSON.parse(await readFile(path.join(work, 'application/shared/template-config.json')));
|
|
assert.equal(templates.environment, manifest.templateEnvironment, 'Application template defaults differ from the manifest');
|
|
const reports = await Promise.all([scanTree(path.join(work, 'outer'), 'package', binary), scanTree(path.join(work, 'application'), 'package', binary)]);
|
|
return { status: 'passed', version: pkg.version, tgzSHA256: await sha256(tgz), applicationSHA256: manifest.application.sha256, reports };
|
|
} finally { await rm(work, { recursive: true, force: true }); }
|
|
}
|
|
|
|
export async function scanPluginPackage(tgz, binary) {
|
|
const work = await mkdtemp(path.join(os.tmpdir(), 'motion-dsh-scan-'));
|
|
try {
|
|
await unpackChecked(tgz, work);
|
|
const pkg = JSON.parse(await readFile(path.join(work, 'package/package.json')));
|
|
assert.equal(pkg.name, 'openmotion-dsh');
|
|
checkReleaseVersion(pkg.version);
|
|
return { ...await scanTree(work, 'package', binary), version: pkg.version, tgzSHA256: await sha256(tgz) };
|
|
} finally { await rm(work, { recursive: true, force: true }); }
|
|
}
|
|
|
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
const [command, input, output, binary] = process.argv.slice(2);
|
|
if (command === 'install') console.log(await installScanner(path.resolve(input)));
|
|
else {
|
|
assert(['source', 'package', 'plugin'].includes(command) && input && output && binary, 'Usage: motion-scan.mjs source|package|plugin <input> <report> <gitleaks>');
|
|
const scan = { source: scanSource, package: scanPackage, plugin: scanPluginPackage }[command];
|
|
await writeJSON(output, await scan(path.resolve(input), binary));
|
|
console.log('Release content scan passed');
|
|
}
|
|
}
|