From db9b50dac7fe45ce08acaa4c4894bb28e9a63158 Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Thu, 5 Jun 2025 09:11:17 -0500 Subject: [PATCH 01/15] Prepare for v1 release --- src/cli.mts | 28 +-- src/commands/analytics/cmd-analytics.mts | 117 +++------ src/commands/analytics/cmd-analytics.test.mts | 235 +++++++----------- src/commands/audit-log/cmd-audit-log.mts | 60 +++-- src/commands/audit-log/cmd-audit-log.test.mts | 95 +++---- src/commands/cdxgen/cmd-cdxgen.mts | 37 --- src/commands/cdxgen/cmd-cdxgen.test.mts | 88 ------- src/commands/cdxgen/handle-cdxgen.mts | 9 - src/commands/ci/cmd-ci.mts | 8 +- src/commands/ci/cmd-ci.test.mts | 10 +- src/commands/cli.test.mts | 148 ++++------- src/commands/config/cmd-config-auto.mts | 12 +- src/commands/config/cmd-config-auto.test.mts | 92 +++++++ src/commands/config/cmd-config-get.mts | 9 +- src/commands/config/cmd-config-get.test.mts | 9 +- src/commands/config/cmd-config-list.mts | 11 +- src/commands/config/cmd-config-list.test.mts | 13 +- src/commands/config/cmd-config-set.mts | 8 +- src/commands/config/cmd-config-set.test.mts | 8 +- src/commands/config/cmd-config-unset.mts | 7 +- src/commands/config/cmd-config-unset.test.mts | 7 +- src/commands/config/cmd-config.mts | 2 +- src/commands/config/cmd-config.test.mts | 2 - .../dependencies/cmd-dependencies.mts | 5 +- .../dependencies/cmd-dependencies.test.mts | 5 +- src/commands/diff-scan/cmd-diff-scan-get.mts | 167 ------------- .../diff-scan/cmd-diff-scan-get.test.mts | 119 --------- src/commands/diff-scan/cmd-diff-scan.mts | 28 --- src/commands/diff-scan/cmd-diff-scan.test.mts | 68 ----- src/commands/diff-scan/fetch-diff-scan.mts | 19 -- src/commands/diff-scan/handle-diff-scan.mts | 32 --- src/commands/diff-scan/output-diff-scan.mts | 87 ------- src/commands/info/cmd-info.mts | 113 --------- src/commands/info/cmd-info.test.mts | 92 ------- src/commands/info/fetch-package-info.mts | 58 ----- src/commands/info/handle-package-info.mts | 51 ---- src/commands/info/output-package-info.mts | 147 ----------- .../install/cmd-install-completion.mts | 2 +- .../install/cmd-install-completion.test.mts | 4 +- src/commands/install/cmd-install.mts | 2 +- src/commands/install/cmd-install.test.mts | 2 - src/commands/json/cmd-json.mts | 9 +- src/commands/json/cmd-json.test.mts | 9 +- src/commands/login/cmd-login.mts | 2 +- src/commands/login/cmd-login.test.mts | 4 +- src/commands/logout/cmd-logout.mts | 5 +- src/commands/logout/cmd-logout.test.mts | 9 +- src/commands/manifest/cmd-manifest-auto.mts | 2 +- .../manifest/cmd-manifest-auto.test.mts | 2 +- src/commands/manifest/cmd-manifest-setup.mts | 1 - .../manifest/cmd-manifest-setup.test.mts | 1 - src/commands/manifest/cmd-manifest.mts | 4 +- src/commands/npm/cmd-npm.mts | 13 + src/commands/npm/cmd-npm.test.mts | 17 +- src/commands/npx/cmd-npx.mts | 13 + src/commands/npx/cmd-npx.test.mts | 17 +- src/commands/oops/cmd-oops.test.mts | 2 - src/commands/optimize/cmd-optimize.test.mts | 2 - .../organization/cmd-organization-list.mts | 6 +- .../cmd-organization-list.test.mts | 8 +- .../cmd-organization-policy-license.mts | 20 +- .../cmd-organization-policy-license.test.mts | 67 ++--- .../cmd-organization-policy-security.mts | 10 +- .../cmd-organization-policy-security.test.mts | 52 +--- .../organization/cmd-organization-policy.mts | 6 +- .../cmd-organization-policy.test.mts | 2 +- .../organization/cmd-organization-quota.mts | 6 +- .../cmd-organization-quota.test.mts | 8 +- .../organization/cmd-organization.mts | 4 +- .../organization/cmd-organization.test.mts | 1 + src/commands/package/cmd-package-score.mts | 16 +- .../package/cmd-package-score.test.mts | 18 +- src/commands/package/cmd-package-shallow.mts | 9 +- .../package/cmd-package-shallow.test.mts | 11 +- src/commands/package/cmd-package.test.mts | 2 - src/commands/raw-npm/cmd-raw-npm.mts | 11 +- src/commands/raw-npm/cmd-raw-npm.test.mts | 13 +- src/commands/raw-npx/cmd-raw-npx.mts | 11 +- src/commands/raw-npx/cmd-raw-npx.test.mts | 13 +- src/commands/report/cmd-report-create.mts | 45 ---- .../report/cmd-report-create.test.mts | 59 ----- src/commands/report/cmd-report-view.mts | 45 ---- src/commands/report/cmd-report-view.test.mts | 59 ----- src/commands/report/cmd-report.mts | 26 -- src/commands/report/cmd-report.test.mts | 69 ----- src/commands/repos/cmd-repos.mts | 31 --- .../cmd-repository-create.mts} | 61 ++--- .../cmd-repository-create.test.mts} | 89 ++++--- .../cmd-repository-del.mts} | 31 +-- .../cmd-repository-del.test.mts} | 82 +++--- .../cmd-repository-list.mts} | 13 +- .../cmd-repository-list.test.mts} | 76 +++--- .../cmd-repository-update.mts} | 45 ++-- .../cmd-repository-update.test.mts} | 78 +++--- .../cmd-repository-view.mts} | 50 ++-- .../cmd-repository-view.test.mts} | 85 +++---- src/commands/repository/cmd-repository.mts | 31 +++ .../cmd-repository.test.mts} | 22 +- .../fetch-create-repo.mts | 0 .../fetch-delete-repo.mts | 0 .../fetch-list-all-repos.mts | 0 .../fetch-list-repos.mts | 0 .../fetch-update-repo.mts | 0 .../{repos => repository}/fetch-view-repo.mts | 0 .../handle-create-repo.mts | 0 .../handle-delete-repo.mts | 0 .../handle-list-repos.mts | 0 .../handle-update-repo.mts | 0 .../handle-view-repo.mts | 0 .../output-create-repo.mts | 0 .../output-delete-repo.mts | 0 .../output-list-repos.mts | 0 .../output-update-repo.mts | 0 .../output-view-repo.mts | 0 src/commands/scan/cmd-scan-create.mts | 40 ++- src/commands/scan/cmd-scan-create.test.mts | 10 +- src/commands/scan/cmd-scan-del.mts | 21 +- src/commands/scan/cmd-scan-del.test.mts | 13 +- src/commands/scan/cmd-scan-diff.mts | 34 ++- src/commands/scan/cmd-scan-diff.test.mts | 19 +- src/commands/scan/cmd-scan-github.mts | 14 -- src/commands/scan/cmd-scan-github.test.mts | 13 +- src/commands/scan/cmd-scan-list.mts | 52 ++-- src/commands/scan/cmd-scan-list.test.mts | 18 +- src/commands/scan/cmd-scan-metadata.mts | 20 +- src/commands/scan/cmd-scan-metadata.test.mts | 13 +- src/commands/scan/cmd-scan-reach.mts | 2 +- src/commands/scan/cmd-scan-reach.test.mts | 2 +- src/commands/scan/cmd-scan-report.mts | 57 +++-- src/commands/scan/cmd-scan-report.test.mts | 37 ++- src/commands/scan/cmd-scan-setup.test.mts | 2 - src/commands/scan/cmd-scan-view.mts | 27 +- src/commands/scan/cmd-scan-view.test.mts | 13 +- src/commands/scan/create-scan-from-github.mts | 2 +- src/commands/threat-feed/cmd-threat-feed.mts | 50 ++-- .../threat-feed/cmd-threat-feed.test.mts | 80 +++--- .../uninstall/cmd-uninstall-completion.mts | 4 +- .../cmd-uninstall-completion.test.mts | 4 +- src/commands/uninstall/cmd-uninstall.mts | 2 +- src/commands/uninstall/cmd-uninstall.test.mts | 4 +- src/commands/wrapper/cmd-wrapper.mts | 54 ++-- src/commands/wrapper/cmd-wrapper.test.mts | 19 +- src/utils/config.mts | 3 +- src/utils/determine-org-slug.mts | 31 +-- src/utils/meow-with-subcommands.mts | 25 +- 145 files changed, 1278 insertions(+), 2826 deletions(-) delete mode 100644 src/commands/cdxgen/cmd-cdxgen.mts delete mode 100644 src/commands/cdxgen/cmd-cdxgen.test.mts delete mode 100644 src/commands/cdxgen/handle-cdxgen.mts create mode 100644 src/commands/config/cmd-config-auto.test.mts delete mode 100644 src/commands/diff-scan/cmd-diff-scan-get.mts delete mode 100644 src/commands/diff-scan/cmd-diff-scan-get.test.mts delete mode 100644 src/commands/diff-scan/cmd-diff-scan.mts delete mode 100644 src/commands/diff-scan/cmd-diff-scan.test.mts delete mode 100644 src/commands/diff-scan/fetch-diff-scan.mts delete mode 100644 src/commands/diff-scan/handle-diff-scan.mts delete mode 100644 src/commands/diff-scan/output-diff-scan.mts delete mode 100644 src/commands/info/cmd-info.mts delete mode 100644 src/commands/info/cmd-info.test.mts delete mode 100644 src/commands/info/fetch-package-info.mts delete mode 100644 src/commands/info/handle-package-info.mts delete mode 100644 src/commands/info/output-package-info.mts delete mode 100644 src/commands/report/cmd-report-create.mts delete mode 100644 src/commands/report/cmd-report-create.test.mts delete mode 100644 src/commands/report/cmd-report-view.mts delete mode 100644 src/commands/report/cmd-report-view.test.mts delete mode 100644 src/commands/report/cmd-report.mts delete mode 100644 src/commands/report/cmd-report.test.mts delete mode 100644 src/commands/repos/cmd-repos.mts rename src/commands/{repos/cmd-repos-create.mts => repository/cmd-repository-create.mts} (73%) rename src/commands/{repos/cmd-repos-create.test.mts => repository/cmd-repository-create.test.mts} (78%) rename src/commands/{repos/cmd-repos-del.mts => repository/cmd-repository-del.mts} (79%) rename src/commands/{repos/cmd-repos-del.test.mts => repository/cmd-repository-del.test.mts} (80%) rename src/commands/{repos/cmd-repos-list.mts => repository/cmd-repository-list.mts} (91%) rename src/commands/{repos/cmd-repos-list.test.mts => repository/cmd-repository-list.test.mts} (81%) rename src/commands/{repos/cmd-repos-update.mts => repository/cmd-repository-update.mts} (77%) rename src/commands/{repos/cmd-repos-update.test.mts => repository/cmd-repository-update.test.mts} (78%) rename src/commands/{repos/cmd-repos-view.mts => repository/cmd-repository-view.mts} (74%) rename src/commands/{repos/cmd-repos-view.test.mts => repository/cmd-repository-view.test.mts} (79%) create mode 100644 src/commands/repository/cmd-repository.mts rename src/commands/{repos/cmd-repos.test.mts => repository/cmd-repository.test.mts} (81%) rename src/commands/{repos => repository}/fetch-create-repo.mts (100%) rename src/commands/{repos => repository}/fetch-delete-repo.mts (100%) rename src/commands/{repos => repository}/fetch-list-all-repos.mts (100%) rename src/commands/{repos => repository}/fetch-list-repos.mts (100%) rename src/commands/{repos => repository}/fetch-update-repo.mts (100%) rename src/commands/{repos => repository}/fetch-view-repo.mts (100%) rename src/commands/{repos => repository}/handle-create-repo.mts (100%) rename src/commands/{repos => repository}/handle-delete-repo.mts (100%) rename src/commands/{repos => repository}/handle-list-repos.mts (100%) rename src/commands/{repos => repository}/handle-update-repo.mts (100%) rename src/commands/{repos => repository}/handle-view-repo.mts (100%) rename src/commands/{repos => repository}/output-create-repo.mts (100%) rename src/commands/{repos => repository}/output-delete-repo.mts (100%) rename src/commands/{repos => repository}/output-list-repos.mts (100%) rename src/commands/{repos => repository}/output-update-repo.mts (100%) rename src/commands/{repos => repository}/output-view-repo.mts (100%) diff --git a/src/cli.mts b/src/cli.mts index 95b474da1..1a3d8f3c0 100755 --- a/src/cli.mts +++ b/src/cli.mts @@ -11,30 +11,27 @@ import { logger } from '@socketsecurity/registry/lib/logger' import { cmdAnalytics } from './commands/analytics/cmd-analytics.mts' import { cmdAuditLog } from './commands/audit-log/cmd-audit-log.mts' -import { cmdCdxgen } from './commands/cdxgen/cmd-cdxgen.mts' import { cmdCI } from './commands/ci/cmd-ci.mts' import { cmdConfig } from './commands/config/cmd-config.mts' import { cmdScanCreate } from './commands/dependencies/cmd-dependencies.mts' -import { cmdDiffScan } from './commands/diff-scan/cmd-diff-scan.mts' import { cmdFix } from './commands/fix/cmd-fix.mts' -import { cmdInfo } from './commands/info/cmd-info.mts' import { cmdInstall } from './commands/install/cmd-install.mts' import { cmdJson } from './commands/json/cmd-json.mts' import { cmdLogin } from './commands/login/cmd-login.mts' import { cmdLogout } from './commands/logout/cmd-logout.mts' +import { cmdManifestCdxgen } from './commands/manifest/cmd-manifest-cdxgen.mts' import { cmdManifest } from './commands/manifest/cmd-manifest.mts' import { cmdNpm } from './commands/npm/cmd-npm.mts' import { cmdNpx } from './commands/npx/cmd-npx.mts' import { cmdOops } from './commands/oops/cmd-oops.mts' import { cmdOptimize } from './commands/optimize/cmd-optimize.mts' import { cmdOrganizationPolicyLicense } from './commands/organization/cmd-organization-policy-license.mts' -import { cmdOrganizationPolicyPolicy } from './commands/organization/cmd-organization-policy-security.mts' +import { cmdOrganizationPolicySecurity } from './commands/organization/cmd-organization-policy-security.mts' import { cmdOrganization } from './commands/organization/cmd-organization.mts' import { cmdPackage } from './commands/package/cmd-package.mts' import { cmdRawNpm } from './commands/raw-npm/cmd-raw-npm.mts' import { cmdRawNpx } from './commands/raw-npx/cmd-raw-npx.mts' -import { cmdReport } from './commands/report/cmd-report.mts' -import { cmdRepos } from './commands/repos/cmd-repos.mts' +import { cmdRepository } from './commands/repository/cmd-repository.mts' import { cmdScan } from './commands/scan/cmd-scan.mts' import { cmdThreatFeed } from './commands/threat-feed/cmd-threat-feed.mts' import { cmdUninstall } from './commands/uninstall/cmd-uninstall.mts' @@ -62,10 +59,8 @@ void (async () => { await meowWithSubcommands( { ci: cmdCI, - cdxgen: cmdCdxgen, config: cmdConfig, fix: cmdFix, - info: cmdInfo, install: cmdInstall, json: cmdJson, login: cmdLogin, @@ -78,14 +73,12 @@ void (async () => { package: cmdPackage, 'raw-npm': cmdRawNpm, 'raw-npx': cmdRawNpx, - report: cmdReport, wrapper: cmdWrapper, scan: cmdScan, 'audit-log': cmdAuditLog, - repos: cmdRepos, + repos: cmdRepository, dependencies: cmdScanCreate, analytics: cmdAnalytics, - 'diff-scan': cmdDiffScan, 'threat-feed': cmdThreatFeed, manifest: cmdManifest, uninstall: cmdUninstall, @@ -102,6 +95,11 @@ void (async () => { hidden: true, argv: ['audit-log'], }, + cdxgen: { + description: cmdManifestCdxgen.description, + hidden: true, + argv: ['manifest', 'cdxgen'], + }, deps: { description: cmdScanCreate.description, hidden: true, @@ -148,22 +146,22 @@ void (async () => { argv: ['package'], }, repo: { - description: cmdRepos.description, + description: cmdRepository.description, hidden: true, argv: ['repos'], }, repository: { - description: cmdRepos.description, + description: cmdRepository.description, hidden: true, argv: ['repos'], }, repositories: { - description: cmdRepos.description, + description: cmdRepository.description, hidden: true, argv: ['repos'], }, security: { - description: cmdOrganizationPolicyPolicy.description, + description: cmdOrganizationPolicySecurity.description, hidden: true, argv: ['organization', 'policy', 'security'], }, diff --git a/src/commands/analytics/cmd-analytics.mts b/src/commands/analytics/cmd-analytics.mts index c6ca83e3b..f73bcf19c 100644 --- a/src/commands/analytics/cmd-analytics.mts +++ b/src/commands/analytics/cmd-analytics.mts @@ -4,7 +4,6 @@ import { handleAnalytics } from './handle-analytics.mts' import constants from '../../constants.mts' import { commonFlags, outputFlags } from '../../flags.mts' import { checkCommandInput } from '../../utils/check-input.mts' -import { isTestingV1 } from '../../utils/config.mts' import { getOutputKind } from '../../utils/get-output-kind.mts' import { meowOrExit } from '../../utils/meow-with-subcommands.mts' import { getFlagListOutput } from '../../utils/output-formatting.mts' @@ -23,58 +22,32 @@ const config: CliCommandConfig = { ...outputFlags, file: { type: 'string', - shortFlag: 'f', - description: - 'Filepath to save output when given. Only valid with --json/--markdown.', - }, - repo: { - type: 'string', - shortFlag: 'r', - default: '', - description: 'Name of the repository. Only valid when scope=repo', - }, - scope: { - type: 'string', - shortFlag: 's', - default: 'org', - description: - "Scope of the analytics data - either 'org' or 'repo', default: org", - }, - time: { - type: 'number', - shortFlag: 't', - default: 30, - description: 'Time filter - either 7, 30 or 90, default: 30', + description: 'Path to store result, only valid with --json/--markdown', }, }, help: (command, { flags }) => ` Usage - $ ${command} ${isTestingV1() ? '[ org | repo ] [time]' : '--scope= --time=