Skip to content

Commit

Permalink
Added the --for-organization option to ronin-db emails (closes #69).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Feb 6, 2024
1 parent b48bd21 commit aa841f7
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 @@ -46,6 +46,7 @@ module Commands
# -I, --with-ip [IP [...]]
# -u, --with-user [NAME [...]]
# -P, --for-person FULL_NAME Searches for the associated person
# -O, --for-organization NAME Searches for the associated organization
#
class Emails < ModelCommand

Expand Down Expand Up @@ -90,6 +91,15 @@ class Emails < ModelCommand
@query_method_calls << [:for_person, [full_name]]
end

option :for_organization, short: '-O',
value: {
type: String,
usage: 'NAME'
},
desc: 'Searches for the associated organization' do |name|
@query_method_calls << [:for_organization, [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 @@ -54,6 +54,9 @@ Manages email addresses.
`-P`, `--for-person` *FULL_NAME*
: Searches for email addresses associated with the person's full name.

`-O`, `--for-organization` *NAME*
: Searches for email addresses associated with the organization's 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 @@ -71,5 +71,20 @@
expect(Ronin::DB::EmailAddress).to respond_to(:for_person)
end
end

describe "--for-person FULL_NAME" do
let(:name) { 'ACME, Inc.' }
let(:argv) { ['--for-organization', name] }

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

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

0 comments on commit aa841f7

Please sign in to comment.