Skip to content

Commit

Permalink
Renamed the raw_user_agent param to user_agent_string.
Browse files Browse the repository at this point in the history
* This matches the `ronin http` command which defines
  `--user-agent` and `--user-agent-string` options.
  • Loading branch information
postmodern committed Apr 17, 2024
1 parent ec39395 commit e0dee40
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions lib/ronin/exploits/mixins/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def self.included(exploit)

exploit.param :user_agent, Core::Params::Types::Enum.new(HTTP_USER_AGENT_ALIASES), desc: 'The HTTP User-Agent to select'

exploit.param :raw_user_agent, desc: 'The raw HTTP User-Agent string to use'
exploit.param :user_agent_string, desc: 'The raw HTTP User-Agent string to use'

exploit.param :http_cookie, desc: 'The raw HTTP Cookie to use'
end
Expand Down Expand Up @@ -126,7 +126,7 @@ def http_headers
# @api private
#
def http_user_agent
params[:raw_user_agent] || params[:user_agent]
params[:user_agent_string] || params[:user_agent]
end

#
Expand Down
50 changes: 25 additions & 25 deletions spec/mixins/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def http_headers
expect(subject.params[:user_agent].desc).to eq("The HTTP User-Agent to select")
end

it "must define a 'raw_user_agent' param" do
expect(subject.params[:raw_user_agent]).to_not be_nil
expect(subject.params[:raw_user_agent].desc).to eq("The raw HTTP User-Agent string to use")
it "must define a 'user_agent_string' param" do
expect(subject.params[:user_agent_string]).to_not be_nil
expect(subject.params[:user_agent_string].desc).to eq("The raw HTTP User-Agent string to use")
end
end

Expand Down Expand Up @@ -95,42 +95,42 @@ def http_headers
end
end

context "when params[:raw_user_agent] is set" do
let(:raw_user_agent) { 'Mozilla/5.0 Foo Bar' }
context "when params[:user_agent_string] is set" do
let(:user_agent_string) { 'Mozilla/5.0 Foo Bar' }

subject do
test_class.new(
params: {
base_url: base_url,
raw_user_agent: raw_user_agent
user_agent_string: user_agent_string
}
)
end

it "must return params[:raw_user_agent]" do
it "must return params[:user_agent_string]" do
expect(subject.http_user_agent).to be(
subject.params[:raw_user_agent]
subject.params[:user_agent_string]
)
end
end

context "when both params[:user_agent] and params[:raw_user_agent] are set" do
let(:user_agent) { :random }
let(:raw_user_agent) { 'Mozilla/5.0 Foo Bar' }
context "when both params[:user_agent] and params[:user_agent_string] are set" do
let(:user_agent) { :random }
let(:user_agent_string) { 'Mozilla/5.0 Foo Bar' }

subject do
test_class.new(
params: {
base_url: base_url,
user_agent: user_agent,
raw_user_agent: raw_user_agent
user_agent_string: user_agent_string
}
)
end

it "must return params[:raw_user_agent]" do
it "must return params[:user_agent_string]" do
expect(subject.http_user_agent).to be(
subject.params[:raw_user_agent]
subject.params[:user_agent_string]
)
end
end
Expand All @@ -155,21 +155,21 @@ def http_headers
end
end

let(:proxy) { URI('https://proxy.example.com:8080') }
let(:raw_user_agent) { 'Mozilla/5.0 Foo Bar' }
let(:cookie) { "foo=1; bar=2" }
let(:user) { 'bob' }
let(:password) { 'secret' }
let(:proxy) { URI('https://proxy.example.com:8080') }
let(:user_agent_string) { 'Mozilla/5.0 Foo Bar' }
let(:cookie) { "foo=1; bar=2" }
let(:user) { 'bob' }
let(:password) { 'secret' }

subject do
test_class.new(
params: {
base_url: base_url,
http_proxy: proxy,
raw_user_agent: raw_user_agent,
http_cookie: cookie,
http_user: user,
http_password: password
base_url: base_url,
http_proxy: proxy,
user_agent_string: user_agent_string,
http_cookie: cookie,
http_user: user,
http_password: password
}
)
end
Expand Down

0 comments on commit e0dee40

Please sign in to comment.