Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented encryption support for only parts of the connection string #124

Merged
merged 5 commits into from
Jan 27, 2020

Conversation

bbandlamudi
Copy link
Contributor

[Issue-123] Supporting encryption of password, username, hostname or dbname fields of the connection string. This should enable customers to keep the existing connection string, but only encrypt the password field. Also, encrypted portion can be optionally enclosed with in ENC(). Added additional test cases to AbstractManagerTest to test this new feature. I have also done some manual testing of various use cases.

host) with in the xcc connection string. Added test cases.
@codecov
Copy link

codecov bot commented Jan 16, 2020

Codecov Report

Merging #124 into development will decrease coverage by 0.02%.
The diff coverage is 74%.

Impacted file tree graph

@@                Coverage Diff                @@
##             development     #124      +/-   ##
=================================================
- Coverage          83.55%   83.52%   -0.03%     
- Complexity          1282     1284       +2     
=================================================
  Files                 45       45              
  Lines               4146     4170      +24     
  Branches             619      624       +5     
=================================================
+ Hits                3464     3483      +19     
- Misses               459      460       +1     
- Partials             223      227       +4
Impacted Files Coverage Δ Complexity Δ
.../com/marklogic/developer/corb/AbstractManager.java 88.21% <74%> (-1.33%) 94 <4> (+3)
.../com/marklogic/developer/corb/JasyptDecrypter.java 76.47% <0%> (-2.95%) 9% <0%> (ø)
...n/java/com/marklogic/developer/corb/JobServer.java 81.08% <0%> (+1.35%) 42% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efd26f0...ff9b4ed. Read the comment docs.

Copy link
Member

@hansenmc hansenmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to make these changes

try {
Pattern pattern = Pattern.compile(XCC_CONNECTION_URI_PATTERN);
Matcher matcher = pattern.matcher(connectionUri);
matcher.find();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to invoke matcher.find() if we are going to ignore it

LOG.info("Checking if any part of the connection string are encrypted");
String uriAfterDecrypt = connectionUri;
try {
Pattern pattern = Pattern.compile(XCC_CONNECTION_URI_PATTERN);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be moved outside of the try/catch

password = this.decrypter.decrypt(XCC_PASSWORD, password);
host = this.decrypter.decrypt(XCC_HOSTNAME, host);
dbname = !isBlank(dbname) ? this.decrypter.decrypt(XCC_DBNAME, dbname) : null;
uriAfterDecrypt = StringUtils.getXccUri(protocol, username, password, host, port, dbname);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this. is not necessary

- removing `this.` where not needed
- moving `pattern.compile()` outside of try block
- removing unnecessary `matcher.find()`
@hansenmc hansenmc merged commit 921f03f into development Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants