Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
f7e46f9
chore(deps): update codecov/codecov-action digest to 0565863 in .gith…
renovate[bot] Feb 27, 2025
68ab4db
chore(deps): update actions/cache digest to d4323d4 in .github/workfl…
renovate[bot] Feb 28, 2025
d7a7194
fix(deps): update all non-major dependencies in go.mod (#1317)
renovate[bot] Mar 5, 2025
b9e125f
chore(deps): update module golang.org/x/crypto to v0.35.0 [security] …
renovate[bot] Mar 5, 2025
78946f6
fix(deps): update module golang.org/x/net to v0.36.0 in go.mod (#1318)
renovate[bot] Mar 5, 2025
fa6558b
fix(deps): update go modules in go.mod (#1320)
renovate[bot] Mar 6, 2025
902edfa
chore(deps): update github/codeql-action digest to 6bb031a in .github…
renovate[bot] Mar 8, 2025
117380e
fix(deps): update module github.com/mccutchen/go-httpbin/v2 to v2.17.…
renovate[bot] Mar 9, 2025
e29a849
chore(deps): update module golang.org/x/net to v0.36.0 [security] (#1…
renovate[bot] Mar 13, 2025
8b612f4
chore: points to Go `v1.23.0` and some clean ups (#1328)
M4tteoP Mar 17, 2025
4722c9a
Merge commit from fork
blotus Mar 20, 2025
1500ccb
fix(go1.24): bump linter (#1330)
M4tteoP Mar 20, 2025
fdba86a
fix(deps): update all non-major dependencies in .github/workflows/tin…
renovate[bot] Mar 20, 2025
cb80190
fix(deps): update module github.com/mccutchen/go-httpbin/v2 to v2.18.…
renovate[bot] Mar 21, 2025
57eb446
audit: `H` should populate also with error logs. (#1310)
M4tteoP Mar 21, 2025
e9f4e80
fix(deps): update module github.com/rs/zerolog to v1.34.0 in testing/…
renovate[bot] Mar 23, 2025
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
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Initialize CodeQL
uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3
uses: github/codeql-action/init@5f8171a638ada777af81d42b55959a643bb29017 # v3
with:
languages: go

- name: Autobuild
uses: github/codeql-action/autobuild@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3
uses: github/codeql-action/autobuild@5f8171a638ada777af81d42b55959a643bb29017 # v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3
uses: github/codeql-action/analyze@5f8171a638ada777af81d42b55959a643bb29017 # v3
2 changes: 1 addition & 1 deletion .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
with:
go-version: ">=1.23.0"
- run: go run mage.go fuzz
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
with:
go-version: v1.23.x
go-version: 1.24.x
cache: true
- run: go run mage.go lint
10 changes: 5 additions & 5 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
with:
go-version: ${{ matrix.go-version }}
cache: true
Expand All @@ -51,28 +51,28 @@ jobs:
export BUILD_TAGS=${{ matrix.build-flag }}
go run mage.go coverage
- name: "Codecov: General"
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5
if: ${{ matrix.go-version == env.GOLANG_BASE_VERSION }}
with:
files: build/coverage.txt
flags: default,${{ matrix.build-flag }}
token: ${{ secrets.CODECOV_TOKEN }}
- name: "Codecov: Examples"
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5
if: ${{ matrix.go-version == env.GOLANG_BASE_VERSION }}
with:
files: build/coverage-examples.txt
flags: examples+${{ matrix.build-flag }}
token: ${{ secrets.CODECOV_TOKEN }}
- name: "Codecov: FTW"
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5
if: ${{ matrix.go-version == env.GOLANG_BASE_VERSION }}
with:
files: build/coverage-ftw.txt
flags: ftw,${{ matrix.build-flag }}
token: ${{ secrets.CODECOV_TOKEN }}
- name: "Codecov: Tinygo"
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5
# only if coverage-tinygo.txt exists
if: ${{ matrix.go-version == env.GOLANG_BASE_VERSION && hashFiles('build/coverage-tinygo.txt') != '' }}
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tinygo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Install Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5
with:
go-version: ${{ matrix.go-version }}
cache: true
Expand All @@ -38,7 +38,7 @@ jobs:
tinygo-version: ${{ matrix.tinygo-version }}

- name: Cache TinyGo build
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: |
~/.cache/tinygo
Expand Down
6 changes: 3 additions & 3 deletions examples/http-server/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/corazawaf/coraza/v3/examples/http-server

go 1.22.0
go 1.23.0

require github.com/corazawaf/coraza/v3 v3.2.1

Expand All @@ -11,8 +11,8 @@ require (
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/net v0.37.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/tools v0.22.0 // indirect
rsc.io/binaryregexp v0.2.0 // indirect
)
12 changes: 6 additions & 6 deletions examples/http-server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
Expand Down
1 change: 1 addition & 0 deletions experimental/plugins/plugintypes/auditlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type AuditLogMessage interface {
Actionset() string
Message() string
Data() AuditLogMessageData
// TODO(4.x): Add Log() ErrorMessage() string
}

// AuditLogMessageData contains information about the triggered rules
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/corazawaf/coraza/v3

go 1.23.6
go 1.23.0

// Testing dependencies:
// - go-mockdns
Expand All @@ -23,12 +23,12 @@ require (
github.com/foxcpp/go-mockdns v1.1.0
github.com/jcchavezs/mergefs v0.1.0
github.com/magefile/mage v1.15.1-0.20241126214340-bdc92f694516
github.com/mccutchen/go-httpbin/v2 v2.16.0
github.com/mccutchen/go-httpbin/v2 v2.18.0
github.com/petar-dambovaliev/aho-corasick v0.0.0-20240411101913-e07a1f0e8eb4
github.com/tidwall/gjson v1.18.0
github.com/valllabh/ocsf-schema-golang v1.0.3
golang.org/x/net v0.35.0
golang.org/x/sync v0.11.0
golang.org/x/net v0.37.0
golang.org/x/sync v0.12.0
rsc.io/binaryregexp v0.2.0
)

Expand All @@ -40,9 +40,9 @@ require (
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
google.golang.org/protobuf v1.35.1 // indirect
)

retract v3.2.2
22 changes: 12 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ github.com/jcchavezs/mergefs v0.1.0 h1:7oteO7Ocl/fnfFMkoVLJxTveCjrsd//UB0j89xmnp
github.com/jcchavezs/mergefs v0.1.0/go.mod h1:eRLTrsA+vFwQZ48hj8p8gki/5v9C2bFtHH5Mnn4bcGk=
github.com/magefile/mage v1.15.1-0.20241126214340-bdc92f694516 h1:aAO0L0ulox6m/CLRYvJff+jWXYYCKGpEm3os7dM/Z+M=
github.com/magefile/mage v1.15.1-0.20241126214340-bdc92f694516/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/mccutchen/go-httpbin/v2 v2.16.0 h1:dzoFvE4fWPIzWZ7ZRznLDYK9FpqXyx5NE3uzCngeTHM=
github.com/mccutchen/go-httpbin/v2 v2.16.0/go.mod h1:GBy5I7XwZ4ZLhT3hcq39I4ikwN9x4QUt6EAxNiR8Jus=
github.com/mccutchen/go-httpbin/v2 v2.17.1 h1:35FQXl1KT4CcJV6O5RtUc91tdMIBMzaJWW5+ZLA8CxY=
github.com/mccutchen/go-httpbin/v2 v2.17.1/go.mod h1:GBy5I7XwZ4ZLhT3hcq39I4ikwN9x4QUt6EAxNiR8Jus=
github.com/mccutchen/go-httpbin/v2 v2.18.0 h1:WFU1OELp3nHYLvXct/3nrGVIgxU0X+RJfDPYRBnvicY=
github.com/mccutchen/go-httpbin/v2 v2.18.0/go.mod h1:GBy5I7XwZ4ZLhT3hcq39I4ikwN9x4QUt6EAxNiR8Jus=
github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
github.com/petar-dambovaliev/aho-corasick v0.0.0-20240411101913-e07a1f0e8eb4 h1:1Kw2vDBXmjop+LclnzCb/fFy+sgb3gYARwfmoUcQe6o=
Expand Down Expand Up @@ -53,16 +55,16 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -73,8 +75,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
Expand All @@ -98,8 +100,8 @@ golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.23.6
go 1.23.0

use (
.
Expand Down
11 changes: 8 additions & 3 deletions internal/auditlog/auditlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,10 @@ func (trf TransactionRequestFiles) Mime() string {
// Message contains information about the triggered
// rules
type Message struct {
Actionset_ string `json:"actionset"`
Message_ string `json:"message"`
Data_ *MessageData `json:"data"`
Actionset_ string `json:"actionset"`
Message_ string `json:"message"`
ErrorMessage_ string `json:"error_message"`
Data_ *MessageData `json:"data"`
}

var _ plugintypes.AuditLogMessage = Message{}
Expand All @@ -378,6 +379,10 @@ func (m Message) Message() string {
return m.Message_
}

func (m Message) ErrorMessage() string {
return m.ErrorMessage_
}

func (m Message) Data() plugintypes.AuditLogMessageData {
return m.Data_
}
Expand Down
16 changes: 14 additions & 2 deletions internal/auditlog/formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (

type nativeFormatter struct{}

type auditLogWithErrMesg interface{ ErrorMessage() string }

func (nativeFormatter) Format(al plugintypes.AuditLog) ([]byte, error) {
if len(al.Parts()) == 0 {
return nil, nil
Expand Down Expand Up @@ -100,11 +102,21 @@ func (nativeFormatter) Format(al plugintypes.AuditLog) ([]byte, error) {
// Producer: ModSecurity for Apache/2.9.1 (http://www.modsecurity.org/).
// Server: Apache
// Engine-Mode: "ENABLED"

// AuditLogTrailer is also expected to contain the error message generated by the rule, if any
for _, alEntry := range al.Messages() {
alWithErrMsg, ok := alEntry.(auditLogWithErrMesg)
if ok && alWithErrMsg.ErrorMessage() != "" {
res.WriteByte('\n')
res.WriteString(alWithErrMsg.ErrorMessage())
}
}

_, _ = fmt.Fprintf(&res, "\nStopwatch: %s\nResponse-Body-Transformed: %s\nProducer: %s\nServer: %s", "", "", "", "")
case types.AuditLogPartRulesMatched:
for _, r := range al.Messages() {
for _, alEntry := range al.Messages() {
res.WriteByte('\n')
res.WriteString(r.Data().Raw())
res.WriteString(alEntry.Data().Raw())
}
}
res.WriteByte('\n')
Expand Down
16 changes: 9 additions & 7 deletions internal/auditlog/formats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ func TestNativeFormatter(t *testing.T) {
checkLine(t, lines, 10, mutateSeparator(separator, 'F'))
checkLine(t, lines, 12, "some: response header")
checkLine(t, lines, 13, mutateSeparator(separator, 'H'))
checkLine(t, lines, 15, "Stopwatch: ")
checkLine(t, lines, 16, "Response-Body-Transformed: ")
checkLine(t, lines, 17, "Producer: ")
checkLine(t, lines, 18, "Server: ")
checkLine(t, lines, 19, mutateSeparator(separator, 'K'))
checkLine(t, lines, 21, `SecAction "id:100"`)
checkLine(t, lines, 15, "error message")
checkLine(t, lines, 16, "Stopwatch: ")
checkLine(t, lines, 17, "Response-Body-Transformed: ")
checkLine(t, lines, 18, "Producer: ")
checkLine(t, lines, 19, "Server: ")
checkLine(t, lines, 20, mutateSeparator(separator, 'K'))
checkLine(t, lines, 22, `SecAction "id:100"`)
})
}

Expand Down Expand Up @@ -128,7 +129,8 @@ func createAuditLog() *Log {
},
Messages_: []plugintypes.AuditLogMessage{
&Message{
Message_: "some message",
Message_: "some message",
ErrorMessage_: "error message",
Data_: &MessageData{
Msg_: "some message",
Raw_: "SecAction \"id:100\"",
Expand Down
Loading