@govuk-pay/cli 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/package.json +1 -1
  2. package/resources/legacy-ruby-cli/.rspec +1 -0
  3. package/resources/legacy-ruby-cli/.rubocop.yml +26 -0
  4. package/resources/legacy-ruby-cli/.ruby-version +1 -0
  5. package/resources/legacy-ruby-cli/Gemfile +24 -0
  6. package/resources/legacy-ruby-cli/Gemfile.lock +1431 -0
  7. package/resources/legacy-ruby-cli/README.md +142 -0
  8. package/resources/legacy-ruby-cli/bin/pay +31 -0
  9. package/resources/legacy-ruby-cli/config/generate-secrets.yml +9 -0
  10. package/resources/legacy-ruby-cli/config/secrets.yml +581 -0
  11. package/resources/legacy-ruby-cli/config/service_secrets.yml +174 -0
  12. package/resources/legacy-ruby-cli/lib/pay_cli/aws/document.rb +23 -0
  13. package/resources/legacy-ruby-cli/lib/pay_cli/aws/services.rb +47 -0
  14. package/resources/legacy-ruby-cli/lib/pay_cli/aws/tokens.rb +161 -0
  15. package/resources/legacy-ruby-cli/lib/pay_cli/commands/aws.rb +51 -0
  16. package/resources/legacy-ruby-cli/lib/pay_cli/commands/browse.rb +31 -0
  17. package/resources/legacy-ruby-cli/lib/pay_cli/commands/doctor.rb +154 -0
  18. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/app_client.rb +216 -0
  19. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/config.rb +138 -0
  20. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/config.yaml +192 -0
  21. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/docker.rb +36 -0
  22. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/docker-compose.erb +270 -0
  23. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/end-to-end.erb +30 -0
  24. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/localstack/init-aws.sh +70 -0
  25. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/naxsi/readme.md +1 -0
  26. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/postgres/docker-entrypoint-initdb.d/make_payments_databases.sql +26 -0
  27. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/adminusers.env +49 -0
  28. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/cardid.env +2 -0
  29. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/connector.env +70 -0
  30. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/demo-service.env +10 -0
  31. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/frontend.env +12 -0
  32. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/java_app.env +1 -0
  33. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ledger.env +7 -0
  34. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/products-ui.env +14 -0
  35. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/products.env +25 -0
  36. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/publicapi.env +13 -0
  37. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/publicauth.env +13 -0
  38. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/selfservice.env +21 -0
  39. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/frontend-proxy.crt +18 -0
  40. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/products-ui-proxy.crt +20 -0
  41. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/selfservice-proxy.crt +20 -0
  42. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/stubs-proxy.crt +18 -0
  43. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/frontend-proxy.key +28 -0
  44. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/products-ui-proxy.key +28 -0
  45. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/selfservice-proxy.key +28 -0
  46. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/stubs-proxy.key +28 -0
  47. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/make-selfsigned.sh +2 -0
  48. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/stubs.env +12 -0
  49. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/toolbox.env +5 -0
  50. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/webhooks.env +9 -0
  51. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/image_extractor.rb +20 -0
  52. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local.rb +430 -0
  53. package/resources/legacy-ruby-cli/lib/pay_cli/commands/schema.rb +36 -0
  54. package/resources/legacy-ruby-cli/lib/pay_cli/commands/secrets.rb +114 -0
  55. package/resources/legacy-ruby-cli/lib/pay_cli/commands/ssm.rb +111 -0
  56. package/resources/legacy-ruby-cli/lib/pay_cli/commands/tf.rb +90 -0
  57. package/resources/legacy-ruby-cli/lib/pay_cli/commands/tunnel/services.yml +49 -0
  58. package/resources/legacy-ruby-cli/lib/pay_cli/config.rb +27 -0
  59. package/resources/legacy-ruby-cli/lib/pay_cli/ec2.rb +38 -0
  60. package/resources/legacy-ruby-cli/lib/pay_cli/entry_point.rb +52 -0
  61. package/resources/legacy-ruby-cli/lib/pay_cli/environment.rb +25 -0
  62. package/resources/legacy-ruby-cli/lib/pay_cli/logger.rb +3 -0
  63. package/resources/legacy-ruby-cli/lib/pay_cli/logs.rb +248 -0
  64. package/resources/legacy-ruby-cli/lib/pay_cli/naming.rb +44 -0
  65. package/resources/legacy-ruby-cli/lib/pay_cli/secrets.rb +276 -0
  66. package/resources/legacy-ruby-cli/lib/pay_cli/stop_yubico_authenticator.rb +10 -0
  67. package/resources/legacy-ruby-cli/lib/pay_cli/ykman_oath_credential_config.rb +70 -0
  68. package/resources/legacy-ruby-cli/lib/zeitwerk_setup.rb +5 -0
  69. package/resources/legacy-ruby-cli/package-lock.json +6 -0
  70. package/resources/legacy-ruby-cli/rds_access/connect.sh +149 -0
  71. package/resources/legacy-ruby-cli/spec/.rubocop.yml +2 -0
  72. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.complex +34 -0
  73. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.complex_differing_froms +33 -0
  74. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.no_from +3 -0
  75. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.simple +5 -0
  76. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.simple_no_tag +5 -0
  77. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.with_sha +5 -0
  78. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.with_sha_no_tag +5 -0
  79. package/resources/legacy-ruby-cli/spec/lib/pay_cli/commands/local/image_extractor_spec.rb +55 -0
  80. package/resources/legacy-ruby-cli/spec/naming_spec.rb +83 -0
  81. package/resources/legacy-ruby-cli/spec/spec_helper.rb +106 -0
  82. package/resources/legacy-ruby-cli/vulnerability_scan/.nvmrc +1 -0
  83. package/resources/legacy-ruby-cli/vulnerability_scan/generate_vulnerability_report.js +91 -0
  84. package/resources/legacy-ruby-cli/vulnerability_scan/reports/.gitkeep +0 -0
  85. package/resources/legacy-ruby-cli/vulnerability_scan/scan.sh +57 -0
  86. package/src/commands/browse.js +2 -2
  87. package/src/commands/legacy.js +5 -2
  88. package/src/core/constants.js +7 -10
  89. package/src/util/payCliExec.js +18 -1
