From eeb44e5b915d2d8284cd8b736ca88339801e90f9 Mon Sep 17 00:00:00 2001 From: sada-sigsci Date: Mon, 26 Jun 2023 18:22:40 -0700 Subject: [PATCH 1/3] Added config option to send request body of any content type to agent --- config.go | 10 ++++++++++ module.go | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/config.go b/config.go index 2cf82d4..b0edde1 100644 --- a/config.go +++ b/config.go @@ -47,6 +47,7 @@ type ModuleConfig struct { anomalyDuration time.Duration anomalySize int64 expectedContentTypes []string + extendContentTypes bool debug bool rawHeaderExtractor RawHeaderExtractorFunc inspector Inspector @@ -278,6 +279,15 @@ func ExpectedContentType(s string) ModuleConfigOption { } } +// ExtendContentTypes is a function argument to indicate that send request body +// of any content-type to the agent for inspection +func ExtendContentTypes(v bool) ModuleConfigOption { + return func(c *ModuleConfig) error { + c.extendContentTypes = v + return nil + } +} + // CustomInspector is a function argument that sets a custom inspector, // an optional inspector initializer to decide if inspection should occur, and // an optional inspector finalizer that can perform any post-inspection steps diff --git a/module.go b/module.go index e8b4457..88a04b4 100644 --- a/module.go +++ b/module.go @@ -385,6 +385,10 @@ func shouldReadBody(req *http.Request, m *Module) bool { return true } + if m.config.extendContentTypes { + return true + } + // read the body if there are multiple Content-Type headers if len(req.Header.Values("Content-Type")) > 1 { return true From 118b577b02beff8c52bf7f8ad7309d7489ac8d1c Mon Sep 17 00:00:00 2001 From: sada-sigsci Date: Mon, 26 Jun 2023 18:30:40 -0700 Subject: [PATCH 2/3] updated version --- CHANGELOG.md | 4 ++++ VERSION | 2 +- version.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f7158e..1c88862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Golang Module Release Notes +## 1.12.2 2023-06-26 + +* Added `ExtendContentTypes` config option to send request body of any content-type to agent for inspection + ## 1.12.1 2023-02-24 * Sync versions diff --git a/VERSION b/VERSION index f8f4f03..6b89d58 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.12.1 +1.12.2 diff --git a/version.go b/version.go index caf6963..f82a940 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package sigsci -const version = "1.12.1" +const version = "1.12.2" From 4bb1360f26572cd95538c41ea73a226bb6b9fa3f Mon Sep 17 00:00:00 2001 From: Alex MacNair Date: Wed, 5 Jul 2023 18:01:52 -0400 Subject: [PATCH 3/3] Prep for release --- CHANGELOG.md | 4 ++-- LICENSE.md | 2 +- VERSION | 2 +- module.go | 8 ++++---- version.go | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c88862..de58475 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Golang Module Release Notes -## 1.12.2 2023-06-26 +## 1.13.0 2023-07-06 -* Added `ExtendContentTypes` config option to send request body of any content-type to agent for inspection +* Added new module configuration option for more granular inspection ## 1.12.1 2023-02-24 diff --git a/LICENSE.md b/LICENSE.md index b7df6dc..a01ce7d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -2,7 +2,7 @@ The MIT License (MIT) -Copyright (c) 2019-2022 Signal Sciences Corp. +Copyright (c) 2019-2023 Signal Sciences Corp. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/VERSION b/VERSION index 6b89d58..feaae22 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.12.2 +1.13.0 diff --git a/module.go b/module.go index 88a04b4..ac214c6 100644 --- a/module.go +++ b/module.go @@ -375,6 +375,10 @@ func shouldReadBody(req *http.Request, m *Module) bool { } } + if m.config.extendContentTypes { + return true + } + // only read certain types of content if inspectableContentType(req.Header.Get("Content-Type")) { return true @@ -385,10 +389,6 @@ func shouldReadBody(req *http.Request, m *Module) bool { return true } - if m.config.extendContentTypes { - return true - } - // read the body if there are multiple Content-Type headers if len(req.Header.Values("Content-Type")) > 1 { return true diff --git a/version.go b/version.go index f82a940..bc6f60f 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package sigsci -const version = "1.12.2" +const version = "1.13.0"