From 5beabf338ec822f711be5ebc57d7a3685074244c Mon Sep 17 00:00:00 2001 From: Dave Holladay Date: Wed, 12 Apr 2023 18:35:12 +0100 Subject: [PATCH] version 1.0.0 --- .github/workflows/build.yml | 145 + .gitignore | 2 + README.md | 188 + cli/.ci/notarize.js | 52 + cli/.ci/package.sh | 59 + cli/.ci/set-package-vars.js | 28 + cli/.eslintignore | 4 + cli/.eslintrc.json | 16 + cli/.gitignore | 8 + cli/.mocharc.json | 7 + cli/.prettierignore | 4 + cli/LICENSE | 21 + cli/README.md | 1295 ++ cli/bin/dev | 17 + cli/bin/dev.cmd | 3 + cli/bin/run | 5 + cli/bin/run.cmd | 3 + cli/package.json | 107 + cli/src/commands/app/archive.ts | 45 + cli/src/commands/app/config.ts | 102 + cli/src/commands/app/create.ts | 79 + cli/src/commands/app/index.ts | 11 + cli/src/commands/app/last-assessment.ts | 45 + cli/src/commands/app/list.ts | 89 + cli/src/commands/app/process.ts | 63 + cli/src/commands/app/update.ts | 151 + cli/src/commands/app/upload.ts | 53 + cli/src/commands/app/vulnerabilities.ts | 48 + cli/src/commands/assessment/cancel.ts | 31 + .../commands/assessment/github-snapshot.ts | 106 + cli/src/commands/assessment/index.ts | 11 + cli/src/commands/assessment/list.ts | 175 + cli/src/commands/assessment/raw.ts | 36 + cli/src/commands/assessment/sarif.ts | 121 + cli/src/commands/assessment/show.ts | 170 + cli/src/commands/assessment/start.ts | 81 + cli/src/commands/configure/index.ts | 235 + cli/src/commands/organization/groups.ts | 35 + cli/src/commands/organization/index.ts | 11 + cli/src/commands/organization/invitations.ts | 31 + cli/src/commands/organization/invite.ts | 83 + .../organization/revoke-invitation.ts | 66 + cli/src/commands/organization/users.ts | 43 + cli/src/commands/user/account.ts | 25 + cli/src/commands/user/groups.ts | 28 + cli/src/commands/user/index.ts | 11 + cli/src/index.ts | 7 + cli/src/utils/app-ref.ts | 71 + cli/src/utils/args.ts | 41 + cli/src/utils/base-command.ts | 175 + cli/src/utils/command-core.ts | 12 + cli/src/utils/config.ts | 133 + cli/src/utils/filters.ts | 94 + cli/src/utils/group-list.ts | 55 + cli/src/utils/index.ts | 16 + cli/src/utils/parsers.ts | 127 + cli/src/utils/sub-command-lister.ts | 20 + cli/src/utils/table.ts | 66 + cli/test/helpers/command-shim.ts | 69 + cli/test/helpers/init.js | 12 + cli/test/helpers/resource.ts | 34 + cli/test/resources/test-config.ini | 21 + cli/test/tsconfig.json | 7 + cli/test/utils/app-ref.test.ts | 181 + cli/test/utils/base-command.test.ts | 95 + cli/test/utils/config.test.ts | 32 + cli/test/utils/filters.test.ts | 79 + cli/test/utils/group-list.test.ts | 95 + cli/test/utils/parsers.test.ts | 125 + cli/test/utils/table.test.ts | 49 + cli/tsconfig.json | 15 + cli/tsconfig.production.json | 4 + cli/yarn.lock | 5546 ++++++ github-snapshot/.eslintignore | 2 + github-snapshot/.eslintrc.json | 16 + github-snapshot/.gitignore | 2 + github-snapshot/.prettierignore | 2 + github-snapshot/LICENSE | 21 + github-snapshot/README.md | 62 + github-snapshot/jest.config.js | 6 + github-snapshot/package.json | 42 + github-snapshot/src/dependency-snapshot.ts | 90 + github-snapshot/src/index.ts | 127 + .../convert-to-snapshot.test.ts.snap | 52 + .../tests/convert-to-snapshot.test.ts | 22 + github-snapshot/tests/jsconfig.json | 5 + .../tests/resources/dependencies-output.json | 78 + github-snapshot/tsconfig.json | 20 + github-snapshot/tsconfig.production.json | 4 + github-snapshot/yarn.lock | 3434 ++++ lib/.eslintignore | 4 + lib/.eslintrc.json | 16 + lib/.gitignore | 3 + lib/.prettierignore | 4 + lib/LICENSE | 21 + lib/README.md | 33 + lib/codegen.yml | 36 + lib/docs/.DS_Store | Bin 0 -> 8196 bytes lib/docs/README.md | 12 + lib/docs/images/logo.png | Bin 0 -> 16303 bytes lib/docs/includes/_api.md | 23 + lib/docs/includes/_app.md | 3 + lib/docs/includes/_app_archiveApp.md | 16 + lib/docs/includes/_app_createApp.md | 25 + lib/docs/includes/_app_getAnalysisConfig.md | 15 + .../includes/_app_getAppVulnerabilities.md | 50 + lib/docs/includes/_app_listApplications.md | 78 + lib/docs/includes/_app_processBinary.md | 66 + lib/docs/includes/_app_resetAnalysisConfig.md | 13 + .../includes/_app_updateAnalysisConfig.md | 82 + lib/docs/includes/_app_uploadBinary.md | 47 + lib/docs/includes/_assessment.md | 1 + .../includes/_assessment_cancelAssessment.md | 17 + .../includes/_assessment_fetchAssessment.md | 20 + .../includes/_assessment_isLicenseValid.md | 5 + .../includes/_assessment_listAssessments.md | 69 + .../includes/_assessment_pollForReport.md | 23 + .../includes/_assessment_rawAssessmentData.md | 13 + .../includes/_assessment_startAssessment.md | 81 + lib/docs/includes/_nsclient.md | 172 + lib/docs/includes/_organization.md | 1 + lib/docs/includes/_organization_inviteUser.md | 25 + .../includes/_organization_listInvitations.md | 9 + lib/docs/includes/_organization_listRoles.md | 26 + lib/docs/includes/_organization_orgGroups.md | 17 + lib/docs/includes/_organization_orgUsers.md | 17 + .../_organization_revokeInvitation.md | 11 + lib/docs/includes/_platform.md | 65 + lib/docs/includes/_support.md | 1 + lib/docs/includes/_types.md | 515 + lib/docs/includes/_user.md | 3 + lib/docs/includes/_user_userGroups.md | 1 + lib/docs/includes/_user_userInfo.md | 1 + lib/docs/index.html.md | 52 + lib/docs/makedocs.sh | 23 + lib/docs/slate/modified/lib/toc_data.rb | 31 + .../source/javascripts/all_nosearch.js | 27 + .../source/javascripts/app/_search.js | 102 + .../slate/modified/source/layouts/layout.erb | 146 + .../source/stylesheets/screen.css.scss | 656 + .../original/lib/monokai_sublime_slate.rb | 95 + lib/docs/slate/original/lib/multilang.rb | 16 + .../slate/original/lib/nesting_unique_head.rb | 22 + lib/docs/slate/original/lib/toc_data.rb | 31 + lib/docs/slate/original/lib/unique_head.rb | 24 + .../slate/original/source/fonts/slate.eot | Bin 0 -> 1876 bytes .../slate/original/source/fonts/slate.svg | 14 + .../slate/original/source/fonts/slate.ttf | Bin 0 -> 1720 bytes .../slate/original/source/fonts/slate.woff | Bin 0 -> 1796 bytes .../slate/original/source/fonts/slate.woff2 | Bin 0 -> 796 bytes .../slate/original/source/images/logo.png | Bin 0 -> 22317 bytes .../slate/original/source/images/navbar.png | Bin 0 -> 96 bytes .../slate/original/source/javascripts/all.js | 2 + .../source/javascripts/all_nosearch.js | 27 + .../original/source/javascripts/app/_copy.js | 15 + .../original/source/javascripts/app/_lang.js | 171 + .../source/javascripts/app/_search.js | 102 + .../original/source/javascripts/app/_toc.js | 122 + .../source/javascripts/lib/_energize.js | 169 + .../javascripts/lib/_imagesloaded.min.js | 7 + .../javascripts/lib/_jquery.highlight.js | 108 + .../source/javascripts/lib/_jquery.js | 10881 ++++++++++++ .../original/source/javascripts/lib/_lunr.js | 3475 ++++ .../slate/original/source/layouts/layout.erb | 137 + .../source/stylesheets/_icon-font.scss | 38 + .../source/stylesheets/_normalize.scss | 427 + .../original/source/stylesheets/_rtl.scss | 140 + .../source/stylesheets/_variables.scss | 103 + .../source/stylesheets/print.css.scss | 153 + .../source/stylesheets/screen.css.scss | 637 + lib/graphql/analysis-config.graphql | 68 + lib/graphql/apps.graphql | 44 + lib/graphql/assessment.graphql | 61 + lib/graphql/fragments/analysis-config.graphql | 44 + .../fragments/assessment-analysis.graphql | 15 + lib/graphql/fragments/assessment.graphql | 28 + lib/graphql/fragments/build.graphql | 16 + lib/graphql/fragments/findings.graphql | 81 + lib/graphql/fragments/group.graphql | 15 + lib/graphql/fragments/invitation.graphql | 15 + lib/graphql/fragments/job.graphql | 7 + lib/graphql/fragments/license.graphql | 13 + lib/graphql/fragments/permission.graphql | 7 + lib/graphql/fragments/role.graphql | 12 + lib/graphql/fragments/user.graphql | 17 + lib/graphql/group.graphql | 17 + lib/graphql/invitations.graphql | 35 + lib/graphql/license.graphql | 5 + lib/graphql/roles.graphql | 9 + lib/graphql/user.graphql | 20 + lib/htmldocs/fonts/slate-7b7da4fe.ttf | Bin 0 -> 1720 bytes lib/htmldocs/fonts/slate-cfc9d06b.eot | Bin 0 -> 1876 bytes lib/htmldocs/fonts/slate-e55b8307.svg | 14 + lib/htmldocs/fonts/slate.woff | Bin 0 -> 1796 bytes lib/htmldocs/fonts/slate.woff2 | Bin 0 -> 796 bytes lib/htmldocs/images/logo-02a52ce4.png | Bin 0 -> 16303 bytes lib/htmldocs/images/navbar-cad8cdcb.png | Bin 0 -> 96 bytes lib/htmldocs/index.html | 2880 ++++ lib/htmldocs/javascripts/all-1b920087.js | 120 + .../javascripts/all_nosearch-7f95e017.js | 31 + lib/htmldocs/stylesheets/print-966d6edc.css | 1 + lib/htmldocs/stylesheets/screen-61abaf50.css | 1 + lib/jest.config.js | 13 + lib/package.json | 60 + lib/schema.graphql | 13907 ++++++++++++++++ lib/src/api/app/archive.ts | 28 + lib/src/api/app/config.ts | 34 + lib/src/api/app/create.ts | 36 + lib/src/api/app/index.ts | 15 + lib/src/api/app/list.ts | 28 + lib/src/api/app/runner.ts | 36 + lib/src/api/app/update-config.ts | 602 + lib/src/api/app/upload-binary.ts | 63 + lib/src/api/app/vulnerabilities.ts | 16 + lib/src/api/assessment/cancel.ts | 19 + lib/src/api/assessment/fetch.ts | 104 + lib/src/api/assessment/index.ts | 12 + lib/src/api/assessment/is-license-valid.ts | 25 + lib/src/api/assessment/list.ts | 24 + lib/src/api/assessment/raw.ts | 29 + lib/src/api/assessment/start.ts | 29 + lib/src/api/index.ts | 10 + lib/src/api/organization/groups.ts | 20 + lib/src/api/organization/index.ts | 10 + lib/src/api/organization/invitations.ts | 39 + lib/src/api/organization/roles.ts | 14 + lib/src/api/organization/users.ts | 20 + lib/src/api/user/group.ts | 14 + lib/src/api/user/index.ts | 8 + lib/src/api/user/info.ts | 14 + lib/src/client.ts | 207 + lib/src/errors.ts | 21 + lib/src/finding-keys.ts | 142 + lib/src/findings-filter.ts | 191 + lib/src/index.ts | 15 + lib/src/platform-config.ts | 39 + lib/src/platform.ts | 319 + lib/src/queries.ts | 150 + lib/src/types/dependencies.ts | 55 + lib/src/types/graphql.ts | 19 + lib/src/types/index.ts | 9 + lib/src/types/platform.ts | 170 + lib/src/utils.ts | 32 + lib/tests/api/app/update-config.test.ts | 739 + lib/tests/client.test.ts | 266 + lib/tests/errors.test.ts | 16 + lib/tests/finding-keys.test.ts | 292 + lib/tests/findings-filter.test.ts | 109 + lib/tests/helpers/resources.ts | 34 + lib/tests/jsconfig.json | 5 + lib/tests/platform-config.test.ts | 36 + lib/tests/resources/assessment.json | 385 + lib/tests/resources/filter-errors.yml | 5 + lib/tests/resources/js-runner.js | 64 + lib/tests/resources/key-params.yml | 31 + lib/tests/utils.test.ts | 77 + lib/tsconfig.json | 20 + lib/tsconfig.production.json | 4 + lib/tsconfig.test.json | 22 + lib/yarn.lock | 5181 ++++++ package.json | 36 + sarif/.eslintignore | 2 + sarif/.eslintrc.json | 16 + sarif/.gitignore | 2 + sarif/.prettierignore | 2 + sarif/LICENSE | 21 + sarif/README.md | 50 + sarif/jest.config.js | 6 + sarif/package.json | 42 + sarif/src/index.ts | 403 + .../convert-to-sarif.test.ts.snap | 80 + sarif/tests/convert-to-sarif.test.ts | 30 + sarif/tests/resources/assessment.json | 43 + sarif/tsconfig.json | 20 + sarif/tsconfig.production.json | 4 + sarif/yarn.lock | 2981 ++++ 276 files changed, 65906 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 cli/.ci/notarize.js create mode 100755 cli/.ci/package.sh create mode 100644 cli/.ci/set-package-vars.js create mode 100644 cli/.eslintignore create mode 100644 cli/.eslintrc.json create mode 100644 cli/.gitignore create mode 100644 cli/.mocharc.json create mode 100644 cli/.prettierignore create mode 100644 cli/LICENSE create mode 100644 cli/README.md create mode 100755 cli/bin/dev create mode 100644 cli/bin/dev.cmd create mode 100755 cli/bin/run create mode 100644 cli/bin/run.cmd create mode 100644 cli/package.json create mode 100644 cli/src/commands/app/archive.ts create mode 100644 cli/src/commands/app/config.ts create mode 100644 cli/src/commands/app/create.ts create mode 100644 cli/src/commands/app/index.ts create mode 100644 cli/src/commands/app/last-assessment.ts create mode 100644 cli/src/commands/app/list.ts create mode 100644 cli/src/commands/app/process.ts create mode 100644 cli/src/commands/app/update.ts create mode 100644 cli/src/commands/app/upload.ts create mode 100644 cli/src/commands/app/vulnerabilities.ts create mode 100644 cli/src/commands/assessment/cancel.ts create mode 100644 cli/src/commands/assessment/github-snapshot.ts create mode 100644 cli/src/commands/assessment/index.ts create mode 100644 cli/src/commands/assessment/list.ts create mode 100644 cli/src/commands/assessment/raw.ts create mode 100644 cli/src/commands/assessment/sarif.ts create mode 100644 cli/src/commands/assessment/show.ts create mode 100644 cli/src/commands/assessment/start.ts create mode 100644 cli/src/commands/configure/index.ts create mode 100644 cli/src/commands/organization/groups.ts create mode 100644 cli/src/commands/organization/index.ts create mode 100644 cli/src/commands/organization/invitations.ts create mode 100644 cli/src/commands/organization/invite.ts create mode 100644 cli/src/commands/organization/revoke-invitation.ts create mode 100644 cli/src/commands/organization/users.ts create mode 100644 cli/src/commands/user/account.ts create mode 100644 cli/src/commands/user/groups.ts create mode 100644 cli/src/commands/user/index.ts create mode 100644 cli/src/index.ts create mode 100644 cli/src/utils/app-ref.ts create mode 100644 cli/src/utils/args.ts create mode 100644 cli/src/utils/base-command.ts create mode 100644 cli/src/utils/command-core.ts create mode 100644 cli/src/utils/config.ts create mode 100644 cli/src/utils/filters.ts create mode 100644 cli/src/utils/group-list.ts create mode 100644 cli/src/utils/index.ts create mode 100644 cli/src/utils/parsers.ts create mode 100644 cli/src/utils/sub-command-lister.ts create mode 100644 cli/src/utils/table.ts create mode 100644 cli/test/helpers/command-shim.ts create mode 100644 cli/test/helpers/init.js create mode 100644 cli/test/helpers/resource.ts create mode 100644 cli/test/resources/test-config.ini create mode 100644 cli/test/tsconfig.json create mode 100644 cli/test/utils/app-ref.test.ts create mode 100644 cli/test/utils/base-command.test.ts create mode 100644 cli/test/utils/config.test.ts create mode 100644 cli/test/utils/filters.test.ts create mode 100644 cli/test/utils/group-list.test.ts create mode 100644 cli/test/utils/parsers.test.ts create mode 100644 cli/test/utils/table.test.ts create mode 100644 cli/tsconfig.json create mode 100644 cli/tsconfig.production.json create mode 100644 cli/yarn.lock create mode 100644 github-snapshot/.eslintignore create mode 100644 github-snapshot/.eslintrc.json create mode 100644 github-snapshot/.gitignore create mode 100644 github-snapshot/.prettierignore create mode 100644 github-snapshot/LICENSE create mode 100644 github-snapshot/README.md create mode 100644 github-snapshot/jest.config.js create mode 100644 github-snapshot/package.json create mode 100644 github-snapshot/src/dependency-snapshot.ts create mode 100644 github-snapshot/src/index.ts create mode 100644 github-snapshot/tests/__snapshots__/convert-to-snapshot.test.ts.snap create mode 100644 github-snapshot/tests/convert-to-snapshot.test.ts create mode 100644 github-snapshot/tests/jsconfig.json create mode 100644 github-snapshot/tests/resources/dependencies-output.json create mode 100644 github-snapshot/tsconfig.json create mode 100644 github-snapshot/tsconfig.production.json create mode 100644 github-snapshot/yarn.lock create mode 100644 lib/.eslintignore create mode 100644 lib/.eslintrc.json create mode 100644 lib/.gitignore create mode 100644 lib/.prettierignore create mode 100644 lib/LICENSE create mode 100644 lib/README.md create mode 100644 lib/codegen.yml create mode 100644 lib/docs/.DS_Store create mode 100644 lib/docs/README.md create mode 100644 lib/docs/images/logo.png create mode 100644 lib/docs/includes/_api.md create mode 100644 lib/docs/includes/_app.md create mode 100644 lib/docs/includes/_app_archiveApp.md create mode 100644 lib/docs/includes/_app_createApp.md create mode 100644 lib/docs/includes/_app_getAnalysisConfig.md create mode 100644 lib/docs/includes/_app_getAppVulnerabilities.md create mode 100644 lib/docs/includes/_app_listApplications.md create mode 100644 lib/docs/includes/_app_processBinary.md create mode 100644 lib/docs/includes/_app_resetAnalysisConfig.md create mode 100644 lib/docs/includes/_app_updateAnalysisConfig.md create mode 100644 lib/docs/includes/_app_uploadBinary.md create mode 100644 lib/docs/includes/_assessment.md create mode 100644 lib/docs/includes/_assessment_cancelAssessment.md create mode 100644 lib/docs/includes/_assessment_fetchAssessment.md create mode 100644 lib/docs/includes/_assessment_isLicenseValid.md create mode 100644 lib/docs/includes/_assessment_listAssessments.md create mode 100644 lib/docs/includes/_assessment_pollForReport.md create mode 100644 lib/docs/includes/_assessment_rawAssessmentData.md create mode 100644 lib/docs/includes/_assessment_startAssessment.md create mode 100644 lib/docs/includes/_nsclient.md create mode 100644 lib/docs/includes/_organization.md create mode 100644 lib/docs/includes/_organization_inviteUser.md create mode 100644 lib/docs/includes/_organization_listInvitations.md create mode 100644 lib/docs/includes/_organization_listRoles.md create mode 100644 lib/docs/includes/_organization_orgGroups.md create mode 100644 lib/docs/includes/_organization_orgUsers.md create mode 100644 lib/docs/includes/_organization_revokeInvitation.md create mode 100644 lib/docs/includes/_platform.md create mode 100644 lib/docs/includes/_support.md create mode 100644 lib/docs/includes/_types.md create mode 100644 lib/docs/includes/_user.md create mode 100644 lib/docs/includes/_user_userGroups.md create mode 100644 lib/docs/includes/_user_userInfo.md create mode 100644 lib/docs/index.html.md create mode 100755 lib/docs/makedocs.sh create mode 100644 lib/docs/slate/modified/lib/toc_data.rb create mode 100644 lib/docs/slate/modified/source/javascripts/all_nosearch.js create mode 100644 lib/docs/slate/modified/source/javascripts/app/_search.js create mode 100644 lib/docs/slate/modified/source/layouts/layout.erb create mode 100644 lib/docs/slate/modified/source/stylesheets/screen.css.scss create mode 100644 lib/docs/slate/original/lib/monokai_sublime_slate.rb create mode 100644 lib/docs/slate/original/lib/multilang.rb create mode 100644 lib/docs/slate/original/lib/nesting_unique_head.rb create mode 100644 lib/docs/slate/original/lib/toc_data.rb create mode 100644 lib/docs/slate/original/lib/unique_head.rb create mode 100644 lib/docs/slate/original/source/fonts/slate.eot create mode 100644 lib/docs/slate/original/source/fonts/slate.svg create mode 100644 lib/docs/slate/original/source/fonts/slate.ttf create mode 100644 lib/docs/slate/original/source/fonts/slate.woff create mode 100644 lib/docs/slate/original/source/fonts/slate.woff2 create mode 100644 lib/docs/slate/original/source/images/logo.png create mode 100644 lib/docs/slate/original/source/images/navbar.png create mode 100644 lib/docs/slate/original/source/javascripts/all.js create mode 100644 lib/docs/slate/original/source/javascripts/all_nosearch.js create mode 100644 lib/docs/slate/original/source/javascripts/app/_copy.js create mode 100644 lib/docs/slate/original/source/javascripts/app/_lang.js create mode 100644 lib/docs/slate/original/source/javascripts/app/_search.js create mode 100644 lib/docs/slate/original/source/javascripts/app/_toc.js create mode 100644 lib/docs/slate/original/source/javascripts/lib/_energize.js create mode 100644 lib/docs/slate/original/source/javascripts/lib/_imagesloaded.min.js create mode 100644 lib/docs/slate/original/source/javascripts/lib/_jquery.highlight.js create mode 100644 lib/docs/slate/original/source/javascripts/lib/_jquery.js create mode 100644 lib/docs/slate/original/source/javascripts/lib/_lunr.js create mode 100644 lib/docs/slate/original/source/layouts/layout.erb create mode 100644 lib/docs/slate/original/source/stylesheets/_icon-font.scss create mode 100644 lib/docs/slate/original/source/stylesheets/_normalize.scss create mode 100644 lib/docs/slate/original/source/stylesheets/_rtl.scss create mode 100644 lib/docs/slate/original/source/stylesheets/_variables.scss create mode 100644 lib/docs/slate/original/source/stylesheets/print.css.scss create mode 100644 lib/docs/slate/original/source/stylesheets/screen.css.scss create mode 100644 lib/graphql/analysis-config.graphql create mode 100644 lib/graphql/apps.graphql create mode 100644 lib/graphql/assessment.graphql create mode 100644 lib/graphql/fragments/analysis-config.graphql create mode 100644 lib/graphql/fragments/assessment-analysis.graphql create mode 100644 lib/graphql/fragments/assessment.graphql create mode 100644 lib/graphql/fragments/build.graphql create mode 100644 lib/graphql/fragments/findings.graphql create mode 100644 lib/graphql/fragments/group.graphql create mode 100644 lib/graphql/fragments/invitation.graphql create mode 100644 lib/graphql/fragments/job.graphql create mode 100644 lib/graphql/fragments/license.graphql create mode 100644 lib/graphql/fragments/permission.graphql create mode 100644 lib/graphql/fragments/role.graphql create mode 100644 lib/graphql/fragments/user.graphql create mode 100644 lib/graphql/group.graphql create mode 100644 lib/graphql/invitations.graphql create mode 100644 lib/graphql/license.graphql create mode 100644 lib/graphql/roles.graphql create mode 100644 lib/graphql/user.graphql create mode 100644 lib/htmldocs/fonts/slate-7b7da4fe.ttf create mode 100644 lib/htmldocs/fonts/slate-cfc9d06b.eot create mode 100644 lib/htmldocs/fonts/slate-e55b8307.svg create mode 100644 lib/htmldocs/fonts/slate.woff create mode 100644 lib/htmldocs/fonts/slate.woff2 create mode 100644 lib/htmldocs/images/logo-02a52ce4.png create mode 100644 lib/htmldocs/images/navbar-cad8cdcb.png create mode 100644 lib/htmldocs/index.html create mode 100644 lib/htmldocs/javascripts/all-1b920087.js create mode 100644 lib/htmldocs/javascripts/all_nosearch-7f95e017.js create mode 100644 lib/htmldocs/stylesheets/print-966d6edc.css create mode 100644 lib/htmldocs/stylesheets/screen-61abaf50.css create mode 100644 lib/jest.config.js create mode 100644 lib/package.json create mode 100644 lib/schema.graphql create mode 100644 lib/src/api/app/archive.ts create mode 100644 lib/src/api/app/config.ts create mode 100644 lib/src/api/app/create.ts create mode 100644 lib/src/api/app/index.ts create mode 100644 lib/src/api/app/list.ts create mode 100644 lib/src/api/app/runner.ts create mode 100644 lib/src/api/app/update-config.ts create mode 100644 lib/src/api/app/upload-binary.ts create mode 100644 lib/src/api/app/vulnerabilities.ts create mode 100644 lib/src/api/assessment/cancel.ts create mode 100644 lib/src/api/assessment/fetch.ts create mode 100644 lib/src/api/assessment/index.ts create mode 100644 lib/src/api/assessment/is-license-valid.ts create mode 100644 lib/src/api/assessment/list.ts create mode 100644 lib/src/api/assessment/raw.ts create mode 100644 lib/src/api/assessment/start.ts create mode 100644 lib/src/api/index.ts create mode 100644 lib/src/api/organization/groups.ts create mode 100644 lib/src/api/organization/index.ts create mode 100644 lib/src/api/organization/invitations.ts create mode 100644 lib/src/api/organization/roles.ts create mode 100644 lib/src/api/organization/users.ts create mode 100644 lib/src/api/user/group.ts create mode 100644 lib/src/api/user/index.ts create mode 100644 lib/src/api/user/info.ts create mode 100644 lib/src/client.ts create mode 100644 lib/src/errors.ts create mode 100644 lib/src/finding-keys.ts create mode 100644 lib/src/findings-filter.ts create mode 100644 lib/src/index.ts create mode 100644 lib/src/platform-config.ts create mode 100644 lib/src/platform.ts create mode 100644 lib/src/queries.ts create mode 100644 lib/src/types/dependencies.ts create mode 100644 lib/src/types/graphql.ts create mode 100644 lib/src/types/index.ts create mode 100644 lib/src/types/platform.ts create mode 100644 lib/src/utils.ts create mode 100644 lib/tests/api/app/update-config.test.ts create mode 100644 lib/tests/client.test.ts create mode 100644 lib/tests/errors.test.ts create mode 100644 lib/tests/finding-keys.test.ts create mode 100644 lib/tests/findings-filter.test.ts create mode 100644 lib/tests/helpers/resources.ts create mode 100644 lib/tests/jsconfig.json create mode 100644 lib/tests/platform-config.test.ts create mode 100644 lib/tests/resources/assessment.json create mode 100644 lib/tests/resources/filter-errors.yml create mode 100644 lib/tests/resources/js-runner.js create mode 100644 lib/tests/resources/key-params.yml create mode 100644 lib/tests/utils.test.ts create mode 100644 lib/tsconfig.json create mode 100644 lib/tsconfig.production.json create mode 100644 lib/tsconfig.test.json create mode 100644 lib/yarn.lock create mode 100644 package.json create mode 100644 sarif/.eslintignore create mode 100644 sarif/.eslintrc.json create mode 100644 sarif/.gitignore create mode 100644 sarif/.prettierignore create mode 100644 sarif/LICENSE create mode 100644 sarif/README.md create mode 100644 sarif/jest.config.js create mode 100644 sarif/package.json create mode 100644 sarif/src/index.ts create mode 100644 sarif/tests/__snapshots__/convert-to-sarif.test.ts.snap create mode 100644 sarif/tests/convert-to-sarif.test.ts create mode 100644 sarif/tests/resources/assessment.json create mode 100644 sarif/tsconfig.json create mode 100644 sarif/tsconfig.production.json create mode 100644 sarif/yarn.lock diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fc0312d --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,145 @@ +name: Build and package the NowSecure Platform CLI +on: + push: + branches: + - main + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' + pull_request: + branches: + - main + workflow_dispatch: {} + +jobs: + build-on-ubuntu: + name: Build .deb files for arm & intel + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Get Git History + run: git fetch --unshallow --filter=blob:none --tags --force + - name: Set Version + id: set-version + run: | + TAG_REGEX="^refs/tags/(v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?)$" + if [[ ${{ github.ref }} =~ $TAG_REGEX ]]; then + echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT + else + echo "version=$(git describe --tags --long --match 'v*')" >> $GITHUB_OUTPUT + fi + - uses: actions/setup-node@v3 + with: + node-version: '16' + - run: | + CLI_VERSION=${{ steps.set-version.outputs.version }} node cli/.ci/set-package-vars.js + CI_CD_BUILD=1 cli/.ci/package.sh + - name: Archive artifacts + uses: actions/upload-artifact@v3 + with: + name: Linux + path: | + cli/dist/deb + + build-on-macos: + name: Build, sign and notarize .pkg files for Mac + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + - name: Get Git History + run: git fetch --unshallow --filter=blob:none --tags --force + - name: Set Version + id: set-version + run: | + TAG_REGEX="^refs/tags/(v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?)$" + if [[ ${{ github.ref }} =~ $TAG_REGEX ]]; then + echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT + else + echo "version=$(git describe --tags --long --match 'v*')" >> $GITHUB_OUTPUT + fi + - uses: actions/setup-node@v3 + with: + node-version: '16' + - name: Install the Apple certificate and provisioning profile + env: + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + run: | + # create variables + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + + # import certificate from secrets + echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH + + # create temporary keychain + security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + + # import certificate to keychain + security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH + security list-keychain -d user -s $KEYCHAIN_PATH + + - name: Build, sign, and notarize the installer packages + env: + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + APPLEID_PASSWORD: ${{ secrets.APPLEID_PASSWORD }} + APPLEID: ${{ secrets.APPLEID }} + APPLEID_TEAM: ${{ secrets.APPLEID_TEAM }} + SIGNING_ID: ${{ secrets.SIGNING_ID }} + + # Note: oclif requires the env var OSX_KEYCHAIN to know where the keychain is + run: | + CLI_VERSION=${{ steps.set-version.outputs.version }} node cli/.ci/set-package-vars.js + + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $OSX_KEYCHAIN + OSX_KEYCHAIN=$RUNNER_TEMP/app-signing.keychain-db CI_CD_BUILD=1 cli/.ci/package.sh + + node cli/.ci/notarize.js cli/dist/macos/*.pkg + spctl --assess -vv --type install cli/dist/macos/*.pkg + + - name: Clean up keychain + if: ${{ always() }} + run: | + security delete-keychain $RUNNER_TEMP/app-signing.keychain-db + + - name: Archive Artifacts + uses: actions/upload-artifact@v3 + with: + name: MacOS + path: | + cli/dist/macos + + release: + needs: + - build-on-ubuntu + - build-on-macos + runs-on: ubuntu-22.04 + steps: + - name: Check Tag + id: check-tag + run: | + TAG_REGEX="^refs/tags/(v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?)$" + if [[ ${{ github.ref }} =~ $TAG_REGEX ]]; then + echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT + echo "release=true" >> $GITHUB_OUTPUT + else + echo "release=false" >> $GITHUB_OUTPUT + fi + + - name: Download Release Artifacts + if: ${{ steps.check-tag.outputs.release == 'true' }} + uses: actions/download-artifact@v3 + with: + path: artifacts + + - name: Create Release + if: ${{ steps.check-tag.outputs.release == 'true' }} + uses: ncipollo/release-action@v1.12.0 + with: + artifacts: "artifacts/Linux/*.deb,artifacts/MacOS/*.pkg" + tag: ${{ steps.check-tag.outputs.version }} + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cb2ec11 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +**/node_modules +lib/graphql.schema.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..9c304a9 --- /dev/null +++ b/README.md @@ -0,0 +1,188 @@ +# NowSecure CLI + +## Overview + +The NowSecure CLI is a tool that allows users to interact with the NowSecure Platform. It is a command line interface that allows users to perform a variety of tasks, including: + +* Uploading Applications to NowSecure Platform. +* Accessing assessment data. +* Managing your NowSecure Organization including sending invitations. + +## User's Guide + +### Getting Started + +### Prerequisites + +The following is needed to use the ns-cli: + +* A valid NowSecure Platform account. +* A valid NowSecure Platform API token. Instructions on how to acquire this can be found in the NowSecure support center document [Creating an API Bearer Token in Platform](https://support.nowsecure.com/hc/en-us/articles/7499657262093-Creating-an-API-Bearer-Token-in-Platform) +* If you are using a single tenant deployment of NowSecure Platform, you will need to specify the URLs of your deployment during configuration. Please be sure to have the following URLs available: + * The URL of your NowSecure Platform REST API. This is the URL that you will use to access the NowSecure Platform API. This URL will be in the format of `lab-api..nowsecure.com`. + * The URL of your NowSecure Graph API. This is the URL that you will use to access the NowSecure Graph API. This URL will be in the format of `api..nowsecure.com`. + * The URL of your NowSecure Platform UI. This is the URL that you will use to access the NowSecure Platform UI. This URL will be in the format of `app..nowsecure.com`. + +### Install + +1. Get binary from [Releases](https://github.com/nowsecure/nowsecure-platform-cli/releases) +2. Right click the .pkg file and select `run`. + +### Configure + +1. After the `ns-cli` has been installed on your system, run `ns-cli configure` to configure the CLI with your NowSecure Platform Account. +2. The first prompt will ask you to enter the profile you are using. Hit enter to select the default profile of `default`. + + **Note:** Most users will only need to use the default profile. +3. The next prompt will ask you to enter the Platform API token that you will be using. Paste this into the field provided and hit enter. +4. The next prompt will ask you to enter the Graphql endpoint for the NowSecure Platform. You can just hit enter if you are using the CLI to interact with the default production instance of NowSecure Platform. If you are using a single tenant deployment of NowSecure Platform, you will need to enter the URL of your Graphql endpoint. This URL will be in the format of `api..nowsecure.com`. +5. The next prompt will ask you to enter the REST endpoint for the NowSecure Platform. You can just hit enter if you are using the CLI to interact with the default production instance of NowSecure Platform. If you are using a single tenant deployment of NowSecure Platform, you will need to enter the URL of your REST endpoint. This URL will be in the format of `lab-api..nowsecure.com`. +6. The next prompt and final will ask you to enter the UI Server for the NowSecure platform. You can just hit enter if you are using the CLI to interact with the default production instance of NowSecure Platform. If you are using a single tenant deployment of NowSecure Platform, you will need to enter the URL of your UI Server. This URL will be in the format of `app..nowsecure.com`. + +Once done, verify that the CLI functions as expected by running `ns-cli app list`. A listing of the apps in your platform account will be displayed. If desired, you can run `ns-cli app list --json` to return the results in json format. Example: + +```bash +✗ ns-cli app list +REF TITLE PLATFORM PACKAGE GROUP +9fc8a97e-2044-11eb-80b5-snip "Business Suite" ios com.facebook.PageAdminApp "Auto Group" +952801a2-2a96-11eb-80b5-snip Disney+ android com.disney.disneyplus "Auto Group" +0f377a8a-2b51-11eb-b2b8-snip Strava ios com.strava.stravaride TriageGroup +dcf30d7a-2c16-11eb-80b5-snip Facebook ios com.facebook.Facebook "Cool Group" +9d691706-3181-11eb-80b5-snip Darksky ios com.jackadam.darksky "Auto Group" +``` + +### Usage + +Running `ns-cli help` will provide a top level list of the options that are available via the CLI: + +``` +$ ns-cli help +VERSION + @nowsecure/cli/1.0.0-alpha.2 darwin-arm64 node-v16.19.1 + +USAGE + $ ns-cli [COMMAND] + +TOPICS + app Commands to manipulate applications for analysis + assessment Commands to retrieve assessment data + organization Commands for the user's organization + plugins List installed plugins. + user Commands for users & accounts + +COMMANDS + app Commands to manipulate applications for analysis + assessment Commands to retrieve assessment data + autocomplete display autocomplete installation instructions + configure + help Display help for ns-cli. + organization Commands for the user's organization + plugins List installed plugins. + user Commands for users & accounts + ``` +Options are as follows + +#### app + +App commands provide steps that can be used to manipulate application binaries for analysis. The following commands are available: + +* **app archive** Allows you to Archive or Unarchive an application that has been uploaded to NowSecure Platform. +* **app config** Retrieve the analysis configuration for an application that has been uploaded to NowSecure Platform +* **app create** Create an app resource without a binary +* **app last-assessment**: Show the details and findings of an assessment based on platform (`ios` or `android`) and package name (`com.facebook.katana`). If the app exists in multiple groups, provide the group reference using the `-g` or `--group` option. +* **app list** List available applications in your platform account. +* **app process** Upload and analyze an application binary. +* **app update** Update the application's analysis configuration. +* **app upload** Upload an application binary. +* **app vulnerabilities** Show application vulnerabilities + +You can use the `--help` option to get more details on each of the options above. + + +#### assessment + +Assessment commands are used to interact with assessments created in in NowSecure Platform. The following commands are available: + +* **assessment cancel** Cancel a running assessment +* **assessment github-snapshot** Create a SARIF report from an assessment +* **assessment list** List assessments in your NowSecure Platform account +* **assessment raw** Get the raw data for an assessment +* **assessment sarif** Create a SARIF report from an assessment +* **assessment show** Show the details and findings of an assessment +* **assessment start** Start an assessment + +You can use the `--help` option to get more details on each of the options above. + +#### autocomplete + +Running `ns-cli autocomplete` will provide details on how to integrate the ns-cli into your `.zshrc` to perform autocomplete actions. + +#### configure + +Configure is described above in the [Configure](#configure) section. + +#### help + +Help provides help for the ns-cli. + +#### organization + +Organization commands provide steps that can be used to manipulate an organization within NowSecure Platform. The following commands are available: + +* **organization groups** Returns the groups that have been configured in an NowSecure Platform organization. +* **organization invitations** List invitations that have been created within your NowSecure Platform organization. +* **organization invite** Create an invitiation to add someone to your NowSecure Platform organization. +* **organization revoke-invitation** Revoke an invitation that has been created in your NowSecure Platform organization. +* **organization users** List the users that exist in your NowSecure Platform organization. + +You can use the `--help` option to get more details on each of the options above. + +#### plugins + +The Plugins options will list plugins that have been added to the ns-cli. + +#### user + +User commands provide steps that can be used to manipulate users within NowSecure Platform. The following commands are available: + +* **user account** Get the user details from NowSecure Platform for the user account that was used to create the token that the ns-cli has been configured to use. +* **user groups** Get the group membership from NowSecure Platform for the user account that was used to create the token that the ns-cli has been configured + +You can use the `--help` option to get more details on each of the options above. + + + +## Developer's Guide + +This is a Monorepo containing the following items. + - The [NowSecure Sarif Conversion Module](./sarif/README.md) + - The [NowSecure GitHub Snapshot Module](./github-snapshot/README.md) + - The [NowSecure REST and GQL API Library](./lib/README.md) + - The [NowSecure CLI](./cli/README.md) + +## Building + +> Ensure you are using Node >= 16 and have `yarn` installed before proceeding. + +If you are looking to build a specific library or tool, see +[Building specific tools](#building-specific-tools). + +Run the following to build everything: +```sh +yarn run build +``` + +Run the following to clean up all build artifacts: +```sh +yarn run clean +``` + +### Building specific tools + +| Tool | Build Command | Clean Command | +|:--|:--|:--| +| [NowSecure REST and GQL API Library](./lib/README.md) | `yarn run build:lib` | `yarn run clean:lib` | +| [NowSecure Sarif Conversion Module](./sarif/README.md) | `yarn run build:sarif` | `yarn run clean:sarif` | +| [NowSecure GitHub Snapshot Module](./github-snapshot/README.md) | `yarn run build:github-snapshot` | `yarn run clean:github-snapshot` | +| [NowSecure CLI](./cli/README.md) | `yarn run build:cli` | `yarn run clean:cli` | + diff --git a/cli/.ci/notarize.js b/cli/.ci/notarize.js new file mode 100644 index 0000000..5b4cbc5 --- /dev/null +++ b/cli/.ci/notarize.js @@ -0,0 +1,52 @@ +#!/usr/bin/env node + +const fs = require("fs"); +const path = require("path"); +const { notarize } = require("@electron/notarize"); + +const APPLEID = process.env.APPLEID; +const APPLEID_TEAM = process.env.APPLEID_TEAM; +const APPLEID_PASSWORD = process.env.APPLEID_PASSWORD; + +async function processOne(fileName) { + const fullPath = path.normalize(path.resolve(fileName)); + console.log(`Notarizing ${fullPath}`); + await notarize({ + tool: "notarytool", + appPath: fullPath, + appleId: APPLEID, + appleIdPassword: APPLEID_PASSWORD, + teamId: APPLEID_TEAM, + }); + console.log(`${fullPath} completed`); +} + +async function processAll() { + const files = process.argv.slice(2); + + if (!APPLEID) { + console.log("No Apple ID specified, skipping"); + return; + } + + if (!(APPLEID_PASSWORD && APPLEID_TEAM)) { + console.error("APPLEID_PASSWORD and APPLEID_TEAM are required"); + process.exit(1); + } + + const promises = []; + for (const file of files) { + const stat = fs.statSync(file); + if (stat.isFile()) { + promises.push(processOne(file)); + } + } + + if (promises.length === 0) { + console.log("No files found"); + } else { + await Promise.all(promises); + } +} + +Promise.resolve().then(processAll); diff --git a/cli/.ci/package.sh b/cli/.ci/package.sh new file mode 100755 index 0000000..2086d28 --- /dev/null +++ b/cli/.ci/package.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +set -exv + +HERE="$(cd "$(dirname "$0")" && pwd)" +SRC="$(cd "$(dirname "$0")"/.. && pwd)" +OS=$(uname) + +cd "${SRC}" + +# build the libraries for release + +function build () { + if [ "${CI_CD_BUILD}" ]; then + yarn --cwd "../$1" unlink || true + rm -rf "../$1/node_modules" + yarn --cwd "../$1" install --frozen-lockfile + fi + yarn --cwd "../$1" build + yarn --cwd "../$1" test +} + +function copy_lib() { + # use yarn pack to export only what a yarn publish would do + yarn --cwd "../$1" pack -f "tmp/$1.tgz" + tar -C tmp -xf "tmp/$1.tgz" + mv tmp/package "tmp/$1" +} + +# Must be in this order, sarif and github-snapshot depend on lib +build lib +build github-snapshot +build sarif + +if [ -L "node_modules/@nowsecure/platform-lib" ]; then + yarn unlink @nowsecure/platform-lib @nowsecure/github-snapshot @nowsecure/sarif + yarn install --force --frozen-lockfile + LINKED=1 +fi + +build cli +yarn prepack + +# export the library to the place that `oclif pack` will look for it +rm -rf tmp +mkdir tmp +copy_lib lib +copy_lib github-snapshot +copy_lib sarif + +if [[ "$OS" == 'Darwin' ]]; then + yarn package-macos +else + yarn package-deb +fi + +if [ -n "${LINKED}" ]; then + yarn link @nowsecure/platform-lib @nowsecure/github-snapshot @nowsecure/sarif +fi \ No newline at end of file diff --git a/cli/.ci/set-package-vars.js b/cli/.ci/set-package-vars.js new file mode 100644 index 0000000..79a0130 --- /dev/null +++ b/cli/.ci/set-package-vars.js @@ -0,0 +1,28 @@ +const fs = require("fs"); +const path = require("path"); + +const DIRS = [".", "lib", "github-snapshot", "sarif", "cli"]; + +const load = (dir) => + JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf-8")); + +const save = (dir, pkg) => + fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify(pkg, 0, 2)); + +const VERSION = process.env["CLI_VERSION"]; +const SIGNING_ID = process.env["SIGNING_ID"]; +const SEMVER = VERSION.startsWith("v") ? VERSION.substring(1) : VERSION; + +if (SEMVER) { + for (const dir of DIRS) { + const pkg = load(dir); + pkg.version = SEMVER; + save(dir, pkg); + } +} + +if (SIGNING_ID) { + const cli = load("cli"); + cli.oclif.macos.sign = SIGNING_ID; + save("cli", cli); +} diff --git a/cli/.eslintignore b/cli/.eslintignore new file mode 100644 index 0000000..ac83b56 --- /dev/null +++ b/cli/.eslintignore @@ -0,0 +1,4 @@ +/node_modules +/dist +/lib +/tmp \ No newline at end of file diff --git a/cli/.eslintrc.json b/cli/.eslintrc.json new file mode 100644 index 0000000..e94c72a --- /dev/null +++ b/cli/.eslintrc.json @@ -0,0 +1,16 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@typescript-eslint/no-unused-vars": [ + "warn", + { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" } + ] + } +} diff --git a/cli/.gitignore b/cli/.gitignore new file mode 100644 index 0000000..3b5ed83 --- /dev/null +++ b/cli/.gitignore @@ -0,0 +1,8 @@ +*-debug.log +*-error.log +/.nyc_output +/dist +/lib +/tmp +oclif.manifest.json +/src/version.ts \ No newline at end of file diff --git a/cli/.mocharc.json b/cli/.mocharc.json new file mode 100644 index 0000000..42ff67e --- /dev/null +++ b/cli/.mocharc.json @@ -0,0 +1,7 @@ +{ + "require": ["test/helpers/init.js", "ts-node/register"], + "watch-extensions": ["ts"], + "recursive": true, + "reporter": "spec", + "timeout": 60000 +} diff --git a/cli/.prettierignore b/cli/.prettierignore new file mode 100644 index 0000000..8100e24 --- /dev/null +++ b/cli/.prettierignore @@ -0,0 +1,4 @@ +/node_modules +/dist +/tmp +README.md \ No newline at end of file diff --git a/cli/LICENSE b/cli/LICENSE new file mode 100644 index 0000000..60c35f8 --- /dev/null +++ b/cli/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 NowSecure + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/cli/README.md b/cli/README.md new file mode 100644 index 0000000..a2105a8 --- /dev/null +++ b/cli/README.md @@ -0,0 +1,1295 @@ +# ns-cli + +NowSecure command line tool + +[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io) +[![Version](https://img.shields.io/npm/v/oclif-hello-world.svg)](https://npmjs.org/package/oclif-hello-world) +[![CircleCI](https://circleci.com/gh/oclif/hello-world/tree/main.svg?style=shield)](https://circleci.com/gh/oclif/hello-world/tree/main) +[![Downloads/week](https://img.shields.io/npm/dw/oclif-hello-world.svg)](https://npmjs.org/package/oclif-hello-world) +[![License](https://img.shields.io/npm/l/oclif-hello-world.svg)](https://github.com/oclif/hello-world/blob/main/package.json) + + +* [ns-cli](#ns-cli) +* [Usage](#usage) +* [Commands](#commands) + + +# Usage + + +```sh-session +$ npm install -g @nowsecure/platform-cli +$ ns-cli COMMAND +running command... +$ ns-cli (--version) +@nowsecure/platform-cli/1.0.0-beta.3 darwin-x64 node-v16.19.1 +$ ns-cli --help [COMMAND] +USAGE + $ ns-cli COMMAND +... +``` + + +# Commands + + +* [`ns-cli app`](#ns-cli-app) +* [`ns-cli app archive [PLATFORM] [PACKAGENAME]`](#ns-cli-app-archive-platform-packagename) +* [`ns-cli app config [PLATFORM] [PACKAGENAME]`](#ns-cli-app-config-platform-packagename) +* [`ns-cli app create PLATFORM PACKAGENAME`](#ns-cli-app-create-platform-packagename) +* [`ns-cli app last [PLATFORM] [PACKAGENAME]`](#ns-cli-app-last-platform-packagename) +* [`ns-cli app last-assessment [PLATFORM] [PACKAGENAME]`](#ns-cli-app-last-assessment-platform-packagename) +* [`ns-cli app list`](#ns-cli-app-list) +* [`ns-cli app process BINARY`](#ns-cli-app-process-binary) +* [`ns-cli app update [PLATFORM] [PACKAGENAME] [STDIN]`](#ns-cli-app-update-platform-packagename-stdin) +* [`ns-cli app upload BINARY`](#ns-cli-app-upload-binary) +* [`ns-cli app vulnerabilities [PLATFORM] [PACKAGENAME]`](#ns-cli-app-vulnerabilities-platform-packagename) +* [`ns-cli assessment`](#ns-cli-assessment) +* [`ns-cli assessment cancel ASSESSMENT`](#ns-cli-assessment-cancel-assessment) +* [`ns-cli assessment github-snapshot ASSESSMENT`](#ns-cli-assessment-github-snapshot-assessment) +* [`ns-cli assessment list`](#ns-cli-assessment-list) +* [`ns-cli assessment raw ASSESSMENT`](#ns-cli-assessment-raw-assessment) +* [`ns-cli assessment sarif ASSESSMENT`](#ns-cli-assessment-sarif-assessment) +* [`ns-cli assessment show ASSESSMENT`](#ns-cli-assessment-show-assessment) +* [`ns-cli assessment start [PLATFORM] [PACKAGENAME]`](#ns-cli-assessment-start-platform-packagename) +* [`ns-cli autocomplete [SHELL]`](#ns-cli-autocomplete-shell) +* [`ns-cli configure`](#ns-cli-configure) +* [`ns-cli help [COMMANDS]`](#ns-cli-help-commands) +* [`ns-cli organization`](#ns-cli-organization) +* [`ns-cli organization groups`](#ns-cli-organization-groups) +* [`ns-cli organization invitations`](#ns-cli-organization-invitations) +* [`ns-cli organization invite EMAIL`](#ns-cli-organization-invite-email) +* [`ns-cli organization revoke-invitation [EMAIL]`](#ns-cli-organization-revoke-invitation-email) +* [`ns-cli organization users`](#ns-cli-organization-users) +* [`ns-cli plugins`](#ns-cli-plugins) +* [`ns-cli plugins:install PLUGIN...`](#ns-cli-pluginsinstall-plugin) +* [`ns-cli plugins:inspect PLUGIN...`](#ns-cli-pluginsinspect-plugin) +* [`ns-cli plugins:install PLUGIN...`](#ns-cli-pluginsinstall-plugin-1) +* [`ns-cli plugins:link PLUGIN`](#ns-cli-pluginslink-plugin) +* [`ns-cli plugins:uninstall PLUGIN...`](#ns-cli-pluginsuninstall-plugin) +* [`ns-cli plugins:uninstall PLUGIN...`](#ns-cli-pluginsuninstall-plugin-1) +* [`ns-cli plugins:uninstall PLUGIN...`](#ns-cli-pluginsuninstall-plugin-2) +* [`ns-cli plugins update`](#ns-cli-plugins-update) +* [`ns-cli user`](#ns-cli-user) +* [`ns-cli user account`](#ns-cli-user-account) +* [`ns-cli user groups`](#ns-cli-user-groups) + +## `ns-cli app` + +Commands to manipulate applications for analysis + +``` +USAGE + $ ns-cli app + +DESCRIPTION + Commands to manipulate applications for analysis +``` + +_See code: [dist/commands/app/index.ts](https://github.com/cosdon/nowsecure-cli/blob/v1.0.0-beta.3/dist/commands/app/index.ts)_ + +## `ns-cli app archive [PLATFORM] [PACKAGENAME]` + +Archive or unarchive an app + +``` +USAGE + $ ns-cli app archive [PLATFORM] [PACKAGENAME] [--token ] [--graphql ] [--rest ] [--ui + ] [--profile ] [--config-file ] [--json] [-g ] [--group-ref ] [-r ] [-u] + +ARGUMENTS + PLATFORM (android|ios) Platform + PACKAGENAME Package identifier (e.g. com.example.app) + +FLAGS + -g, --group= Group name + -r, --ref= Application reference + -u, --unarchive unarchive the application + --group-ref= Group reference + +GLOBAL FLAGS + --config-file= Path to the config file + --graphql= URL of the graphql server + --json Format output as json. + --profile= Profile to read from ~/.nsclirc + --rest= URL of the REST server + --token= Platform API token + --ui= URL of the UI server + +DESCRIPTION + Archive or unarchive an app + +EXAMPLES + $ ns-cli app archive android com.example.package --group "My group" + + $ ns-cli app archive --app=d296eaea-f714-4e2d-8930-023b3f2bb12a --unarchive +``` + +## `ns-cli app config [PLATFORM] [PACKAGENAME]` + +Retrieve the analysis configuration + +``` +USAGE + $ ns-cli app config [PLATFORM] [PACKAGENAME] [--token ] [--graphql ] [--rest ] [--ui + ] [--profile ] [--config-file ] [--json] [-g ] [--group-ref ] [-r ] + +ARGUMENTS + PLATFORM (android|ios) Platform + PACKAGENAME Package identifier (e.g. com.example.app) + +FLAGS + -g, --group= Group name + -r, --ref= Application reference + --group-ref= Group reference + +GLOBAL FLAGS + --config-file= Path to the config file + --graphql= URL of the graphql server + --json Format output as json. + --profile= Profile to read from ~/.nsclirc + --rest= URL of the REST server + --token= Platform API token + --ui= URL of the UI server + +DESCRIPTION + Retrieve the analysis configuration + +EXAMPLES + $ ns-cli app config +``` + +## `ns-cli app create PLATFORM PACKAGENAME` + +Create an app resource without a binary + +``` +USAGE + $ ns-cli app create PLATFORM PACKAGENAME [--token ] [--graphql ] [--rest ] [--ui ] + [--profile ] [--config-file ] [--json] [-g ] [--group-ref ] + +ARGUMENTS + PLATFORM (android|ios) Platform + PACKAGENAME Package identifier (e.g. com.example.app) + +FLAGS + -g, --group= Group name + --group-ref= Group reference + +GLOBAL FLAGS + --config-file= Path to the config file + --graphql= URL of the graphql server + --json Format output as json. + --profile= Profile to read from ~/.nsclirc + --rest= URL of the REST server + --token= Platform API token + --ui= URL of the UI server + +DESCRIPTION + Create an app resource without a binary + +EXAMPLES + $ ns-cli app create android com.example.package --group "My group" +``` + +## `ns-cli app last [PLATFORM] [PACKAGENAME]` + +Show the details and findings of the last complete assessment for an application + +``` +USAGE + $ ns-cli app last [PLATFORM] [PACKAGENAME] [--token ] [--graphql ] [--rest ] [--ui + ] [--profile ] [--config-file ] [--json] [-a | -m critical|c|high|h|medium|m|low|l|info|i | -w + | -i | -e ] [-f] [-s] [-c] [-d] [-b] [-g ] [--group-ref ] [-r ] + +ARGUMENTS + PLATFORM (android|ios) Platform + PACKAGENAME Package identifier (e.g. com.example.app) + +FLAGS + -a, --all-findings show all findings + -b, --[no-]build Include details of the build + -c, --[no-]config Include the analysis configuration + -d, --dependencies Include the application dependency analysis + -e, --exclude=... Findings that should always be excluded + -f, --[no-]findings Include the findings report + -g, --group= Group name + -i, --include=... Findings that should always be included + -m, --min-severity=