Skip to content

Commit

Permalink
Fill in the Query for HTTP transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tudor Golubenco committed Mar 31, 2015
1 parent 0a13f16 commit 0082596
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions protos/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ func (http *Http) PublishTransaction(t *HttpTransaction) {
}
event["method"] = t.Method
event["path"] = t.RequestUri
event["query"] = fmt.Sprintf("%s %s", t.Method, t.RequestUri)
event["params"] = t.Params

event["@timestamp"] = common.Time(t.ts)
Expand Down
37 changes: 37 additions & 0 deletions tests/test_0024_http_query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from pbtests.packetbeat import TestCase

"""
Tests for checking that HTTP query is filled.
"""


class Test(TestCase):

def test_http_post(self):
"""
Should be able to parse the parameters from the HTTP POST request.
"""
self.render_config_template()
self.run_packetbeat(pcap="http_post.pcap",
debug_selectors=["http", "httpdetailed"])
objs = self.read_output()

assert len(objs) == 1
o = objs[0]
assert o["type"] == "http"
assert o["query"] == "POST /register"

def test_http_get(self):
"""
Should be able to parse the parameters from the HTTP POST request.
"""
self.render_config_template()
self.run_packetbeat(pcap="http_url_params.pcap",
debug_selectors=["http", "httpdetailed"])
objs = self.read_output()

assert len(objs) == 1
o = objs[0]
assert o["type"] == "http"
assert o["query"] == "GET /dashboard/transactions?" + \
"input=packetbeat&src_ip=192.35.243.1"

0 comments on commit 0082596

Please sign in to comment.