diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 52dd597..794df87 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,8 @@ - Add a new class `Unisec::Bidi::Spoof` and CLI command `bidi spoof` to craft payloads for attack using BiDi code points like RtLO, for example, for spoofing a domain name or a file name - Add a new helper method: `Unisec::Utils::String.grapheme_reverse`: Reverse a string by graphemes (not by code points) +- Add an `--enc` option for `unisec hexdump` to output only in the specified encoding +- `unisec hexdump` can now read from STDIN if the input equals to `-` ## [0.0.3] diff --git a/docs/yard/Integer.html b/docs/yard/Integer.html index be4077e..80ab82b 100644 --- a/docs/yard/Integer.html +++ b/docs/yard/Integer.html @@ -304,7 +304,7 @@

diff --git a/docs/yard/Unisec.html b/docs/yard/Unisec.html index 1105711..948f530 100644 --- a/docs/yard/Unisec.html +++ b/docs/yard/Unisec.html @@ -135,7 +135,7 @@

diff --git a/docs/yard/Unisec/Bidi.html b/docs/yard/Unisec/Bidi.html index 6501d88..f224b10 100644 --- a/docs/yard/Unisec/Bidi.html +++ b/docs/yard/Unisec/Bidi.html @@ -131,7 +131,7 @@

Overview

diff --git a/docs/yard/Unisec/Bidi/Spoof.html b/docs/yard/Unisec/Bidi/Spoof.html index 22c5b05..e442c8c 100644 --- a/docs/yard/Unisec/Bidi/Spoof.html +++ b/docs/yard/Unisec/Bidi/Spoof.html @@ -1309,7 +1309,7 @@

diff --git a/docs/yard/Unisec/CLI.html b/docs/yard/Unisec/CLI.html index c1abbd3..234a7c6 100644 --- a/docs/yard/Unisec/CLI.html +++ b/docs/yard/Unisec/CLI.html @@ -117,7 +117,7 @@

Overview

diff --git a/docs/yard/Unisec/CLI/Commands.html b/docs/yard/Unisec/CLI/Commands.html index bb40188..6c1382c 100644 --- a/docs/yard/Unisec/CLI/Commands.html +++ b/docs/yard/Unisec/CLI/Commands.html @@ -125,7 +125,7 @@

Overview

diff --git a/docs/yard/Unisec/CLI/Commands/Bidi.html b/docs/yard/Unisec/CLI/Commands/Bidi.html index 289e7d6..b209def 100644 --- a/docs/yard/Unisec/CLI/Commands/Bidi.html +++ b/docs/yard/Unisec/CLI/Commands/Bidi.html @@ -115,7 +115,7 @@

Overview

diff --git a/docs/yard/Unisec/CLI/Commands/Bidi/Spoof.html b/docs/yard/Unisec/CLI/Commands/Bidi/Spoof.html index b79b986..6d958b7 100644 --- a/docs/yard/Unisec/CLI/Commands/Bidi/Spoof.html +++ b/docs/yard/Unisec/CLI/Commands/Bidi/Spoof.html @@ -269,7 +269,7 @@

diff --git a/docs/yard/Unisec/CLI/Commands/Confusables.html b/docs/yard/Unisec/CLI/Commands/Confusables.html index 760a5e5..a7e1812 100644 --- a/docs/yard/Unisec/CLI/Commands/Confusables.html +++ b/docs/yard/Unisec/CLI/Commands/Confusables.html @@ -115,7 +115,7 @@

Overview

diff --git a/docs/yard/Unisec/CLI/Commands/Confusables/List.html b/docs/yard/Unisec/CLI/Commands/Confusables/List.html index 72fea91..8c8e859 100644 --- a/docs/yard/Unisec/CLI/Commands/Confusables/List.html +++ b/docs/yard/Unisec/CLI/Commands/Confusables/List.html @@ -272,7 +272,7 @@

diff --git a/docs/yard/Unisec/CLI/Commands/Confusables/Randomize.html b/docs/yard/Unisec/CLI/Commands/Confusables/Randomize.html index f0af554..6b4a122 100644 --- a/docs/yard/Unisec/CLI/Commands/Confusables/Randomize.html +++ b/docs/yard/Unisec/CLI/Commands/Confusables/Randomize.html @@ -231,7 +231,7 @@

