Skip to content

console-proxy: fix potential NPE condition#3419

Merged
yadvr merged 2 commits into
apache:masterfrom
shapeblue:cpvm-npe-fix
Jun 26, 2019
Merged

console-proxy: fix potential NPE condition#3419
yadvr merged 2 commits into
apache:masterfrom
shapeblue:cpvm-npe-fix

Conversation

@yadvr
Copy link
Copy Markdown
Member

@yadvr yadvr commented Jun 24, 2019

When checking if the console proxy URL domain starts with *, the code
does not check if the provided string is null. When domain is not
configured the IP address should be used.

Fixes #3164

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

When checking if the console proxy URL domain starts with *, the code
does not check if the provided string is null. When domain is not
configured the IP address should be used.

Fixes apache#3164

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@yadvr yadvr added this to the 4.13.0.0 milestone Jun 24, 2019
private String formatProxyAddress(String consoleProxyUrlDomain, String proxyIpAddress) {
StringBuffer sb = new StringBuffer();
// Domain in format *.example.com, proxy IP is 1.2.3.4 --> 1-2-3-4.example.com
if (consoleProxyUrlDomain.startsWith("*")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Jun 25, 2019

@anuragaw @shwstppr @nvazquez please review

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Jun 25, 2019

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

Copy link
Copy Markdown
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

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

LGTM

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-20

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Jun 25, 2019

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

Copy link
Copy Markdown
Contributor

@nvazquez nvazquez left a comment

Choose a reason for hiding this comment

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

LGTM. Just minor code improvement

StringBuffer sb = new StringBuffer();
// Domain in format *.example.com, proxy IP is 1.2.3.4 --> 1-2-3-4.example.com
if (consoleProxyUrlDomain.startsWith("*")) {
if (consoleProxyUrlDomain != null && consoleProxyUrlDomain.startsWith("*")) {
Copy link
Copy Markdown
Contributor

@nvazquez nvazquez Jun 25, 2019

Choose a reason for hiding this comment

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

Can we reorder this if-then-else? To:

if (StringUtils.isBlank(consoleProxyUrlDomain) {
   // Blank config, we use the proxy IP
   sb.append(proxyIpAddress);
} else if (consoleProxyUrlDomain.startsWith("*")) {
   sb.append(proxyIpAddress.replaceAll("\\.", "-"));
   sb.append(consoleProxyUrlDomain.substring(1)); // skip the *
} else {
   // Otherwise we assume a valid domain if config not blank
   sb.append(consoleProxyUrlDomain);
}

Copy link
Copy Markdown
Contributor

@anuragaw anuragaw left a comment

Choose a reason for hiding this comment

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

lgtm

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-25)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 36723 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr3419-t25-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_deploy_virtio_scsi_vm.py
Smoke tests completed. 71 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Jun 26, 2019

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-32

@yadvr
Copy link
Copy Markdown
Member Author

yadvr commented Jun 26, 2019

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

Trillian test result (tid-32)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 25990 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr3419-t32-kvm-centos7.zip
Smoke tests completed. 71 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

@yadvr yadvr merged commit 2c3c88e into apache:master Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot open console: ConsoleProxyServlet NullPointerException

8 participants