From eebd3699a70568c329541cea1eb40b197e2a06a8 Mon Sep 17 00:00:00 2001 From: Shlomo Zalman Heigh Date: Tue, 19 Nov 2024 16:53:24 -0500 Subject: [PATCH 1/2] Update VSCode debugging instructions Co-authored-by: Ghea Chaw <149848354+GheaCRPI@users.noreply.github.com> --- .gitignore | 3 +- .vscode/launch.json | 15 +++++++++ CONTRIBUTING.md | 71 ++++++++++-------------------------------- Gemfile | 6 ++-- Gemfile.lock | 49 ++++++++++++++++++----------- dev/docker-compose.yml | 1 + 6 files changed, 68 insertions(+), 77 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index 1fb2ee49c7..08768d3687 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,8 @@ api.html brakeman-output.* .idea -.vscode +.vscode/* +!.vscode/launch.json TEMP_NOTES.txt awstest diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..91ca533d60 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // See CONTRIBUTING.md for more details on debugging Conjur in VSCode + "version": "0.2.0", + "configurations": [ + { + "type": "rdbg", + "request": "attach", + "name": "Attach with rdbg (tcp 12345)", + "debugPort": "127.0.0.1:12345", + "localfsMap": "/src/conjur-server:${workspaceFolder}" + // In the conjur container, run: + // bundle exec rdbg --open --port=12345 --host=0.0.0.0 -c -- rails server -b 0.0.0.0 -u webrick + }, + ] +} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3736c1df27..bd4425053d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,10 +12,9 @@ For general contribution and community guidelines, please see the [community rep - [Prevent Secret Leaks](#prevent-secret-leaks) - [Build Conjur as a Docker image](#build-conjur-as-a-docker-image) - [Set up a development environment](#set-up-a-development-environment) - - [LDAP Authentication](#ldap-authentication) - - [Google Cloud Platform (GCP) Authentication](#google-cloud-platform-gcp-authentication) - - [RubyMine IDE Debugging](#rubymine-ide-debugging) - - [Visual Studio Code IDE Debugging](#visual-studio-code-ide-debugging) + - [LDAP Authentication](#ldap-authentication) + - [Google Cloud Platform (GCP) Authentication](#google-cloud-platform-gcp-authentication) + - [Visual Studio Code IDE Debugging](#visual-studio-code-ide-debugging) - [Development CLI](#development-cli) - [Step into the running Conjur container](#step-into-the-running-conjur-container) - [View the admin user's API key](#view-the-admin-users-api-key) @@ -89,9 +88,6 @@ It's easy to get started with Conjur and Docker: ## Set up a development environment -**Note**: If you are going to debug Conjur using [RubyMine IDE](https://www.jetbrains.com/ruby/) or [Visual Studio Code IDE](https://code.visualstudio.com), -see [RubyMine IDE Debugging](#rubymine-ide-debugging) or [Visual Studio Code IDE debugging](#visual-studio-code-ide-debugging) respectively before setting up the development environment. - The `dev` directory contains a `docker-compose` file which creates a development environment with a database container (`pg`, short for *postgres*), and a `conjur` server container with source code mounted into the directory @@ -135,12 +131,11 @@ To use it: * find or create the token-signing key * start the web server - You may choose to debug Conjur using `pry.byebug`, RubyMine or Visual Studio Code IDEs. This will + You may choose to debug Conjur using `pry.byebug` or the Visual Studio Code IDE. This will allow you to work in the debugger without the server timing out. To do so, run the following command instead of `conjurctl server`: - `pry.byebug`: `rails server -b 0.0.0.0 webrick` - - RubyMine and VS Code IDE, make sure you are in `/src/conjur-server` and run the following command: `rdebug-ide --port 1234 --dispatcher-port 26162 --host 0.0.0.0 -- bin/rails s -b 0.0.0.0 -u webrick` - - Now that the server is listening, debug the code via [RubyMine's](#rubymine-ide-debugging) or [VC Code's](#visual-studio-code-ide-debugging) debuggers. + - VS Code: See [Visual Studio Code IDE Debugging](#visual-studio-code-ide-debugging) 1. Cleanup @@ -176,55 +171,23 @@ $ curl -v -k -X POST -d "alice" http://localhost:3000/authn-ldap/test/cucumber/a To enable a host to log into Conjur using GCP identity token, run `start` with the `--authn-gcp` flag. Form more information on how to setup Conjur Google Cloud (GCP) authenticator, follow the official [documentation](https://www.conjur.org/). -#### RubyMine IDE Debugging +#### Visual Studio Code IDE Debugging -If you are going to be debugging Conjur using [RubyMine IDE](https://www.jetbrains.com/ruby/), follow +To debug Conjur using [VS Code IDE](https://code.visualstudio.com), follow these steps: - 1. Add a debug configuration - 1. Go to: Run -> Edit Configurations - 1. In the Run/Debug Configuration dialog, click + on the toolbar and - choose “Ruby remote debug” - 1. Specify a name for this configuration (i.e “debug Conjur server”) - 1. Specify these parameters: - - Remote host - the address of Conjur. if it's a local docker environment the address - should be `localhost`, otherwise enter the address of Conjur - - Remote port - the port which RubyMine will try to connect to for its debugging protocol. - The convention is `1234`. If you changing this, remember to change also the exposed port in - `docker-compose.yml` & in the `rdebug-ide` command when running the server - - Remote root folder: `/src/conjur-server` - - Local port: 26162 - - Local root folder: `/local/path/to/conjur/repository` - 1. Click "OK" - - 1. Create remote SDK - 1. Go to Preferences -> Ruby SDK and Gems - 1. In the Ruby SDK and Gems dialog, click + on the toolbar - and choose “New remote...” - 1. Choose “Docker Compose” and specify these parameters: - - Server: Docker - - If Docker isn't configured, click "New..." and configure it. - - Configuration File(s): `./dev/docker-compose.yml` - - Note: remove other `docker-compose` files if present. - - Service: conjur - - Environment variables: This can be left blank - - Ruby or version manager path: ruby - 1. Click "OK" + 1. Ensure you have the "Ruby LSP" and "rdbg" extensions installed in VSCode + 1. Start or enter the development container. + 1. Instead of running `conjurctl server`, run the following command to start the server + with the debugger: -#### Visual Studio Code IDE Debugging - -If you are going to be debugging Conjur using [VS Code IDE](https://code.visualstudio.com), follow -these steps: + ```sh-session + bundle exec rdbg --open --port=12345 --host=0.0.0.0 -c -- rails server -b 0.0.0.0 -u webrick + ``` - 1. Go to: Debugger view - 1. Choose Ruby -> Listen for rdebug-ide from the prompt window, then you'll get the sample launch configuration in `.vscode/launch.json`. - 1. Edit "Listen for rdebug-ide" configuration in the `launch.json` file: - - remoteHost - the address of Conjur. if it's a local docker environment the address - should be `localhost`, otherwise enter the address of Conjur - - remotePort - the port which VS Code will try to connect to for its debugging protocol. - The convention is `1234`. If you changing this, remember to change also the exposed port in - `docker-compose.yml` & in the `rdebug-ide` command when running the server - - remoteWorkspaceRoot: `/src/conjur-server` + 1. Go to the "Run and Debug" tab in VS Code and click the "Start Debugging" button with the + "Attach with rdbg (tcp 12345)" configuration selected. + You should now be able to debug normally using breakpoints and the debug console. ### Development CLI diff --git a/Gemfile b/Gemfile index 66b237031b..7f329cb6cc 100644 --- a/Gemfile +++ b/Gemfile @@ -95,8 +95,9 @@ group :development, :test do gem 'database_cleaner', '~> 1.8' gem 'debase', '~> 0.2.5.beta2' gem 'debase-ruby_core_source', '~> 3.3' - gem 'json_spec', '~> 1.1' + gem 'debug' # For VSCode debugging gem 'faye-websocket' + gem 'json_spec', '~> 1.1' gem 'net-ssh' gem 'parallel' gem 'parallel_tests' @@ -108,7 +109,6 @@ group :development, :test do gem 'rspec' gem 'rspec-core' gem 'rspec-rails' - gem 'ruby-debug-ide' # We use a post-coverage hook to sleep covered processes until we're ready to # collect the coverage reports in CI. Because of this, we don't want bundler @@ -126,7 +126,7 @@ end group :development do # NOTE: minor version of this needs to match codeclimate channel - gem 'rubocop', '~> 0.58.0', require: false + gem 'rubocop', '>= 1.4.0', require: false gem 'reek', require: false gem 'rubocop-checkstyle_formatter', require: false # for Jenkins diff --git a/Gemfile.lock b/Gemfile.lock index 4b15cc2764..a579892ea6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,6 +103,7 @@ GEM aws-eventstream (~> 1, >= 1.0.2) base32-crockford (0.1.0) base58 (0.2.3) + base64 (0.1.2) bcrypt (3.1.19) bindata (2.4.15) builder (3.2.4) @@ -177,6 +178,9 @@ GEM debase (0.2.5.beta2) debase-ruby_core_source (>= 0.10.12) debase-ruby_core_source (3.3.1) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) deep_merge (1.2.2) diff-lcs (1.5.0) docile (1.4.0) @@ -259,12 +263,16 @@ GEM i18n (1.8.11) concurrent-ruby (~> 1.0) ice_nine (0.11.2) + io-console (0.7.2) + irb (1.14.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) iso8601 (0.13.0) - jaro_winkler (1.5.6) jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) jmespath (1.6.2) + json (2.8.2) json-jwt (1.16.3) activesupport (>= 4.2) aes_key_wrap @@ -287,6 +295,7 @@ GEM recursive-open-struct (~> 1.1, >= 1.1.1) rest-client (~> 2.0) kwalify (0.7.2) + language_server-protocol (3.17.0.3) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -306,6 +315,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2024.1001) mini_mime (1.1.2) + mini_portile2 (2.8.8) minitest (5.25.1) multi_json (1.15.0) multi_test (0.1.2) @@ -323,13 +333,8 @@ GEM net-ssh (7.1.0) netrc (0.11.0) nio4r (2.5.9) - nokogiri (1.15.4-aarch64-linux) - racc (~> 1.4) - nokogiri (1.15.4-arm64-darwin) - racc (~> 1.4) - nokogiri (1.15.4-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.15.4-x86_64-linux) + nokogiri (1.15.4) + mini_portile2 (~> 2.8.2) racc (~> 1.4) openid_connect (2.2.0) activemodel @@ -351,7 +356,6 @@ GEM ast (~> 2.4.1) racc pg (1.5.3) - powerpack (0.1.3) prometheus-client (3.0.0) pry (0.14.2) coderay (~> 1.1) @@ -421,12 +425,15 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + rdoc (6.3.4.1) recursive-open-struct (1.1.3) reek (6.1.4) kwalify (~> 0.7.0) parser (~> 3.2.0) rainbow (>= 2.0, < 4.0) regexp_parser (2.8.1) + reline (0.5.11) + io-console (~> 0.5) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) @@ -454,18 +461,22 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) rspec-support (3.12.0) - rubocop (0.58.2) - jaro_winkler (~> 1.5.1) + rubocop (1.56.4) + base64 (~> 0.1.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 2.5, != 2.5.1.1) - powerpack (~> 0.1) + parser (>= 3.2.2.3) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.30.0) + parser (>= 3.2.1.0) rubocop-checkstyle_formatter (0.4.0) rubocop (>= 0.35.1) - ruby-debug-ide (0.7.3) - rake (>= 0.8.1) ruby-next-core (0.15.3) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) @@ -516,7 +527,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.9) - unicode-display_width (1.8.0) + unicode-display_width (2.6.0) validate_email (0.1.6) activemodel (>= 3.0) mail (>= 2.2.5) @@ -570,6 +581,7 @@ DEPENDENCIES database_cleaner (~> 1.8) debase (~> 0.2.5.beta2) debase-ruby_core_source (~> 3.3) + debug dry-struct dry-types dry-validation @@ -614,9 +626,8 @@ DEPENDENCIES rspec rspec-core rspec-rails - rubocop (~> 0.58.0) + rubocop (>= 1.4.0) rubocop-checkstyle_formatter - ruby-debug-ide sequel sequel-pg_advisory_locking sequel-postgres-schemata diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index 724c1a0ff2..59b7353bf2 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -65,6 +65,7 @@ services: ports: - "3000:3000" - "1234:1234" + - "12345:12345" # Debug port for rdbg expose: - "3000" volumes: From d68abbfb20f441ec68909a986f905bf174448683 Mon Sep 17 00:00:00 2001 From: Shlomo Zalman Heigh Date: Wed, 20 Nov 2024 14:55:54 -0500 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d498d2378..0652b92520 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Nothing should go in this section, please add to the latest unreleased version (and update the corresponding date), or add a new version. -## [1.21.2] - 2024-11-05 +## [1.21.2] - 2024-11-20 ### Changed - Replaces ERB template engine with Mustache when rendering Factory templates @@ -1259,7 +1259,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - The first tagged version. -[Unreleased]: https://github.com/cyberark/conjur/compare/v1.20.2...HEAD +[Unreleased]: https://github.com/cyberark/conjur/compare/v1.21.2...HEAD +[1.21.2]: https://github.com/cyberark/conjur/compare/v1.21.1...v1.21.2 +[1.21.1]: https://github.com/cyberark/conjur/compare/v1.21.0...v1.21.1 +[1.21.0]: https://github.com/cyberark/conjur/compare/v1.20.4...v1.21.0 +[1.20.4]: https://github.com/cyberark/conjur/compare/v1.20.3...v1.20.4 +[1.20.3]: https://github.com/cyberark/conjur/compare/v1.20.2...v1.20.3 [1.20.2]: https://github.com/cyberark/conjur/compare/v1.20.1...v1.20.2 [1.20.1]: https://github.com/cyberark/conjur/compare/v1.20.0...v1.20.1 [1.20.0]: https://github.com/cyberark/conjur/compare/v1.19.5...v1.20.0