You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,10 @@ $ CGO_ENABLED=0 go build csp_collector.go
41
41
|port |Port to run on, default 8080|
42
42
|filter-file|Reads the blocked URI filter list from the specified file. Note one filter per line|
43
43
|health-check-path|Sets path for health checkers to use, default \/_healthcheck|
44
+
|log-client-ip|Include a field in the log with the IP delivering the report, or the value of the `X-Forwarded-For` header, if present.|
45
+
|log-truncated-client-ip|Include a field in the log with the truncated IP (to /24 for IPv4, /64 for IPv6) delivering the report, or the value of the `X-Forwarded-For` header, if present. Conflicts with `log-client-ip`.
46
+
|truncated-query-fragment|Remove all query strings and fragments (if set) from all URLs transmitted by the client|
47
+
|query-params-metadata|Log all query parameters of the report URL as a map in the `metadata` field|
44
48
45
49
46
50
See the sample.filterlist.txt file as an example of the filter list in a file
@@ -54,6 +58,11 @@ logged report.
54
58
For example a report sent to `https://collector.example.com/?metadata=foobar`
55
59
will include field `metadata` with value `foobar`.
56
60
61
+
If `query-params-metadata` is set, instead all query parameters are logged as a
62
+
map, e.g. `https://collector.example.com/?env=production&mode=enforce` will
63
+
result in `"metadata": {"env": "production", "mode": "enforce"}` in JSON
64
+
format, and `metadata="map[env:production mode:enforce]"` in default format.
65
+
57
66
### Output formats
58
67
59
68
The output format can be controlled by passing `--output-format <type>`
version:=flag.Bool("version", false, "Display the version")
116
-
flag.BoolVar(&debugFlag, "debug", false, "Output additional logging for debugging")
117
-
flag.StringVar(&outputFormat, "output-format", "text", "Define how the violation reports are formatted for output.\nDefaults to 'text'. Valid options are 'text' or 'json'")
118
-
flag.StringVar(&blockedURIfile, "filter-file", "", "Blocked URI Filter file")
119
-
flag.IntVar(&listenPort, "port", 8080, "Port to listen on")
debugFlag:=flag.Bool("debug", false, "Output additional logging for debugging")
107
+
outputFormat:=flag.String("output-format", "text", "Define how the violation reports are formatted for output.\nDefaults to 'text'. Valid options are 'text' or 'json'")
108
+
blockedURIFile:=flag.String("filter-file", "", "Blocked URI Filter file")
109
+
listenPort:=flag.Int("port", 8080, "Port to listen on")
truncateQueryStringFragment:=flag.Bool("truncate-query-fragment", false, "Truncate query string and fragment from document-uri, referrer and blocked-uri before logging (to reduce chances of accidentally logging sensitive data)")
112
+
113
+
logClientIP:=flag.Bool("log-client-ip", false, "Log the reporting client IP address")
114
+
logTruncatedClientIP:=flag.Bool("log-truncated-client-ip", false, "Log the truncated client IP address (IPv4: /24, IPv6: /64")
115
+
116
+
metadataObject:=flag.Bool("query-params-metadata", false, "Write query parameters of the report URI as JSON object under metadata instead of the single metadata string")
0 commit comments