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

0: unrecognized option "--version" #1671

Closed
bjmgeek opened this issue Jul 7, 2020 · 3 comments
Closed

0: unrecognized option "--version" #1671

bjmgeek opened this issue Jul 7, 2020 · 3 comments

Comments

@bjmgeek
Copy link

bjmgeek commented Jul 7, 2020

Please make sure that you provide enough information so that we understand what your issue is about.

I'm running with testssl.sh as an alias:

alias testssl.sh='testssl.sh --openssl=/home/bminton/src/testssl.sh/bin/openssl.Linux.x86_64'

where /home/bminton/src/testssl.sh is the latest version from github.

  1. Did you check the documentation in ~/doc/ or, if it is a different problem: Did you google for it?
    yes
  2. uname -a
    Linux node1 3.0.101-91-xen Heartbleed for STARTTLS #1 SMP Mon Sep 8 07:39:05 UTC 2014 (bbbeeba) x86_64 x86_64 x86_64 GNU/Linux
  3. testssl version from the banner: testssl.sh -b 2>/dev/null | head -4 | tail -2
    It just prints a blank line.
    If I skip the alias and run the script directly, I see testssl.sh 3.0.2 from https://testssl.sh/
  4. git log | head -1 (if running from git repo)
    commit 2949b9593749dd369aa3c420f76922e689ca596b
  5. openssl version used by testssl.sh: testssl.sh -b 2>/dev/null | awk -F':' '/openssl/ { print $2}'

 using openssl for all ciphers (-e), show only first preferred cipher.
 look in $PATH, $RUN_DIR of testssl.sh)
 use the OpenSSL cipher suite name as the primary name cipher suite name form (default)


If I skip the alias and run the script directly, I see

/home/bminton/src/testssl.sh/bin/openssl.Linux.x86_64
  1. steps to reproduce: testssl.sh or docker command line, if possible incl. host
bminton@node1:~$ unalias testssl.sh
bminton@node1:~$ testssl.sh --version

###########################################################
    testssl.sh       3.0.2 from https://testssl.sh/

      This program is free software. Distribution and
             modification under GPLv2 permitted.
      USAGE w/o ANY WARRANTY. USE IT AT YOUR OWN RISK!

       Please file bugs @ https://testssl.sh/bugs/

###########################################################

 Using "OpenSSL 1.0.2-chacha (1.0.2k-dev)" [~183 ciphers]
 on node1:/home/bminton/src/testssl.sh/bin/openssl.Linux.x86_64
 (built: "Jan 18 17:12:17 2019", platform: "linux-x86_64")


bminton@node1:~$ alias testssl.sh='testssl.sh --openssl=/home/bminton/src/testssl.sh/bin/openssl.Linux.x86_64'
bminton@node1:~$ testssl.sh --version
0: unrecognized option "--version"

     "testssl.sh [options] <URI>"    or    "testssl.sh <options>"


"testssl.sh <options>", where <options> is:

     --help                        what you're looking at
     -b, --banner                  displays banner + version of testssl.sh
     -v, --version                 same as previous
[snip]
  1. what exactly was happening, output is needed
    0: unrecognized option "--version"

  2. what did you expect instead?

The script would display the version.

@drwetter
Copy link
Collaborator

drwetter commented Jul 7, 2020

Those options obviously don't work together. I can look into it later to see how much effort it is to fix especially that. Note: there will be other conflicts which still won't be handled and resolving that is probably a tedious job.

IN the meantime for you: there's probably no point setting the alias when your testssl.sh is installed as /home/bminton/src/testssl.sh/

@dcooper16
Copy link
Collaborator

After doing some experimenting I found the reason for the "unrecognized option" error. As noted above, the help output says:

     "testssl.sh [options] <URI>"    or    "testssl.sh <options>"


"testssl.sh <options>", where <options> is:

     --help                        what you're looking at
     -b, --banner                  displays banner + version of testssl.sh
     -v, --version                 same as previous
     -V, --local                   pretty print all local ciphers
     -V, --local <pattern>         which local ciphers with <pattern> are available? If pattern is not a number: word match

     <pattern>                     is always an ignore case word pattern of cipher hexcode or any other string in the name, kx or bits

"testssl.sh <URI>", where <URI> is:

     <URI>                         host|host:port|URL|URL:port   port 443 is default, URL can only contain HTTPS protocol)

"testssl.sh [options] <URI>", where [options] is:
[snip]

Looking at the code, the --help, -b, --banner, -v, and --version options can only be used by themselves (as the first option). parse_cmd_line() first checks whether the first argument is one of these options. If it isn't, then it loops through and processes all of the arguments. The loop does not recognize the --help, -b, --banner, -v, and --version options and so reports "unrecognized option" if it encounters one of these.

Above, when the alias is used, the first option is --openssl=... and so parse_cmd_line() enters the loop. The loop doesn't recognize --version and so fails with the "unrecognized option" error.

@bjmgeek
Copy link
Author

bjmgeek commented Jul 15, 2020

Maybe this is just a documentation bug: replace <options> with <standalone options> for instance (to avoid confusion with [options] below). Otherwise, perhaps a check if any of the standalone options are present at all in the args, do them and then exit, rather than even trying to parse the args.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants