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

[Feature request] line wrapping for grade cap #2567

Open
drwetter opened this issue Sep 17, 2024 · 4 comments
Open

[Feature request] line wrapping for grade cap #2567

drwetter opened this issue Sep 17, 2024 · 4 comments

Comments

@drwetter
Copy link
Owner

proper line wrapping, see #2564 (comment)

@magnuslarsen
Copy link
Contributor

magnuslarsen commented Sep 17, 2024

(continuation from above comment)

It does actually seem like it wraps, if I make my terminal smaller; though the array sorting makes it behave incorrectly

 Rating (experimental)

 Rating specs (not complete)  SSL Labs's 'SSL Server Rating Guide' (version 2009q from 2020-01-30)
 Specification documentation  https://github.com/ssllabs/research/wiki/SSL-Server-Rating-Guide
 Protocol Support (weighted)  0 (0)
 Key Exchange     (weighted)  0 (0)
 Cipher Strength  (weighted)  0 (0)
 Final Score                  0
 Overall Grade                T
 Grade cap reasons            Grade capped to T. STARTTLS encryption is not mandatory for clients.
                              Grade capped to T. Issues with the chain of trust (chain incomplete)
                              Grade capped to A. HSTS is not offered
                                                          STARTTLS can only be secured clientside

 Done 2024-09-17 10:58:47 [  70s] -->> 104.154.89.105:443 (untrusted-root.badssl.com) <<--
diff --git a/testssl.sh b/testssl.sh
index 4068440..fd991a3 100755
--- a/testssl.sh
+++ b/testssl.sh
@@ -7691,6 +7691,7 @@ determine_trust() {
                fi
                fileout "${jsonID}${json_postfix}" "CRITICAL" "failed $code. $addtl_warning"
                set_grade_cap "T" "Issues with the chain of trust $code"
+               set_grade_cap "T" "$(out_row_aligned_max_width 'STARTTLS encryption is not mandatory for clients. STARTTLS can only be secured clientside' '                            ' $TERM_WIDTH)"
           else
                # alt least one ok and other(s) not ==> display the culprit store(s)
                if "$some_ok"; then

@drwetter
Copy link
Owner Author

Now we're on the same page. 😃 But the wrapped part of the line is not where it should be, that's also what I experienced.

@magnuslarsen
Copy link
Contributor

hmm, it is definitely the sorting that breaks it:

 Rating (experimental)

 Rating specs (not complete)  SSL Labs's 'SSL Server Rating Guide' (version 2009q from 2020-01-30)
 Specification documentation  https://github.com/ssllabs/research/wiki/SSL-Server-Rating-Guide
 Protocol Support (weighted)  0 (0)
 Key Exchange     (weighted)  0 (0)
 Cipher Strength  (weighted)  0 (0)
 Final Score                  0
 Overall Grade                T
 Grade cap reasons            Grade capped to T. Issues with the chain of trust (chain incomplete)
                              Grade capped to T. STARTTLS encryption is not mandatory for clients. STARTTLS can
                            only be secured clientside
                              Grade capped to T. Issues with the chain of trust (chain incomplete)
                              Grade capped to T. STARTTLS encryption is not mandatory for clients. STARTTLS can
                            only be secured clientside
                              Grade capped to A. HSTS is not offered

 Done 2024-09-17 12:40:54 [  73s] -->> 104.154.89.105:443 (untrusted-root.badssl.com) <<--
diff --git a/testssl.sh b/testssl.sh
index 4068440..f17663b 100755
--- a/testssl.sh
+++ b/testssl.sh
@@ -7691,6 +7691,7 @@ determine_trust() {
                fi
                fileout "${jsonID}${json_postfix}" "CRITICAL" "failed $code. $addtl_warning"
                set_grade_cap "T" "Issues with the chain of trust $code"
+               set_grade_cap "T" "$(out_row_aligned_max_width 'STARTTLS encryption is not mandatory for clients. STARTTLS can only be secured clientside' '                            ' $TERM_WIDTH)"
           else
                # alt least one ok and other(s) not ==> display the culprit store(s)
                if "$some_ok"; then
@@ -23125,7 +23126,7 @@ run_rating() {
      fi

      # Pretty print - again, it's just nicer to read
-     for reason in "${sorted_reasons[@]}"; do
+     for reason in "${GRADE_CAP_REASONS[@]}"; do
           if [[ $reason_nr -eq 0 ]]; then
                pr_bold " Grade cap reasons            "; outln "$reason"
           else

Though I have no good off-the-top-of-my-head fixes. We use IFS=\n for the sorting:

IFS=$'\n' sorted_reasons=($(sort -ru <<<"${GRADE_CAP_REASONS[*]}"))

So we can't also keep multiline "reasons" with \n during the sorting step

@drwetter
Copy link
Owner Author

Tanks for the explanation. Guess better would be then in the for-loop to use out_row_aligned_max_width for just outln "$reason"

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 a pull request may close this issue.

2 participants