Skip to content

SCANCLI-216 Update scanner library to fix proxy authentication on CONNECT#267

Open
henryju wants to merge 4 commits intomasterfrom
jh/fix_proxy_connect_auth
Open

SCANCLI-216 Update scanner library to fix proxy authentication on CONNECT#267
henryju wants to merge 4 commits intomasterfrom
jh/fix_proxy_connect_auth

Conversation

@henryju
Copy link
Member

@henryju henryju commented Mar 11, 2026

Please be aware that we are not actively looking for feature contributions. The truth is that it's extremely difficult for someone outside SonarSource to comply with our roadmap and expectations. Therefore, we typically only accept minor cosmetic changes and typo fixes. If you would like to see a new feature, please create a new thread in the forum "Suggest new features".

With that in mind, if you would like to submit a code contribution, make sure that you adhere to the following guidelines and all tests are passing:

  • Please explain your motives to contribute this change: what problem you are trying to fix, what improvement you are trying to make
  • Use the following formatting style: SonarSource/sonar-developer-toolset
  • Provide a unit test for any code you changed
  • If there is a JIRA ticket available, please make your commits and pull request start with the ticket ID (SCANCLI-XXXX)

We will try to give you feedback on your contribution as quickly as possible.

Thank You!
The SonarSource Team

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod bot changed the title Update scanner library to fix proxy authentication on CONNECT SCANCLI-216 Update scanner library to fix proxy authentication on CONNECT Mar 11, 2026
@hashicorp-vault-sonar-prod
Copy link

hashicorp-vault-sonar-prod bot commented Mar 11, 2026

SCANCLI-216

@henryju henryju force-pushed the jh/fix_proxy_connect_auth branch from 8e5cee6 to a5d05ac Compare March 11, 2026 11:21
@henryju henryju marked this pull request as ready for review March 12, 2026 07:49
@RunWith(Suite.class)
@SuiteClasses({ScannerTest.class, MultimoduleTest.class,
DistributionTest.class})
DistributionTest.class, ProxyTest.class})
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: I would prefer having one class per line

Comment on lines +91 to +92
private static final ConcurrentLinkedDeque<String> seenByProxy = new ConcurrentLinkedDeque<>();
private static final ConcurrentLinkedDeque<String> seenConnectByProxy = new ConcurrentLinkedDeque<>();
Copy link
Contributor

@antoine-vinot-sonarsource antoine-vinot-sonarsource Mar 19, 2026

Choose a reason for hiding this comment

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

The names are unclear to me at first read. What are these queues?

Copy link
Member Author

Choose a reason for hiding this comment

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

New attempt, let me know

seenConnectByProxy.clear();
}

private static void startProxy(boolean needProxyAuth) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to not have to rely on a flag parameter here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


private static Server proxyServer;
private static int httpProxyPort;
// HTTPS reverse-proxy target, used for the HTTPS CONNECT tests
Copy link
Contributor

Choose a reason for hiding this comment

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

I would avoid comments saying "what" as they should be replaced with a meaningful variable/method name.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be better now

sslConnector.setPort(httpsTargetPort);
httpsTargetServer.addConnector(sslConnector);

// Transparently forward all requests to the Orchestrator instance
Copy link
Contributor

Choose a reason for hiding this comment

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

I would avoid comments saying "what" as they should be replaced with a meaningful variable/method name.

httpsTargetServer.start();
}

private static ServletContextHandler proxyHandler(boolean needProxyAuth) {
Copy link
Contributor

Choose a reason for hiding this comment

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

parameter flag should be avoided

Copy link
Member Author

Choose a reason for hiding this comment

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

Did my best, not always possible IMO


import static org.assertj.core.api.Assertions.assertThat;

public class ProxyTest extends ScannerTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

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

The overall quality/readability of this test class is lacking IMO:

  • The first Test occurrence happens at line 342 (red flag IMO)
  • Unnecessary comments
  • Flag params
  • Vertical alignment of method calls is not respected
  • Naming of methods is sometimes lacking the "start with a verb" principle, and is not entirely clear what the method is doing.
  • Some methods are a bit too big

I can feel it was AI generated 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I made another attempt, let me know what you think.

@sonarqube-next
Copy link

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