diff --git a/docs/yard/Unisec/CLI/Commands/Grep.html b/docs/yard/Unisec/CLI/Commands/Grep.html index 7a3b9d9..814391c 100644 --- a/docs/yard/Unisec/CLI/Commands/Grep.html +++ b/docs/yard/Unisec/CLI/Commands/Grep.html @@ -231,7 +231,7 @@

diff --git a/docs/yard/Unisec/CLI/Commands/Hexdump.html b/docs/yard/Unisec/CLI/Commands/Hexdump.html index cb6bdf6..ae2649f 100644 --- a/docs/yard/Unisec/CLI/Commands/Hexdump.html +++ b/docs/yard/Unisec/CLI/Commands/Hexdump.html @@ -137,7 +137,7 @@

  • - #call(input: nil) ⇒ Object + #call(input: nil, **options) ⇒ Object @@ -170,7 +170,7 @@

    Instance Method Details

    - #call(input: nil) ⇒ Object + #call(input: nil, **options) ⇒ Object @@ -213,15 +213,27 @@

     
     
    -29
    -30
    -31
    +32 +33 +34 +35 +36 +37 +38 +39 +40 -
    # File 'lib/unisec/cli/hexdump.rb', line 29
    -
    -def call(input: nil, **)
    -  puts Unisec::Hexdump.new(input).display
    +      
    # File 'lib/unisec/cli/hexdump.rb', line 32
    +
    +def call(input: nil, **options)
    +  input = $stdin.read.chomp if input == '-'
    +  if options[:enc].nil?
    +    puts Unisec::Hexdump.new(input).display
    +  else
    +    # using send() is safe here thanks to the value whitelist
    +    puts puts Unisec::Hexdump.send(options[:enc], input)
    +  end
     end
    @@ -233,7 +245,7 @@

    diff --git a/docs/yard/Unisec/CLI/Commands/Properties.html b/docs/yard/Unisec/CLI/Commands/Properties.html index 1682a86..4dc5bcb 100644 --- a/docs/yard/Unisec/CLI/Commands/Properties.html +++ b/docs/yard/Unisec/CLI/Commands/Properties.html @@ -115,7 +115,7 @@

    Overview

    diff --git a/docs/yard/Unisec/CLI/Commands/Properties/Char.html b/docs/yard/Unisec/CLI/Commands/Properties/Char.html index 7e9a732..f6bf389 100644 --- a/docs/yard/Unisec/CLI/Commands/Properties/Char.html +++ b/docs/yard/Unisec/CLI/Commands/Properties/Char.html @@ -273,7 +273,7 @@

    diff --git a/docs/yard/Unisec/CLI/Commands/Properties/Codepoints.html b/docs/yard/Unisec/CLI/Commands/Properties/Codepoints.html index 5878f05..da19d34 100644 --- a/docs/yard/Unisec/CLI/Commands/Properties/Codepoints.html +++ b/docs/yard/Unisec/CLI/Commands/Properties/Codepoints.html @@ -230,7 +230,7 @@

    diff --git a/docs/yard/Unisec/CLI/Commands/Properties/List.html b/docs/yard/Unisec/CLI/Commands/Properties/List.html index f99f327..407ab96 100644 --- a/docs/yard/Unisec/CLI/Commands/Properties/List.html +++ b/docs/yard/Unisec/CLI/Commands/Properties/List.html @@ -215,7 +215,7 @@

    diff --git a/docs/yard/Unisec/CLI/Commands/Size.html b/docs/yard/Unisec/CLI/Commands/Size.html index 146737f..d08f929 100644 --- a/docs/yard/Unisec/CLI/Commands/Size.html +++ b/docs/yard/Unisec/CLI/Commands/Size.html @@ -236,7 +236,7 @@

    diff --git a/docs/yard/Unisec/CLI/Commands/Surrogates.html b/docs/yard/Unisec/CLI/Commands/Surrogates.html index 3b78234..1860a4d 100644 --- a/docs/yard/Unisec/CLI/Commands/Surrogates.html +++ b/docs/yard/Unisec/CLI/Commands/Surrogates.html @@ -115,7 +115,7 @@

    Overview

    diff --git a/docs/yard/Unisec/CLI/Commands/Surrogates/From.html b/docs/yard/Unisec/CLI/Commands/Surrogates/From.html index c15009d..30e0cfd 100644 --- a/docs/yard/Unisec/CLI/Commands/Surrogates/From.html +++ b/docs/yard/Unisec/CLI/Commands/Surrogates/From.html @@ -251,7 +251,7 @@

    diff --git a/docs/yard/Unisec/CLI/Commands/Surrogates/To.html b/docs/yard/Unisec/CLI/Commands/Surrogates/To.html index 72da0c3..b60d0f8 100644 --- a/docs/yard/Unisec/CLI/Commands/Surrogates/To.html +++ b/docs/yard/Unisec/CLI/Commands/Surrogates/To.html @@ -232,7 +232,7 @@

    diff --git a/docs/yard/Unisec/CLI/Commands/Versions.html b/docs/yard/Unisec/CLI/Commands/Versions.html index 04d68b7..74370d7 100644 --- a/docs/yard/Unisec/CLI/Commands/Versions.html +++ b/docs/yard/Unisec/CLI/Commands/Versions.html @@ -219,7 +219,7 @@

    diff --git a/docs/yard/Unisec/Confusables.html b/docs/yard/Unisec/Confusables.html index 1208495..4646963 100644 --- a/docs/yard/Unisec/Confusables.html +++ b/docs/yard/Unisec/Confusables.html @@ -575,7 +575,7 @@

    diff --git a/docs/yard/Unisec/Hexdump.html b/docs/yard/Unisec/Hexdump.html index 1cd3bab..73d35dc 100644 --- a/docs/yard/Unisec/Hexdump.html +++ b/docs/yard/Unisec/Hexdump.html @@ -1324,7 +1324,7 @@

    diff --git a/docs/yard/Unisec/Properties.html b/docs/yard/Unisec/Properties.html index 3394057..755309c 100644 --- a/docs/yard/Unisec/Properties.html +++ b/docs/yard/Unisec/Properties.html @@ -1140,7 +1140,7 @@

    diff --git a/docs/yard/Unisec/Rugrep.html b/docs/yard/Unisec/Rugrep.html index a3fc81d..3708641 100644 --- a/docs/yard/Unisec/Rugrep.html +++ b/docs/yard/Unisec/Rugrep.html @@ -731,7 +731,7 @@

    diff --git a/docs/yard/Unisec/Size.html b/docs/yard/Unisec/Size.html index cd158dd..c9fc9bd 100644 --- a/docs/yard/Unisec/Size.html +++ b/docs/yard/Unisec/Size.html @@ -1966,7 +1966,7 @@

    diff --git a/docs/yard/Unisec/Surrogates.html b/docs/yard/Unisec/Surrogates.html index b9ce904..3f8110e 100644 --- a/docs/yard/Unisec/Surrogates.html +++ b/docs/yard/Unisec/Surrogates.html @@ -1229,7 +1229,7 @@

    diff --git a/docs/yard/Unisec/Utils.html b/docs/yard/Unisec/Utils.html index f4cb3f5..faec94b 100644 --- a/docs/yard/Unisec/Utils.html +++ b/docs/yard/Unisec/Utils.html @@ -115,7 +115,7 @@

    Overview

    diff --git a/docs/yard/Unisec/Utils/String.html b/docs/yard/Unisec/Utils/String.html index 1644e63..cc203e1 100644 --- a/docs/yard/Unisec/Utils/String.html +++ b/docs/yard/Unisec/Utils/String.html @@ -613,7 +613,7 @@

    diff --git a/docs/yard/Unisec/Versions.html b/docs/yard/Unisec/Versions.html index 461f646..8164262 100644 --- a/docs/yard/Unisec/Versions.html +++ b/docs/yard/Unisec/Versions.html @@ -416,7 +416,7 @@

    diff --git a/docs/yard/_index.html b/docs/yard/_index.html index 79e36f7..4422c70 100644 --- a/docs/yard/_index.html +++ b/docs/yard/_index.html @@ -428,7 +428,7 @@

    Namespace Listing A-Z

    diff --git a/docs/yard/file.CHANGELOG.html b/docs/yard/file.CHANGELOG.html index b07bc48..133bd73 100644 --- a/docs/yard/file.CHANGELOG.html +++ b/docs/yard/file.CHANGELOG.html @@ -63,6 +63,8 @@

    [0.0.4]

    • Add a new class Unisec::Bidi::Spoof and CLI command bidi spoof to craft payloads for attack using BiDi code points like RtLO, for example, for spoofing a domain name or a file name
    • Add a new helper method: Unisec::Utils::String.grapheme_reverse: Reverse a string by graphemes (not by code points)
    • +
    • Add an --enc option for unisec hexdump to output only in the specified encoding
    • +
    • unisec hexdump can now read from STDIN if the input equals to -

    [0.0.3]

    Features

    @@ -91,7 +93,7 @@

    [0.0.1]

    diff --git a/docs/yard/file.LICENSE.html b/docs/yard/file.LICENSE.html index 52ef99d..c117022 100644 --- a/docs/yard/file.LICENSE.html +++ b/docs/yard/file.LICENSE.html @@ -77,7 +77,7 @@ diff --git a/docs/yard/file.README.html b/docs/yard/file.README.html index d8435b7..6518bb4 100644 --- a/docs/yard/file.README.html +++ b/docs/yard/file.README.html @@ -130,7 +130,7 @@

    Author

    diff --git a/docs/yard/file.about.html b/docs/yard/file.about.html index 912ed68..834ac59 100644 --- a/docs/yard/file.about.html +++ b/docs/yard/file.about.html @@ -67,7 +67,7 @@

    User documentation

    diff --git a/docs/yard/file.documentation.html b/docs/yard/file.documentation.html index 44dd2ef..58a7bc3 100644 --- a/docs/yard/file.documentation.html +++ b/docs/yard/file.documentation.html @@ -76,7 +76,7 @@

    Build & serve locally

    diff --git a/docs/yard/file.install.html b/docs/yard/file.install.html index 8a182ff..79ece1c 100644 --- a/docs/yard/file.install.html +++ b/docs/yard/file.install.html @@ -111,7 +111,7 @@

    No install

    diff --git a/docs/yard/file.publishing.html b/docs/yard/file.publishing.html index 7f3a07f..d3093c4 100644 --- a/docs/yard/file.publishing.html +++ b/docs/yard/file.publishing.html @@ -84,7 +84,7 @@ diff --git a/docs/yard/file.quick-start.html b/docs/yard/file.quick-start.html index 9a2c505..b761860 100644 --- a/docs/yard/file.quick-start.html +++ b/docs/yard/file.quick-start.html @@ -78,7 +78,7 @@

    Default usage: library

    diff --git a/docs/yard/file.usage.html b/docs/yard/file.usage.html index fc038ae..90feb10 100644 --- a/docs/yard/file.usage.html +++ b/docs/yard/file.usage.html @@ -143,7 +143,7 @@

    Library

    diff --git a/docs/yard/index.html b/docs/yard/index.html index 0126d48..ac34bf0 100644 --- a/docs/yard/index.html +++ b/docs/yard/index.html @@ -130,7 +130,7 @@

    Author

    diff --git a/docs/yard/top-level-namespace.html b/docs/yard/top-level-namespace.html index 35b6927..bc1252e 100644 --- a/docs/yard/top-level-namespace.html +++ b/docs/yard/top-level-namespace.html @@ -102,7 +102,7 @@

    Defined Under Namespace

    diff --git a/lib/unisec/cli/hexdump.rb b/lib/unisec/cli/hexdump.rb index dd4e4de..c07d298 100644 --- a/lib/unisec/cli/hexdump.rb +++ b/lib/unisec/cli/hexdump.rb @@ -22,12 +22,21 @@ class Hexdump < Dry::CLI::Command desc 'Hexdump in all Unicode encodings' argument :input, required: true, - desc: 'String input' + desc: 'String input. Read from STDIN if equal to -.' + + option :enc, default: nil, values: %w[utf8 utf16be utf16le utf32be utf32le], + desc: 'Output only in the specified encoding.' # Hexdump of all Unicode encodings. # @param input [String] Input string to encode - def call(input: nil, **) - puts Unisec::Hexdump.new(input).display + def call(input: nil, **options) + input = $stdin.read.chomp if input == '-' + if options[:enc].nil? + puts Unisec::Hexdump.new(input).display + else + # using send() is safe here thanks to the value whitelist + puts puts Unisec::Hexdump.send(options[:enc], input) + end end end end