Skip to content

Commit

Permalink
Merge pull request #590 from Conjur-Enterprise/update-debug-instructions
Browse files Browse the repository at this point in the history
CNJR-0000: Update VSCode debugging instructions
  • Loading branch information
szh authored and GitHub Enterprise committed Nov 21, 2024
2 parents 9db324d + d68abbf commit 4a4fd0e
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 79 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ api.html

brakeman-output.*
.idea
.vscode
.vscode/*
!.vscode/launch.json
TEMP_NOTES.txt
awstest

Expand Down
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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
},
]
}
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
71 changes: 17 additions & 54 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand Down
49 changes: 30 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ services:
ports:
- "3000:3000"
- "1234:1234"
- "12345:12345" # Debug port for rdbg
expose:
- "3000"
volumes:
Expand Down

0 comments on commit 4a4fd0e

Please sign in to comment.