Skip to content

Commit

Permalink
Added the --nodejs option to ronin quote (closes #247).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent f221500 commit 5887b1a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ronin/cli/commands/quote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module Commands
# -c, --c Quotes the data as a C string
# -J, --java Quotes the data as a Java string
# -j, --js Quotes the data as a JavaScript string
# -n, --nodejs Quotes the data as a Node.js string
# -S, --shell Quotes the data as a Shell string
# -P, --powershell Quotes the data as a PowerShell string
# --perl Quotes the data as a Perl string
Expand Down Expand Up @@ -70,6 +71,12 @@ class Quote < StringMethodsCommand
@method_calls << :java_string
end

option :nodejs, short: '-n',
desc: 'Quotes the data as a Node.js string' do
require 'ronin/support/encoding/node_js'
@method_calls << :node_js_string
end

option :js, short: '-j',
desc: 'Quotes the data as a JavaScript string' do
require 'ronin/support/encoding/js'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-quote.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ Produces quoted a string for a variety of programming languages.
`-j`, `--js`
: Quotes the data as a JavaScript string.

`-n`, `--nodejs`
: Quotes the data as a Node.js string.

`-S`, `--shell`
: Quotes the data as a Shell string.

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/quote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@
end
end

describe "--nodejs" do
let(:argv) { %w[--nodejs] }

it "must require 'ronin/support/encoding/node_js'" do
expect(require('ronin/support/encoding/node_js')).to be(false)
end

it "must add :node_js_string to #method_calls" do
expect(subject.method_calls.last).to eq(:node_js_string)
end
end

describe "--shell" do
let(:argv) { %w[--shell] }

Expand Down

0 comments on commit 5887b1a

Please sign in to comment.