@@ -0,0 +1,83 @@
1
+ # rubocop:disable Metrics/BlockLength
2
+ RSpec.describe 'pay naming' do
3
+ # rubocop:enable Metrics/BlockLength
4
+ context 'asg names' do
5
+ it 'frontend www weirdness' do
6
+ expect(PayCLI::Naming.asg_name(
7
+ 'env-name',
8
+ 'frontend'
9
+ )).to eq('env-name-www-ecs-appserver')
10
+ end
11
+
12
+ it 'cardid normalness' do
13
+ expect(PayCLI::Naming.asg_name(
14
+ 'env-name',
15
+ 'cardid'
16
+ )).to eq('env-name-cardid-ecs-appserver')
17
+ end
18
+ end
19
+
20
+ context 'elb names' do
21
+ it 'elb names to be correct' do
22
+ names = PayCLI::Naming.elb_names(
23
+ 'env-name',
24
+ %w(adminusers connector products publicauth notifications ledger)
25
+ )
26
+ expected_names = {
27
+ 'env-name-adminusers-ecs-elb' => 'adminusers',
28
+ 'env-name-connector-ecs-elb' => 'connector',
29
+ 'env-name-products-ecs-elb' => 'products',
30
+ 'env-name-publicauth-ecs-elb' => 'publicauth',
31
+ 'env-name-notices-ecs-elb' => 'notifications',
32
+ 'env-name-ledger-ecs-elb' => 'ledger',
33
+ }
34
+
35
+ expect(names).to eq(expected_names)
36
+ end
37
+ end
38
+
39
+ context 'domain names' do
40
+ it 'domain names to be correct' do
41
+ expected_domain_names = %w(
42
+ pymnt.uk pymnt.uk pymnt.uk
43
+ payments.service.gov.uk payments.service.gov.uk payments.service.gov.uk
44
+ pymnt.uk
45
+ )
46
+
47
+ actual_domain_names = %w(
48
+ ci dev test deploy staging production blah
49
+ ).map { |env| PayCLI::Naming.domain_name(env) }
50
+
51
+ expect(actual_domain_names).to eq(expected_domain_names)
52
+ end
53
+ end
54
+
55
+ context 'bucket names' do
56
+ it 'ci bucket is correct' do
57
+ expected_name = 'pay-govuk-terraform-state-ci'
58
+ expect(%w( ci dev test ).all? do |e|
59
+ PayCLI::Naming.bucket_name(e) == expected_name
60
+ end).to eq(true)
61
+ end
62
+
63
+ it 'deploy bucket is correct' do
64
+ expected_name = 'pay-govuk-terraform-state-deploy'
65
+ expect(%w( staging production deploy ).all? do |e|
66
+ PayCLI::Naming.bucket_name(e) == expected_name
67
+ end).to eq(true)
68
+ end
69
+
70
+ it 'arbtrary-env bucket is correct' do
71
+ expect(PayCLI::Naming.bucket_name('arbitrary')).to eq('pay-govuk-terraform-state-arbitrary')
72
+ end
73
+ end
74
+
75
+ context 'db names' do
76
+ it 'resolves instance name with no version specified' do
77
+ service = { 'service_name' => 'connector' }
78
+ expect(
79
+ PayCLI::Naming.db_name('env-1', service)
80
+ ).to eq('env-1-connector-rds-0')
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,106 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+
17
+ RSpec.configure do |config|
18
+ # rspec-expectations config goes here. You can use an alternate
19
+ # assertion/expectation library such as wrong or the stdlib/minitest
20
+ # assertions if you prefer.
21
+ config.expect_with :rspec do |expectations|
22
+ # This option will default to `true` in RSpec 4. It makes the `description`
23
+ # and `failure_message` of custom matchers include text for helper methods
24
+ # defined using `chain`, e.g.:
25
+ # be_bigger_than(2).and_smaller_than(4).description
26
+ # # => "be bigger than 2 and smaller than 4"
27
+ # ...rather than:
28
+ # # => "be bigger than 2"
29
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
30
+ end
31
+
32
+ # rspec-mocks config goes here. You can use an alternate test double
33
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
34
+ config.mock_with :rspec do |mocks|
35
+ # Prevents you from mocking or stubbing a method that does not exist on
36
+ # a real object. This is generally recommended, and will default to
37
+ # `true` in RSpec 4.
38
+ mocks.verify_partial_doubles = true
39
+ end
40
+
41
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
42
+ # have no way to turn it off -- the option exists only for backwards
43
+ # compatibility in RSpec 3). It causes shared context metadata to be
44
+ # inherited by the metadata hash of host groups and examples, rather than
45
+ # triggering implicit auto-inclusion in groups with matching metadata.
46
+ config.shared_context_metadata_behavior = :apply_to_host_groups
47
+
48
+ # The settings below are suggested to provide a good initial experience
49
+ # with RSpec, but feel free to customize to your heart's content.
50
+ # rubocop:disable Style/BlockComments
51
+ =begin
52
+ # rubocop:enable Style/BlockComments
53
+ # This allows you to limit a spec run to individual examples or groups
54
+ # you care about by tagging them with `:focus` metadata. When nothing
55
+ # is tagged with `:focus`, all examples get run. RSpec also provides
56
+ # aliases for `it`, `describe`, and `context` that include `:focus`
57
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
58
+ config.filter_run_when_matching :focus
59
+
60
+ # Allows RSpec to persist some state between runs in order to support
61
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
62
+ # you configure your source control system to ignore this file.
63
+ config.example_status_persistence_file_path = "spec/examples.txt"
64
+
65
+ # Limits the available syntax to the non-monkey patched syntax that is
66
+ # recommended. For more details, see:
67
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
68
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
69
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
70
+ config.disable_monkey_patching!
71
+
72
+ # This setting enables warnings. It's recommended, but in some cases may
73
+ # be too noisy due to issues in dependencies.
74
+ config.warnings = true
75
+
76
+ # Many RSpec users commonly either run the entire suite or an individual
77
+ # file, and it's useful to allow more verbose output when running an
78
+ # individual spec file.
79
+ if config.files_to_run.one?
80
+ # Use the documentation formatter for detailed output,
81
+ # unless a formatter has already been configured
82
+ # (e.g. via a command-line flag).
83
+ config.default_formatter = "doc"
84
+ end
85
+
86
+ # Print the 10 slowest examples and example groups at the
87
+ # end of the spec run, to help surface which specs are running
88
+ # particularly slow.
89
+ config.profile_examples = 10
90
+
91
+ # Run specs in random order to surface order dependencies. If you find an
92
+ # order dependency and want to debug it, you can fix the order by providing
93
+ # the seed, which is printed after each run.
94
+ # --seed 1234
95
+ config.order = :random
96
+
97
+ # Seed global randomization in this process using the `--seed` CLI option.
98
+ # Setting this allows you to use `--seed` to deterministically reproduce
99
+ # test failures related to randomization by passing the same `--seed` value
100
+ # as the one that triggered the failure.
101
+ Kernel.srand config.seed
102
+ =end
103
+ end
104
+
105
+ require 'zeitwerk_setup'
106
+ require_relative '../lib/pay_cli/entry_point'
@@ -0,0 +1,91 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+
4
+ const INPUT_PATH = `${path.dirname(__filename)}/reports`
5
+ const OUTPUT_PATH = `${path.dirname(__filename)}/reports`
6
+ const HEADERS = ["App name", "Release", "Vulnerability", "Severity", "Package", "Fixed version"]
7
+ const NODE_MAJOR_VERSION = process.versions.node.split('.')[0];
8
+
9
+ if (NODE_MAJOR_VERSION < 16) {
10
+ console.warn('⛔️ requires >= Node 16')
11
+ } else {
12
+ generate()
13
+ }
14
+
15
+ function generate() {
16
+ const jsonData = []
17
+ const date = new Date().toJSON().slice(0, 10);
18
+ const jsonFiles = fs.readdirSync(INPUT_PATH).filter(file => path.extname(file) === '.json')
19
+ const reportFilePath = `${OUTPUT_PATH}/vulnerability_scan_report-${date}.csv`
20
+ let parseCount = 0
21
+ let rowCount = 0
22
+ try {
23
+ jsonFiles.forEach(file => {
24
+ const appAndRelease = extractAppAndRelease(file)
25
+ const filePath = path.join(INPUT_PATH, file)
26
+ const data = fs.readFileSync(filePath, 'utf8')
27
+ const parsedData = JSON.parse(data)
28
+ const cveObjects = extractCVEObjects(parsedData["runs"][0]["results"], appAndRelease)
29
+ jsonData.push({
30
+ "CVEs": cveObjects
31
+ })
32
+ })
33
+
34
+ fs.writeFileSync(reportFilePath, HEADERS.join(',') + '\n')
35
+
36
+ jsonData.forEach(data => {
37
+ data["CVEs"].forEach(cve => {
38
+ const row = HEADERS.map(key => cve[key]).join(',')
39
+ fs.appendFileSync(reportFilePath, row + '\n')
40
+ rowCount++
41
+ })
42
+ parseCount++
43
+ })
44
+ } catch (err) {
45
+ console.error("ERROR:", err.message)
46
+ } finally {
47
+ console.log(`Parsed ${parseCount} of ${jsonFiles.length} JSON files, wrote ${rowCount} row(s) to ${reportFilePath}`)
48
+ }
49
+ }
50
+
51
+
52
+ function extractAppAndRelease(inputString) {
53
+ const regex = /^.*?(?=-\d+)/ // matches any characters at the beginning of the string that are followed by a dash and one or more digits
54
+ const match = inputString.match(regex)
55
+ if (match && match[0]) {
56
+ const release = inputString.replace(`${match[0]}-`, "").replace(".json", "")
57
+ return [match[0], release]
58
+ } else {
59
+ const fallback = inputString.replace(".json", "")
60
+ return [fallback, fallback] // fallback option
61
+ }
62
+ }
63
+
64
+ function extractCVEObjects(results, appAndRelease) {
65
+ let cveObjects = []
66
+ results.forEach(result => {
67
+ const stringArr = result["message"]["text"].split("\n").reduce((stringArr, string) => {
68
+ if (string !== "") {
69
+ stringArr.push(string
70
+ .split(", ")
71
+ .join(" ")
72
+ .trim()
73
+ )
74
+ }
75
+ return stringArr
76
+ }, [])
77
+ stringArr.push(`App name: ${appAndRelease[0]}`)
78
+ stringArr.push(`Release: ${appAndRelease[1]}`)
79
+ cveObjects.push(convertStringArrayToCVEObj(stringArr))
80
+ })
81
+ return cveObjects
82
+ }
83
+
84
+ function convertStringArrayToCVEObj(stringArr) {
85
+ const cveObj = {}
86
+ stringArr.forEach(s => {
87
+ const parts = s.split(':');
88
+ cveObj[parts[0].trim()] = parts[1].trim()
89
+ })
90
+ return cveObj
91
+ }
@@ -0,0 +1,57 @@
1
+ #!/bin/bash
2
+
3
+ # Script for scanning ECR docker vulnerabilities with "docker scout cves"
4
+ # https://docs.docker.com/engine/reference/commandline/scout_cves/
5
+
6
+ # **** Run this from the root of pay-infra to store reports in this folder. ****
7
+
8
+ # This will take about 5 minutes unless you already have the images cached locally.
9
+ # You will be prompted for your aws-vault auth/MFA code.
10
+ # The report will be stored in reports/vulnerability_scan_report-YYYY-MM-DD.csv
11
+
12
+ set -euo pipefail
13
+
14
+
15
+ ACCOUNT="staging"
16
+ ACCOUNT_ID="888564216586"
17
+ REPORTS_FOLDER="cli/vulnerability_scan/reports"
18
+
19
+ echo "🔍 checking for dependencies..."
20
+
21
+ declare -a commands=("aws" "jq" "aws-vault" "docker" "docker scout")
22
+
23
+ for i in "${!commands[@]}"; do
24
+ if ! command -v ${commands[i]} &> /dev/null
25
+ then
26
+ echo "❌ ${commands[i]}"
27
+ exit 1
28
+ else
29
+ echo "✅ ${commands[i]}"
30
+ fi
31
+ done
32
+
33
+ # Login to ECR
34
+ echo "Logging into staging ECR"
35
+ aws-vault exec $ACCOUNT -- aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin "${ACCOUNT_ID}.dkr.ecr.eu-west-1.amazonaws.com"
36
+
37
+ # Get list of govukpay repository URIs (ignore postgres, selenium etc)
38
+ REPOSITORIES="$(aws-vault exec $ACCOUNT -- aws ecr describe-repositories --no-paginate | jq -r '.repositories[].repositoryUri' | grep 'govukpay')"
39
+ if [[ -z $REPOSITORIES ]]; then
40
+ echo "Unable to find ECR repositories"
41
+ exit 1
42
+ fi
43
+
44
+ # For each repository, run scan on the latest image and save to JSON file
45
+ for REPO_URI in $REPOSITORIES
46
+ do
47
+ SHORT_REPO_NAME=$(echo "$REPO_URI"| cut -d'/' -f 3)
48
+ LATEST_TAG="$(aws-vault exec $ACCOUNT -- aws ecr describe-images --repository-name "govukpay/$SHORT_REPO_NAME" --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]' | tr -d '"')"
49
+ echo "Scanning latest image in $SHORT_REPO_NAME with tag $LATEST_TAG."
50
+ docker scout cves --format sarif --output "${REPORTS_FOLDER}/${SHORT_REPO_NAME}-${LATEST_TAG}.json" "${REPO_URI}:${LATEST_TAG}"
51
+ done
52
+
53
+ node ./cli/vulnerability_scan/generate_vulnerability_report.js
54
+
55
+ # Clean up report JSON files once done
56
+ echo "Removing JSON report files..."
57
+ rm $REPORTS_FOLDER/*.json
@@ -26,8 +26,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.logBrowseCommands = void 0;
27
27
  const path = __importStar(require("path"));
28
28
  const standardContent_js_1 = require("../core/standardContent.js");
29
- const constants_js_1 = require("../core/constants.js");
30
29
  const moduleFunctionWrapper_js_1 = require("../util/moduleFunctionWrapper.js");
30
+ const constants_1 = require("../core/constants");
31
31
  const requestableItems = new Map();
32
32
  requestableItems.set('concourse', {
33
33
  name: 'concourse page',
@@ -73,7 +73,7 @@ async function browseHandler(options) {
73
73
  const requestedItem = requestableItems.get(argumentName);
74
74
  if (requestedItem != null) {
75
75
  console.log('Usage:');
76
- console.log(` npx --package=${path.resolve(constants_js_1.rootDir)} browse ${argumentName}`);
76
+ console.log(` npx --package=${path.resolve(constants_1.rootDir)} browse ${argumentName}`);
77
77
  console.log(`browses the ${requestedItem.name}`);
78
78
  return;
79
79
  }
@@ -28,6 +28,7 @@ const payCliExec_1 = __importStar(require("../util/payCliExec"));
28
28
  const path = __importStar(require("node:path"));
29
29
  const constants_1 = require("../core/constants");
30
30
  const standardContent_1 = require("../core/standardContent");
31
+ const pathToLegacyRubyCli = path.join(constants_1.rootDir, 'resources', 'legacy-ruby-cli');
31
32
  async function legacyHandler(options) {
32
33
  const argsToPassOn = [];
33
34
  if (options.commandName !== 'legacy') {
@@ -44,7 +45,9 @@ async function proxyArrayOfArgumentsToLegacyCli(argsToPassOn) {
44
45
  const rbenvCommand = process.env.PAY_CLI_RBENV_COMMAND ?? 'rbenv';
45
46
  const shellCommand = process.env.PAY_CLI_SHELL_COMMAND ?? 'zsh';
46
47
  const whichRbenvResult = await (0, payCliExec_1.execAndReturnIO)(`which ${rbenvCommand}`);
47
- const whichBundlerResult = await (0, payCliExec_1.execAndReturnIO)(`${rbenvCommand} exec which bundle`);
48
+ const whichBundlerResult = await (0, payCliExec_1.execAndReturnIO)(`${rbenvCommand} exec bundle --version`, {
49
+ cwd: pathToLegacyRubyCli
50
+ });
48
51
  if (whichRbenvResult.exitCode !== 0) {
49
52
  console.error('You need rbenv installed before you can continue.');
50
53
  process.exit(12);
@@ -54,7 +57,7 @@ async function proxyArrayOfArgumentsToLegacyCli(argsToPassOn) {
54
57
  process.exit(12);
55
58
  }
56
59
  await (0, payCliExec_1.default)(shellCommand, {
57
- cwd: path.join(constants_1.rootDir, 'legacy-ruby-cli'),
60
+ cwd: pathToLegacyRubyCli,
58
61
  matchExitCode: true,
59
62
  streamStdio: true,
60
63
  commandsToWrite: [
@@ -23,16 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.distDir = exports.rootDir = void 0;
26
+ exports.distDirForBuildTasks = exports.rootDirForBuildTasks = exports.rootDir = void 0;
27
27
  const path = __importStar(require("path"));
28
- // import {dirname} from 'path'
29
- // import {fileURLToPath} from 'url'
30
- //
31
- // // @ts-ignore
32
- // const currentDir = dirname(fileURLToPath(import.meta.url))
33
- const potentialRootDir = path.resolve(__dirname, '..', '..');
34
- exports.rootDir = potentialRootDir.endsWith('dist') ? path.resolve(potentialRootDir, '..') : potentialRootDir;
35
- exports.distDir = path.join(exports.rootDir, 'dist');
28
+ exports.rootDir = path.resolve(__dirname, '..', '..');
29
+ exports.rootDirForBuildTasks = exports.rootDir.endsWith('dist') ? path.resolve(exports.rootDir, '..') : exports.rootDir;
30
+ exports.distDirForBuildTasks = path.join(exports.rootDirForBuildTasks, 'dist');
36
31
  exports.default = {
37
- rootDir: exports.rootDir
32
+ rootDir: exports.rootDir,
33
+ distDirForBuildTasks: exports.distDirForBuildTasks,
34
+ rootDirForBuildTasks: exports.rootDirForBuildTasks
38
35
  };
@@ -26,9 +26,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.execAndReturnIO = void 0;
27
27
  const cp = __importStar(require("child_process"));
28
28
  async function payCliExec(fullCommand, options) {
29
- return await new Promise((resolve) => {
29
+ return await new Promise((resolve, reject) => {
30
30
  const commandParts = fullCommand.split(' ');
31
31
  const command = commandParts.shift();
32
+ const commandsWritten = [];
33
+ const stderrParts = [];
32
34
  if (command === undefined) {
33
35
  throw new Error('Command can\'t be undefined');
34
36
  }
@@ -42,6 +44,9 @@ async function payCliExec(fullCommand, options) {
42
44
  if ((options?.onStderr) !== undefined) {
43
45
  spawnedThread.stderr.on('data', options.onStderr);
44
46
  }
47
+ spawnedThread.stderr.on('data', (buffer) => {
48
+ stderrParts.push(buffer);
49
+ });
45
50
  if ((options?.onClose) !== undefined) {
46
51
  spawnedThread.on('close', options.onClose);
47
52
  }
@@ -55,12 +60,24 @@ async function payCliExec(fullCommand, options) {
55
60
  process.exitCode = exitCode;
56
61
  });
57
62
  }
63
+ spawnedThread.on('error', (error) => {
64
+ console.error('An error occurred in payCliExec.');
65
+ if (commandsWritten.length > 0) {
66
+ console.error(`commandsWritten: [${commandsWritten.join(', ')}]`);
67
+ }
68
+ if (stderrParts.length > 0) {
69
+ console.error(`STDERR:\n${stderrParts.map(x => x.toString()).join('\n')}`);
70
+ }
71
+ console.error(error);
72
+ reject(error);
73
+ });
58
74
  spawnedThread.once('close', () => {
59
75
  resolve();
60
76
  });
61
77
  if (options?.commandsToWrite !== undefined) {
62
78
  spawnedThread.stdin.setDefaultEncoding('utf-8');
63
79
  options.commandsToWrite.forEach((value) => {
80
+ commandsWritten.push(value);
64
81
  spawnedThread.stdin.write(`${value}\n`);
65
82
  });
66
83
  }