Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion patterns/grok-patterns
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ URIPROTO [A-Za-z]+(\+[A-Za-z+]+)?
URIHOST %{IPORHOST}(?::%{POSINT:port})?
# uripath comes loosely from RFC1738, but mostly from what Firefox
# doesn't turn into %XX
URIPATH (?:/[A-Za-z0-9$.+!*'(){},~:;=@#%_\-]*)+
URIPATH (?:/[A-Za-z0-9$.+!*'(){},~:;=@#%&_\-]*)+
#URIPARAM \?(?:[A-Za-z0-9]+(?:=(?:[^&]*))?(?:&(?:[A-Za-z0-9]+(?:=(?:[^&]*))?)?)*)?
URIPARAM \?[A-Za-z0-9$.+!*'|(){},~@#%&/=:;_?\-\[\]<>]*
URIPATHPARAM %{URIPATH}(?:%{URIPARAM})?
Expand Down
56 changes: 56 additions & 0 deletions spec/patterns/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,62 @@
end
end

describe "URIPATH" do
let(:pattern) { 'URIPATH' }

context "when matching valid URIs" do
context "and the URI is simple" do
let(:value) { '/foo' }

it "should match the path" do
expect(grok_match(pattern,value)).to pass
end
end

context "and the URI has a trailing slash" do
let(:value) { '/foo/' }

it "should match the path" do
expect(grok_match(pattern,value)).to pass
end
end

context "and the URI has multiple levels" do
let(:value) { '/foo/bar' }

it "should match the path" do
expect(grok_match(pattern,value)).to pass
end
end

context "and the URI has fancy characters" do
let(:value) { '/aA1$.+!*\'(){},~:;=@#%&|-' }

it "should match the path" do
expect(grok_match(pattern,value)).to pass
end
end
end

context "when matching invalid URIs" do
context "and the URI has no leading slash" do
let(:value) { 'foo' }

it "should not match the path" do
expect(grok_match(pattern,value)).not_to pass
end
end

context "and the URI has invalid characters" do
let(:value) { '/`' }

it "should not match the path" do
expect(grok_match(pattern,value)).not_to pass
end
end
end
end

describe "IPV4" do

let(:pattern) { 'IPV4' }
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def grok_match(label, message)
end

def build_grok(label)
grok = LogStash::Filters::Grok.new("match" => ["message", "%{#{label}}"])
grok = LogStash::Filters::Grok.new("match" => ["message", "\A%{#{label}}\z"])
grok.register
grok
end
Expand Down