From 1780a9b5ffec597010b32414d87145d505e244dc Mon Sep 17 00:00:00 2001 From: Thomas Brinkmann Date: Wed, 1 Jun 2022 22:29:06 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=9EPOST=20/protection/flexrule=E2=80=9C?= =?UTF-8?q?=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- POST-%2Fprotection%2Fflexrule.md | 191 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 POST-%2Fprotection%2Fflexrule.md diff --git a/POST-%2Fprotection%2Fflexrule.md b/POST-%2Fprotection%2Fflexrule.md new file mode 100644 index 0000000..4a462be --- /dev/null +++ b/POST-%2Fprotection%2Fflexrule.md @@ -0,0 +1,191 @@ +## **POST /protection/flexrule** + + +## **Inhalt** +--- +- Parameter +- Optionale Parameter +- Beispiel Anfrage +- Beispiel Antwort +- Mögliche Fehlermeldungen +--- + +### Parameter + +|URL Parameter | Typ | Beschreibung| +|----------|-----|-------------| +|sequence| integer | Sequenznummer 1-10, steuert die Reihenfolge der Regelverarbeitung; muss fortlaufend sein und bei 1 beginnen - sonst werden alle Regeln ausgelassen +|srcIpStart| string | Übereinstimmung mit der Quell-IP-Adresse als Bereichsanfang und -ende, 0 für keine Übereinstimmung +|srcIpEnd| string | Übereinstimmung mit der Quell-IP-Adresse als Bereichsanfang und -ende, 0 für keine Übereinstimmung +|dstIp| string | Ziel-Präfix für die Übereinstimmung +|protocol| integer | IP-Protokollnummer, die übereinstimmen muss, z. B. 6 -> TCP, 17 -> UDP +|srcPortStart| integer | Übereinstimmung mit Quellport im Bereich Anfang-Ende, 0 für keine Übereinstimmung +|srcPortEnd| integer | Übereinstimmung mit Quellport im Bereich Anfang-Ende, 0 für keine Übereinstimmung +|dstPortStart| integer | Übereinstimmung mit dem Zielport im Bereich Anfang-Ende, 0 für keine Übereinstimmung +|dstPortEnd| integer | Übereinstimmung mit dem Zielport im Bereich Anfang-Ende, 0 für keine Übereinstimmung +|paketLengthMin| integer | Paketlänge im Bereich Start-Ende, 0 für keine Übereinstimmung +|paketLengthMax| integer | Paketlänge im Bereich Start-Ende, 0 für keine Übereinstimmung +|payload| string | Optionale Nutzdaten für die Übereinstimmung (max. 30 Bytes) - leer für keine Übereinstimmung +|flags| boolean | Abgleich von tcp-Flags aktivieren +|syn| boolean | - +|ack| boolean | - +|psh| boolean | - +|fin| boolean | - +|urg| boolean | - +|rst| boolean | - +|ratelimit| integer | Ratelimit in Paketen pro Sekunde +|action| integer | Anzuwendende Aktion, z. B. 0 zum Verwerfen + +|Body Parameter | Typ | Beschreibung| +|----------|-----|-------------| +| - | - | - | + + +--- + +### Optionale Parameter + +|Query-String Parameter | Typ | Beschreibung| +|----------|-----|-------------| +|- | - | - + +--- + +### Beispiel Anfrage + +##### PHP +```php + 'control.local/api/v2/protection/flexrule', + CURLOPT_CUSTOMREQUEST => 'POST', + CURLOPT_POSTFIELDS =>'{ + "sequence": 1, + "srcIpStart": "0", + "srcIpEnd": "0", + "dstIp": "192.168.1.2/32", + "protocol": 6, + "srcPortStart": 0, + "srcPortEnd": 0, + "dstPortStart": 0, + "dstPortEnd": 0, + "paketLengthMin": 0, + "paketLengthMax": 0, + "payload": "", + "flags": false, + "syn": false, + "ack": false, + "psh": false, + "fin": false, + "urg": false, + "rst": false, + "ratelimit": 0, + "action": 0 + }', + CURLOPT_HTTPHEADER => array( + 'X-TOKEN: test-token', + 'Content-Type: application/json' + ), +)); + +$response = curl_exec($curl); + +curl_close($curl); +echo $response; +``` + +##### cURL +```bash +curl --location --request POST 'control.local/api/v2/protection/flexrule' \ +--header 'X-TOKEN: test-token' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "sequence": 1, + "srcIpStart": "0", + "srcIpEnd": "0", + "dstIp": "192.168.1.2/32", + "protocol": 6, + "srcPortStart": 0, + "srcPortEnd": 0, + "dstPortStart": 0, + "dstPortEnd": 0, + "paketLengthMin": 0, + "paketLengthMax": 0, + "payload": "", + "flags": false, + "syn": false, + "ack": false, + "psh": false, + "fin": false, + "urg": false, + "rst": false, + "ratelimit": 0, + "action": 0 +}' +``` + +--- + +### Beispiel Antwort + +```json +{ + "status": "OK", + "flexrule": { + "uuid": "string", + "seq": 1, + "from": { + "ip": { + "src": { + "start": "0", + "end": "0" + }, + "dst": "192.168.1.2/32", + "protocol": 6 + }, + "port": { + "src": { + "start": 0, + "end": 0 + }, + "dst": { + "start": 0, + "end": 0 + } + }, + "length": { + "start": 0, + "end": 0 + }, + "payload": "", + "tcp": { + "flags": false, + "syn": false, + "ack": false, + "psh": false, + "fin": false, + "urg": false, + "rst": false + } + }, + "then": { + "ratelimit": 0, + "action": 0, + "gqc": { + "type": 0, + "ratelimit": 0, + "passthrough": false + } + } + } +} +``` + +### Mögliche Fehlermeldungen + +> :warning: Status Code **403** - Permission denied + +> :warning: Status Code **403** - You're not allowed to create flexrules outside your ip subnets