Skip to content

Commit 566c5a1

Browse files
committed
bulk command: add --audit option
1 parent 2627eb8 commit 566c5a1

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

bin/tls-map

+19-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ doc = <<~DOCOPT
1616
1717
#{Paint['Usage:', '#81c8b6']}
1818
tls-map search <criteria> <term> [-o <output> --force -e -a] [--no-color --debug]
19-
tls-map bulk <criteria> <file> [-q <output> --force] [--no-color --debug]
19+
tls-map bulk <criteria> <file> [(-q <output> | --audit) --force] [--no-color --debug]
2020
tls-map export <filename> <format> [--force] [--debug]
2121
tls-map extract <filename> <format> [--no-color --debug [--only-weak | --hide-weak]]
2222
tls-map update [--with-extended] [--debug]
@@ -34,6 +34,7 @@ doc = <<~DOCOPT
3434
<criteria> The type of term. Accepted values: codepoint, iana, openssl, gnutls, nss.
3535
<file> File containing the cipher algorithm names, one per line.
3636
-q, --output2 <output> Displayed fields. Accepted values: codepoint, iana, openssl, gnutls, nss. [default: iana]
37+
--audit Highlight weak (security level equal to weak or insecure) cipher suites. (work only with TLS not SSL).
3738
3839
#{Paint['Export options:', '#81c8b6']} #{Paint['(offline) export the list of all ciphers (mapping) in various formats', :underline]}
3940
<filename> The output file name to write to.
@@ -98,7 +99,23 @@ begin
9899
res = cli.bulk_search(args['<criteria>'].to_sym, args['<file>'], args['--output2'].to_sym)
99100
puts Paint['No match found', :red] if res.empty?
100101
res.each do |h|
101-
puts Paint[h[args['--output2'].to_sym], :green]
102+
cs = h[args['--output2'].to_sym] # cipher suite
103+
next if cs.nil?
104+
105+
if args['--audit']
106+
cliext = TLSmap::CLI::Extended.new
107+
ci = TLSmap::App::Cipher.new(:iana, cs, enhanced_data: cliext.enhanced_data)
108+
if ci.should_i_use?
109+
print Paint[cs, :green]
110+
else
111+
print Paint[cs, :red]
112+
print ' -- '
113+
print Paint['weak', :red, :bold]
114+
end
115+
puts
116+
else
117+
puts Paint[cs, :green]
118+
end
102119
end
103120
elsif args['export']
104121
cli = TLSmap::CLI.new(args['--force'])

docs/CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
## [Unreleased]
44

5+
Additions:
6+
7+
- Add an `--audit` option to bulk mode to highlight weak cipher suites [#104](https://github.com/noraj/tls-map/issues/104)
8+
59
Enhancements:
610

711
- Display protocol version for extract command when options are used [#54](https://github.com/noraj/tls-map/issues/54)
8-
- Colored help message
12+
- Colored help message [2627eb8](https://github.com/noraj/tls-map/commit/2627eb81914cb932e5eb6638d5de80dccaa8833b)
913

1014
Chore:
1115

docs/pages/examples.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,7 @@ release.
214214

215215
### Bulk search
216216

217-
Search and translate cipher names between SSL/TLS libraries **in bulk**
218-
219-
`test/file_sample/bulk_IANA.txt`
217+
Example file `test/file_sample/bulk_IANA.txt` with IANA named cipher suites:
220218

221219
```
222220
TLS_DH_RSA_WITH_AES_256_CBC_SHA
@@ -227,6 +225,8 @@ TLS_CHACHA20_POLY1305_SHA256
227225
TLS_AES_256_GCM_SHA384
228226
```
229227

228+
Search and translate cipher names between SSL/TLS libraries **in bulk**:
229+
230230
```
231231
$ tls-map bulk iana test/file_sample/bulk_IANA.txt -q openssl
232232
DH-RSA-AES256-SHA
@@ -237,6 +237,17 @@ TLS_CHACHA20_POLY1305_SHA256
237237
TLS_AES_256_GCM_SHA384
238238
```
239239

240+
Search and audit if ciphers are weak **in bulk**:
241+
242+
```
243+
$ tls-map bulk iana test/file_sample/bulk_IANA.txt --audit
244+
TLS_DH_RSA_WITH_AES_256_CBC_SHA -- weak
245+
TLS_RSA_WITH_RC4_128_SHA -- weak
246+
TLS_RSA_WITH_AES_128_CBC_SHA -- weak
247+
TLS_CHACHA20_POLY1305_SHA256
248+
TLS_AES_256_GCM_SHA384
249+
```
250+
240251
## Library
241252

242253
Basic usage, searching for cipher name equivalent in other libraries.

0 commit comments

Comments
 (0)