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: content/waf/logging/custom-dimensions.md
+22-31Lines changed: 22 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,25 @@ nd-content-type: reference
6
6
nd-product: NAP-WAF
7
7
---
8
8
9
-
Custom dimensions log entries feature refers to the new configuration in F5 WAF for NGINX, where the new directive called `app_protect_custom_log_attribute` is assigned to a particular location or server or http level in the `nginx.conf` file. The need is to be able to add custom identifiers to the respective location and/or server and identify requests in the Security Log by those identifiers.
9
+
F5 WAF for NGINX can configure custom dimensions for log entries using the directive `app_protect_custom_log_attribute`.
10
10
11
-
The `app_protect_custom_log_attribute`directive will be used to track the assigned location/server/http dimension of each request by adding the `app_protect_custom_log_attribute` to the **Security Logs** a.k.a **Request Logs**. Since it is a custom attribute a customer can set, that custom attribute will appear for every request log entry that was handled by that location/server.
11
+
This directive can be added to the NGINX configuration file in the `http`, `server` and `location` scopes. The custom dimensions become part of every request in the [Security logs]({{< ref "/waf/logging/security-logs.md" >}}) based on the scope used.
12
12
13
-
### Configuration
13
+
The `app_protect_custom_log_attribute` directive takes a key/value pair, such as `app_protect_custom_log_attribute 'customDimension' '1'`. The directive can cascade and override entries based on scope order: _location_, _server_ then. _http_.
14
14
15
-
A new directive `app_protect_custom_log_attribute` will be added to the `nginx.conf` file. You can set this directive at all scopes: http, server and location. The setting at the location scope overrides the setting in the server and/or http scopes and the server scope overrides the http scope. The `app_protect_custom_log_attribute` directive syntax will consist of a **name/value** or **key/value** pair i.e. "app_protect_custom_log_attribute <name> <value>".
15
+
For example, attributes at the _http_ level applies to all servers and locations unless a specific server or location overrides the same key with a different value.
16
16
17
-
Example Configuration:
17
+
When a custom dimension is assigned to a scope, it will appear in the `json_log` field as a new JSON property called "customLogAttributes" at the top level. This properly only appears if the `app_protect_custom_log_attribute` directive is used.
18
18
19
-
In the below example, we are configuring the `app_protect_custom_log_attribute` directive at the server and location level where we define the **key/value** pair as one string.
19
+
In the configuration example, the "environment" attribute will appear in logs of all locations under that server block.
@@ -66,35 +71,21 @@ The above key/value pair will be parsed as below:
66
71
]
67
72
```
68
73
69
-
### Things to Remember While Configuring the Custom Dimensions Log Entries
70
-
71
-
The `app_protect_custom_log_attribute` directive has a few limitations which should be kept in mind while configuring this directive:
74
+
The `app_protect_custom_log_attribute` directive has constraints you should keep in mind:
72
75
73
76
- Key and value strings are limited to 64 chars
74
-
-Maximum possible directive numbers are limited to 10 (in total) in each context i.e. Limit of 10 keys and values
77
+
-There are a maximum of 10 key/value pairs in each scope
75
78
76
-
### Errors and Warnings
79
+
An error message beginning with "_'app_protect_custom_log_attribute' directive is invalid_" will be displayed in the security log if:
77
80
78
-
An error message "`app_protect_custom_log_attribute` directive is invalid" will be displayed in the Security Log if the below conditions are met:
81
+
1. The `app_protect_custom_log_attribute` exceeds the maximum number of 10 directives
82
+
1. The `app_protect_custom_log_attribute` exceeds the maximum name length of 64 chars
83
+
1. The `app_protect_custom_log_attribute` exceeds the maximum value of 64 chars
79
84
80
-
1. If the `app_protect_custom_log_attribute` exceeds the maximum number of 10 directives
81
-
2. If the `app_protect_custom_log_attribute` exceeds the maximum name length of 64 chars
82
-
3. If the `app_protect_custom_log_attribute` exceeds the maximum value of 64 chars
85
+
The log will specify the precise issue:
83
86
84
-
Error message example:
85
-
86
-
```shell
87
+
```text
87
88
app_protect_custom_log_attribute directive is invalid. Number of app_protect_custom_log_attribute directives exceeds maximum
88
89
```
89
90
90
-
### Logging and Reporting
91
-
92
-
When `app_protect_custom_log_attribute` is assigned to a particular location/server/http context, it will appear in the `json_log` field as a new JSON property called "customLogAttributes" at the top level. The property will not appear if no `app_protect_custom_log_attribute` directive was assigned.
93
-
94
-
Attributes at the http level applies to all servers and locations unless a specific server or location overrides the same key with a different value. Same goes for the server level and all locations under it. In the below example, the "environment" attribute will appear in logs of all locations under that server.
Copy file name to clipboardExpand all lines: content/waf/policies/external-references.md
+45-65Lines changed: 45 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ For example, a `modifications` section could be replaced by `modificationsRefere
34
34
35
35
There are different implementations based on the type of references that are being made.
36
36
37
-
### External URL reference
37
+
### URL references
38
38
39
39
URL reference is the method of referencing an external source by providing its full URL.
40
40
@@ -43,6 +43,7 @@ This is a useful method when trying to combine or consolidate parts of the polic
43
43
{{< call-out "note" >}}
44
44
45
45
You need to make sure that the server where the resource files are located is always available when you are compiling your policy.
46
+
46
47
{{< /call-out >}}
47
48
48
49
This example creates a skeleton policy, enabling the file type violation.
@@ -105,18 +106,18 @@ The referenced `file-types.txt` file contains the following code:
105
106
]
106
107
```
107
108
108
-
### HTTPS references
109
+
####HTTPS references
109
110
110
111
HTTPS references are a special case of URL references. It uses the HTTPS protocol instead of the HTTP protocol. Make sure that the webserver you are downloading the resources from does also support HTTPS protocol and has certificates setup properly.
111
112
112
113
- Certificates must be valid in date (not expired) during the policy compilation.
113
114
- Certificates must be signed by a trusted CA.
114
-
- For Self-signed certificates, you need to make sure to add your certificates to the trusted CA of the machine where App Protect is installed.
115
+
- For Self-signed certificates, you need to make sure to add your certificates to the trusted CA of the machine where F5 WAF for NGINX is installed.
115
116
- Certificates must use the exact domain name that the certificate was issued for. For example, SSL will differentiate between domain.com and www.domain.com, considering each a different domain name.
116
117
117
-
In this configuration, we are completely satisfied with the basic default policy, and we wish to use it as is. However, we wish to define a custom response page using an external file located on an HTTPS web server. The external reference file contains our custom response page configuration.
118
+
The following configuration builds on the default policy by defining a custom response page using an external file located on an HTTPS web server.
118
119
119
-
**Policy configuration:**
120
+
The external reference file contains the custom response page configuration.
120
121
121
122
```json
122
123
{
@@ -145,9 +146,7 @@ Content of the referenced file `response-pages.txt`:
145
146
]
146
147
```
147
148
148
-
In this example, we would like to enable all attack signatures. Yet, we want to exclude specific signatures from being enforced.
149
-
150
-
**Policy configuration:**
149
+
The next example enables all attack signatures while excluding specific signatures from being enforced:
151
150
152
151
```json
153
152
{
@@ -193,22 +192,25 @@ Content of the referenced file `modifications.txt`:
193
192
194
193
### File references
195
194
196
-
File references refers to accessing local resources on the same machine, as opposed to accessing a remote resource on another server/machine. The user can specify any location that is accessible by App Protect except for the root folder ("/"). If no full path is provided, the default path `/etc/app_protect/conf` will be assumed. Note that file references can only be on the local machine: you cannot use remote hosts!
195
+
File references access local resources on the same machine, as opposed to accessing a remote resource on another server/machine.
|<file://etc/app_protect/conf/foo.json>|**Not accepted**| "etc" is interpreted as remote host name |
199
+
You can specify any location that is accessible by F5 WAF for NGINX except for the root folder ("/").
207
200
201
+
If a full path is not provided, the default path (_/etc/app_protect/conf_) will be used for resolution.
208
202
209
-
In this example, we would like to enable all attack signatures. Yet, we want to exclude specific signatures from being enforced. To do this, we reference a local file on the machine.
The error details that follow will depend on the exact situation causing the policy compilation to fail. If the policy compilation process fails, the compiler will revert to the last working policy and all the changes for the last policy compilation attempt will be lost.
263
+
The error will vary based on the conditions of the failure. If the policy compilation process fails, the compiler will revert to the last working policy and the changes for the last policy compilation attempt will be discarded.
264
+
265
+
## OpenAPI references
261
266
262
-
## OpenAPI specification file reference
267
+
F5 WAF for NGINX can reference an OpenAPI specification file used to describe restful APIs, using it for API protection.
263
268
264
-
The OpenAPI Specification defines the spec file format needed to describe RESTful APIs. The spec file can be written either in JSON or YAML. Using a spec file simplifies the work of implementing API protection. Refer to the OpenAPI Specification (formerly called Swagger) for details.
269
+
The specification file can be written in JSON or YAML format: the details can be used to create a protection policy.
270
+
271
+
Based on the content of the OpenAPI specification file, F5 WAF for NGINX will automatically create a policy for the following properties:
265
272
266
-
The simplest way to create an API protection policy is using an OpenAPI Specification file to import the details of the APIs. If you use an OpenAPI Specification file, F5 WAF forNGINX will automatically create a policy for the following properties (depending on what's includedin the spec file):
267
273
* Methods
268
274
* URLs
269
275
* Parameters
270
276
* JSON profiles
271
277
272
-
An OpenAPI-ready policy template is provided with the F5 WAF for NGINX packages and is located in: `/etc/app_protect/conf/NginxApiSecurityPolicy.json`
273
-
274
-
It contains violations related to OpenAPI set to blocking (enforced).
275
-
276
-
{{< call-out "note">}} F5 WAF for NGINX supports only one OpenAPI Specification file reference per policy.{{< /call-out >}}
278
+
A policy template is provided with F5 WAF forNGINX packages containing violations related to OpenAPI configured to block (enforced) and is locatedin on the path _/etc/app_protect/conf/NginxApiSecurityPolicy.json_.
277
279
278
-
### Types of OpenAPI References
279
-
280
-
There are different ways of referencing OpenAPI Specification files. The configuration is similar to [External References](#external-references).
280
+
F5 WAF for NGINX supports only one OpenAPI specification file reference per policy.
281
281
282
282
{{< call-out "note">}} Any update of an OpenAPI Specification file referenced in the policy will not trigger a policy compilation. This action needs to be done actively by reloading the NGINX configuration. {{< /call-out >}}
283
283
284
-
#### URL Reference
285
-
286
-
URL reference is the method of referencing an external source by providing its full URL.
287
-
288
-
Make sure to configure certificates prior to using the HTTPS protocol - see the [HTTPS References](#https-reference) under the External References section for more details.
289
-
290
-
{{< call-out "note">}} You need to make sure that the server where the resource files are located is always available when you are compiling your policy. {{< /call-out >}}
284
+
Configuring and referencing OpenAPI specification files are similar to other external references.
291
285
292
-
##### Example Configuration
286
+
### URL references
293
287
294
-
In this example, we are adding an OpenAPI Specification file reference using the link `http://127.0.0.1:8088/myapi.yaml`. This will configure allowed data types for`query_int` and `query_str` parameters values.
288
+
This example adds an OpenAPI specification file reference using the link `http://127.0.0.1:8088/myapi.yaml`.
295
289
296
-
**Policy configuration:**
290
+
The referenced file configures the allowed data types for`query_int` and `query_str` parameters values.
297
291
298
292
```json
299
293
{
@@ -443,23 +437,15 @@ paths:
443
437
description: NotFound
444
438
```
445
439
446
-
In this case the following request will trigger an `Illegal parameter data type` violation, as we expect to have an integer value in the `query_int` parameter:
440
+
The following request will trigger an `Illegal parameter data type` violation, F5 WAF forNGINX expect to have an integer valuein the `query_int` parameter:
447
441
448
-
```
442
+
```text
449
443
http://localhost/query?query_int=abc
450
444
```
451
445
452
-
The request will be blocked.
453
-
454
-
The link option is also available in the `openApiFileReference` property and synonymous with the one above in `open-api-files`
455
-
456
-
**Note**: `openApiFileReference` is not an array.
446
+
The link option is also available with the `openApiFileReference` property and synonymous with the one in`open-api-files`. `openApiFileReference` is not an array.
457
447
458
-
##### Example Configuration
459
-
460
-
In this example, we reference the same OpenAPI Specification file as in the policy above using the `openApiFileReference` property.
461
-
462
-
**Policy configuration:**
448
+
This next example references the same OpenAPI specification file as the previous one, using the `openApiFileReference` property.
463
449
464
450
```json
465
451
{
@@ -483,15 +469,9 @@ Content of the file `ref.txt`:
483
469
]
484
470
```
485
471
486
-
#### File Reference
487
-
488
-
File reference refers to accessing local resources on the same machine. See the [File References](#file-reference) under the External References section for more details.
489
-
490
-
##### Example Configuration
491
-
492
-
In this example, we would like to add an OpenAPI Specification file reference to the default policy.
472
+
### File references
493
473
494
-
**Policy Configuration:**
474
+
This example adds an OpenAPI specification file reference to the default policy.
495
475
496
476
```json
497
477
{
@@ -554,10 +534,10 @@ Content of the referenced file `myapi2.json`:
554
534
}
555
535
```
556
536
557
-
In this case the following request will trigger an `Illegal repeated parameter name` violation, as the OpenAPI Specification doesn't allow repeated parameters.
537
+
The following request will trigger an `Illegal repeated parameter name` violation, as the OpenAPI specification doesn't allow repeated parameters.
558
538
559
539
```
560
540
http://localhost/query?a=true&a=false
561
541
```
562
542
563
-
The request will not be blocked because this violation is set to alarm in the default policy.
543
+
The request will _not be blocked_ because this violation is set to alarm in the default policy.
0 commit comments