Skip to content

Commit

Permalink
Added the --for-person option to ronin-db emails (closes #68).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Feb 5, 2024
1 parent dfaa273 commit b48bd21
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/ronin/db/cli/commands/emails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module Commands
# -H, --with-host [HOST [...]]
# -I, --with-ip [IP [...]]
# -u, --with-user [NAME [...]]
# -P, --for-person FULL_NAME Searches for the associated person
#
class Emails < ModelCommand

Expand Down Expand Up @@ -80,6 +81,15 @@ class Emails < ModelCommand
@query_method_calls << [:with_user_name, [user]]
end

option :for_person, short: '-P',
value: {
type: String,
usage: 'FULL_NAME'
},
desc: 'Searches for the associated person' do |full_name|
@query_method_calls << [:for_person, [full_name]]
end

description 'Manages all email addresses in the database'

man_page 'ronin-db-emails.1'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-db-emails.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ Manages email addresses.
`-u`, `--with-users` *NAME* [...]
: Searches for email addresses associated with the user NAME(s).

`-P`, `--for-person` *FULL_NAME*
: Searches for email addresses associated with the person's full name.

`-h`, `--help`
: Print help information.

Expand Down
15 changes: 15 additions & 0 deletions spec/cli/commands/emails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,20 @@
expect(Ronin::DB::EmailAddress).to respond_to(:with_user_name)
end
end

describe "--for-person FULL_NAME" do
let(:full_name) { 'John Smith' }
let(:argv) { ['--for-person', full_name] }

it "must append :for_person and the full name to #query_method_calls" do
expect(subject.query_method_calls[-1]).to eq(
[:for_person, [full_name]]
)
end

it "and .for_person must be a class method on Ronin::DB::EmailAddress" do
expect(Ronin::DB::EmailAddress).to respond_to(:for_person)
end
end
end
end

0 comments on commit b48bd21

Please sign in to comment.