Skip to content

Commit 9b7b848

Browse files
committed
adds rfc compliant http1 parser
1 parent 8fc1179 commit 9b7b848

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5247
-1157
lines changed

.claude/settings.local.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(go run:*)",
5+
"Bash(grep:*)",
6+
"Bash(go doc:*)",
7+
"Bash(go test:*)",
8+
"Bash(ls:*)",
9+
"Bash(go build:*)",
10+
"Bash(mkdir:*)",
11+
"WebFetch(domain:pkg.go.dev)",
12+
"Bash(go tool:*)",
13+
"Bash(go vet:*)",
14+
"Bash(find:*)",
15+
"Bash(make:*)",
16+
"Bash(go list:*)",
17+
"Bash(sed:*)",
18+
"Bash(printf:*)",
19+
"Bash(echo:*)",
20+
"mcp__ide__getDiagnostics",
21+
"Bash(golangci-lint run:*)"
22+
],
23+
"deny": []
24+
}
25+
}

examples/fluentbit/lua/extract-payloads.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function extract_payloads(tag, timestamp, record)
1414
}
1515

1616
-- Get the request ID from the original record
17-
local request_id = record.request and record.request.qpoint_request_id
17+
local request_id = record.request and record.request.request_id
1818

1919
-- Create a copy of the original record to modify
2020
local modified_record = {}
@@ -51,7 +51,7 @@ function extract_payloads(tag, timestamp, record)
5151
local new_record = {
5252
msg = "HTTP payload",
5353
payload = field.payload,
54-
qpoint_request_id = request_id,
54+
request_id = request_id,
5555
data = current
5656
}
5757

examples/fluentbit/lua/s3-payloads.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function process_payloads(tag, timestamp, record)
1717
}
1818

1919
-- Get the request ID from the original record
20-
local request_id = record.request and record.request.qpoint_request_id
20+
local request_id = record.request and record.request.request_id
2121

2222
-- Get S3 configuration from environment variables
2323
local s3_bucket = os.getenv("S3_BUCKET")
@@ -71,7 +71,7 @@ function process_payloads(tag, timestamp, record)
7171
local new_record = {
7272
msg = "HTTP payload",
7373
payload = field.payload,
74-
qpoint_request_id = request_id,
74+
request_id = request_id,
7575
data = current,
7676
s3_key = s3_key
7777
}

pkg/connection/connection.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ func (c *Connection) Close() {
386386
}
387387

388388
func (c *Connection) SetDomain(input string) {
389+
if input == "" {
390+
return
391+
}
392+
389393
if !c.domainIsIP && len(c.domain) > 0 {
390394
return
391395
}
@@ -403,6 +407,11 @@ func (c *Connection) SetDomain(input string) {
403407
return
404408
}
405409

410+
// don't allow the same domain to be set twice
411+
if strings.EqualFold(domain, c.domain) {
412+
return
413+
}
414+
406415
// set the domain
407416
c.domain = domain
408417
c.domainIsIP = domainIsIP

pkg/plugins/accesslogs/json.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (j *JSONPrinter) PrintSummary() {
5858
zap.String("method", method),
5959
zap.String("url", url),
6060
zap.Int("status", status),
61-
zap.String("qpoint_request_id", requestID))
61+
zap.String("request_id", requestID))
6262
}
6363

