8000 [plugin-web-app-to-rest-api] Add steps to check SSL rating using SSL Labs by draker94 · Pull Request #4361 · vividus-framework/vividus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[plugin-web-app-to-rest-api] Add steps to check SSL rating using SSL Labs #4361

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

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

draker94
Copy link
Contributor

No description provided.

@draker94 draker94 requested a review from a team as a code owner September 25, 2023 16:44
@codecov
Copy link
codecov bot commented Sep 25, 2023

Codecov Report

Merging #4361 (8298840) into master (076bad3) will decrease coverage by 0.01%.
Report is 7 commits behind head on master.
The diff coverage is 98.01%.

❗ Current head 8298840 differs from pull request most recent head a537725. Consider uploading reports for the commit a537725 to get more accurate results

@@             Coverage Diff              @@
##             master    #4361      +/-   ##
============================================
- Coverage     97.32%   97.31%   -0.01%     
- Complexity     6381     6449      +68     
============================================
  Files           889      895       +6     
  Lines         18384    18526     +142     
  Branches       1226     1238      +12     
============================================
+ Hits          17892    18029     +137     
- Misses          384      387       +3     
- Partials        108      110       +2     
Files Coverage Δ
...main/java/org/vividus/ssllabs/AnalyzeResponse.java 100.00% <100.00%> (ø)
...t-api/src/main/java/org/vividus/ssllabs/Grade.java 100.00% <100.00%> (ø)
...c/main/java/org/vividus/ssllabs/SslLabsClient.java 100.00% <100.00%> (ø)
...rc/main/java/org/vividus/ssllabs/SslLabsSteps.java 100.00% <100.00%> (ø)
...pi/src/main/java/org/vividus/ssllabs/Endpoint.java 80.00% <80.00%> (ø)

... and 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@draker94 draker94 force-pushed the add_ssllabs_steps branch 2 times, most recently from eeff993 to 5f8088d Compare October 2, 2023 13:15
@draker94 draker94 force-pushed the add_ssllabs_steps branch 3 times, most recently from b17354a to 141c364 Compare October 3, 2023 07:13
@draker94 draker94 force-pushed the add_ssllabs_steps branch 3 times, most recently from ab02155 to d8c5738 Compare October 4, 2023 16:29

private Optional<AnalyzeResponse> analyze(String host)
{
AtomicBoolean sslScanFailed = new AtomicBoolean(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

such flags are not good practice, I've started refactoring, but it's not complete yet:

private Optional<HttpResponse> analyze(String host)
    {
        return WAITER.wait(() -> {
            try
            {
                HttpResponse response = httpClient.doHttpGet(URI.create(
                        String.format("%s%s%s", sslLabHost, API_VERSION, String.format(ANALYZE_CALL, host))));
                return Optional.of(response);
            }
            catch (IOException e)
            {
                LOGGER.atError().setCause(e).log("Unable to process request");
                return Optional.empty();
            }
        }, response -> {
            if (response.isEmpty())
            {
                return true;
            }
            HttpResponse httpResponse = response.get();
            int statusCode = httpResponse.getStatusCode();
            if (statusCode == HttpStatus.SC_OK)
            {
                return true;
            }
            LOGGER.atWarn().addArgument(statusCode).addArgument(httpResponse.getResponseBodyAsString()).log(
                    "Unexpected status code received: {}\nResponse body: {}");
            if (statusCode != TOO_MANY_REQUESTS || statusCode != SERVICE_IS_OVERLOADED
                    || statusCode != HttpStatus.SC_SERVICE_UNAVAILABLE)
            {
                return false;
            }
            LOGGER.atError().log(SSL_SCAN_FAILURE);
            return true;
        });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reworked
Please check new solution

@valfirst valfirst requested a review from uarlouski October 6, 2023 07:27
try
{
HttpResponse response = httpClient.doHttpGet(URI.create(
String.format("%s%s%s", sslLabHost, API_VERSION, String.format(ANALYZE_CALL, host))));
Copy link
Member

Choose a reason for hiding this comment

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

what if I specify https://api.ssllabs.com/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what if I specify https://api.ssllabs.com/ ?

Caused by: java.lang.IllegalArgumentException: URI path begins with multiple slashes

But I'm not sure that users will change the host too often to add processing for such cases

@valfirst valfirst merged commit 33cf742 into vividus-framework:master Oct 9, 2023
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.

4 participants
0