6464
// PrintDetails implements Printer.PrintDetails
@@ -74,7 +74,7 @@ func (j *JSONPrinter) PrintFull() error {
7474
func (j *JSONPrinter) printJSONDetails(includeBody bool) error {
7575
meta := j.ctx.Meta()
7676
reqHeaders := tools.NewHeaderMap(j.reqheaders)
77-
qpointRequestID, _ := reqHeaders.QpointRequestID()
77+
requestID := meta.RequestID()
7878
url, _ := reqHeaders.URL()
7979
method, _ := reqHeaders.Method()
8080
protocol := meta.Protocol()
@@ -85,11 +85,11 @@ func (j *JSONPrinter) printJSONDetails(includeBody bool) error {
8585
status, _ := resHeaders.Status()
8686

8787
req := map[string]any{
88-
"url": url,
89-
"method": method,
90-
"proto": protocol,
91-
"qpoint_request_id": qpointRequestID,
92-
"headers": j.reqheaders.All(),
88+
"url": url,
89+
"method": method,
90+
"proto": protocol,
91+
"request_id": requestID,
92+
"headers": j.reqheaders.All(),
9393
}
9494
if includeBody {
9595
if reqHeaders.BinaryContentType() {

pkg/plugins/connection.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (c *Connection) Teardown() {
9393
// set the request and request body
9494
func (c *Connection) SetRequest(req *http.Request) {
9595
// extract URL pieces and set them as headers
96+
// TODO(Jon): we should not be setting these
9697
req.Header.Set(":authority", req.Host)
9798
req.Header.Set(":method", req.Method)
9899
req.Header.Set(":path", req.URL.Path)

pkg/plugins/httpcapture/formatter_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ func TestHttpTransactionFormatting(t *testing.T) {
2727
DurationMs: 150,
2828
Direction: "egress-external",
2929
Metadata: Metadata{
30-
ProcessID: "1234",
31-
ProcessExe: "/usr/bin/curl",
32-
BytesSent: 100,
33-
BytesReceived: 200,
34-
ConnectionID: "conn-123",
35-
EndpointID: "ep-123",
36-
ContainerName: "test-container",
37-
ContainerImage: "nginx:latest",
38-
QpointRequestID: "req-123",
30+
ProcessID: "1234",
31+
ProcessExe: "/usr/bin/curl",
32+
BytesSent: 100,
33+
BytesReceived: 200,
34+
ConnectionID: "conn-123",
35+
EndpointID: "ep-123",
36+
ContainerName: "test-container",
37+
ContainerImage: "nginx:latest",
38+
RequestID: "req-123",
3939
},
4040
Request: Request{
4141
Method: "POST",

pkg/plugins/httpcapture/httpcapture_test.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ func TestHttpTransactionSerialization(t *testing.T) {
1616
DurationMs: 100,
1717
Direction: "egress-external",
1818
Metadata: Metadata{
19-
ProcessID: "12345",
20-
ProcessExe: "/usr/bin/app",
21-
ContainerName: "test-container",
22-
EndpointID: "test-endpoint",
23-
ConnectionID: "test-connection",
24-
QpointRequestID: "test-request-id",
25-
BytesSent: 100,
26-
BytesReceived: 200,
19+
ProcessID: "12345",
20+
ProcessExe: "/usr/bin/app",
21+
ContainerName: "test-container",
22+
EndpointID: "test-endpoint",
23+
ConnectionID: "test-connection",
24+
RequestID: "test-request-id",
25+
BytesSent: 100,
26+
BytesReceived: 200,
2727
},
2828
Request: Request{
2929
Method: "GET",
@@ -34,13 +34,12 @@ func TestHttpTransactionSerialization(t *testing.T) {
3434
UserAgent: "test-agent",
3535
ContentType: "application/json",
3636
Headers: map[string]string{
37-
":method": "GET",
38-
":path": "/api/users",
39-
":authority": "example.com",
40-
":scheme": "https",
41-
"User-Agent": "test-agent",
42-
"Content-Type": "application/json",
43-
"qpoint-request-id": "test-request-id",
37+
":method": "GET",
38+
":path": "/api/users",
39+
":authority": "example.com",
40+
":scheme": "https",
41+
"User-Agent": "test-agent",
42+
"Content-Type": "application/json",
4443
},
4544
Body: []byte(`{"test":"request"}`),
4645
},

pkg/plugins/httpcapture/httptransaction.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ type HttpTransaction struct {
2828

2929
// Metadata contains process and connection information
3030
type Metadata struct {
31-
ProcessID string `json:"process_id,omitempty"`
32-
ProcessExe string `json:"process_exe,omitempty"`
33-
ContainerName string `json:"container_name,omitempty"`
34-
ContainerImage string `json:"container_image,omitempty"`
35-
PodName string `json:"pod_name,omitempty"`
36-
PodNamespace string `json:"pod_namespace,omitempty"`
37-
BytesSent int64 `json:"bytes_sent,omitempty"`
38-
BytesReceived int64 `json:"bytes_received,omitempty"`
39-
QpointRequestID string `json:"qpoint_request_id,omitempty"`
40-
ConnectionID string `json:"connection_id,omitempty"`
41-
EndpointID string `json:"endpoint_id,omitempty"`
31+
ProcessID string `json:"process_id,omitempty"`
32+
ProcessExe string `json:"process_exe,omitempty"`
33+
ContainerName string `json:"container_name,omitempty"`
34+
ContainerImage string `json:"container_image,omitempty"`
35+
PodName string `json:"pod_name,omitempty"`
36+
PodNamespace string `json:"pod_namespace,omitempty"`
37+
BytesSent int64 `json:"bytes_sent,omitempty"`
38+
BytesReceived int64 `json:"bytes_received,omitempty"`
39+
RequestID string `json:"request_id,omitempty"`
40+
ConnectionID string `json:"connection_id,omitempty"`
41+
EndpointID string `json:"endpoint_id,omitempty"`
4242
}
4343

4444
// Request contains HTTP request information
@@ -185,8 +185,8 @@ func (m Metadata) Summary() map[string]any {
185185
if m.PodNamespace != "" {
186186
summary["pod_namespace"] = m.PodNamespace
187187
}
188-
if m.QpointRequestID != "" {
189-
summary["qpoint_request_id"] = m.QpointRequestID
188+
if m.RequestID != "" {
189+
summary["request_id"] = m.RequestID
190190
}
191191
if m.ConnectionID != "" {
192192
summary["connection_id"] = m.ConnectionID
@@ -263,8 +263,8 @@ func (t *HttpTransaction) ToString() string {
263263
text += " Duration: " + strconv.FormatInt(t.DurationMs, 10) + "ms\n"
264264
}
265265
text += " Direction: " + t.Direction + "\n"
266-
if t.Metadata.QpointRequestID != "" {
267-
text += " Request ID: " + t.Metadata.QpointRequestID + "\n"
266+
if t.Metadata.RequestID != "" {
267+
text += " Request ID: " + t.Metadata.RequestID + "\n"
268268
}
269269
if t.Metadata.ProcessID != "" {
270270
text += " Process ID: " + t.Metadata.ProcessID + "\n"

pkg/plugins/httpcapture/httptransaction_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ func TestHttpTransactionToJSONFormat(t *testing.T) {
2323
DurationMs: 150,
2424
Direction: "egress-external",
2525
Metadata: Metadata{
26-
ProcessID: "1234",
27-
ProcessExe: "/usr/bin/curl",
28-
ConnectionID: "conn-123",
29-
EndpointID: "ep-123",
30-
QpointRequestID: "req-123",
31-
BytesSent: 100,
32-
BytesReceived: 200,
26+
ProcessID: "1234",
27+
ProcessExe: "/usr/bin/curl",
28+
ConnectionID: "conn-123",
29+
EndpointID: "ep-123",
30+
RequestID: "req-123",
31+
BytesSent: 100,
32+
BytesReceived: 200,
3333
},
3434
Request: Request{
3535
Method: "GET",
@@ -66,13 +66,13 @@ func TestHttpTransactionToJSONFormat(t *testing.T) {
6666
"duration_ms": float64(150),
6767
"direction": "egress-external",
6868
"metadata": map[string]any{
69-
"process_id": "1234",
70-
"process_exe": "/usr/bin/curl",
71-
"connection_id": "conn-123",
72-
"endpoint_id": "ep-123",
73-
"qpoint_request_id": "req-123",
74-
"bytes_sent": float64(100),
75-
"bytes_received": float64(200),
69+
"process_id": "1234",
70+
"process_exe": "/usr/bin/curl",
71+
"connection_id": "conn-123",
72+
"endpoint_id": "ep-123",
73+
"request_id": "req-123",
74+
"bytes_sent": float64(100),
75+
"bytes_received": float64(200),
7676
},
7777
"request": map[string]any{
7878
"method": "GET",

0 commit comments

Comments
 (0)