Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New API for network rules #59

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

slayercat
Copy link
Contributor

@slayercat slayercat commented Jan 16, 2020

  • GET network_address_aliases_get - Returns address aliaes used by rules.
  • POST network_address_aliases_create - Creates An network aliaes for rules
  • POST network_address_aliases_update - Update a address aliaes. Returns newest result
  • POST network_address_aliases_delete - Delete a address aliaes. Returns newest result
  • GET filter_rules_get - Returns firewall filters.
  • POST filter_rules_create - Creates firewall filters.
  • POST filter_rules_delete - Deletes firewall filters.

Closes #50

Signed-off-by: lilinzhe [email protected]

@slayercat slayercat changed the title WIP: New API for network rules: network_address_aliases_get / filter_rule… WIP: New API for network rules Jan 16, 2020
@slayercat slayercat changed the title WIP: New API for network rules New API for network rules Jan 19, 2020
@slayercat slayercat force-pushed the dev-rules-config branch 3 times, most recently from 901bde5 to 80332b2 Compare January 19, 2020 06:40
network_address_aliases_get
---
 - Returns address aliaes used by rules.
 - HTTP: **GET**
 - Params: none

*Example Request*
```bash
curl \
    -X GET \
    --silent \
    --insecure \
    --header "fauxapi-auth: <auth-value>" \
    "https://<host-address>/fauxapi/v1/?action=network_address_aliases_get"
```

*Example Response*
```javascript
{
    "callid": "5e205fc052956",
    "action": "network_address_aliases_get",
    "message": "ok",
    "data": {
        "aliases": {
            "alias": [
                {
                    "name": "EasyRuleBlockHostsWAN",
                    "type": "network",
                    "address": "1.2.3.4/32 5.6.7.8/32",
                    "descr": "Hosts blocked from Firewall Log view",
                    "detail": "Entry added Fri, 27 Dec 2019 00:53:01 -0800||\u5df2\u6dfb\u52a0\u6761\u76ee Thu, 16 Jan 2020 03:42:37 -0800"
                }
            ]
        }
    }
}
```

filter_rules_get
---
 - Returns address aliaes used by rules.
 - HTTP: **GET**
 - Params: none

*Example Request*
```bash
curl \
    -X GET \
    --silent \
    --insecure \
    --header "fauxapi-auth: <auth-value>" \
    "https://<host-address>/fauxapi/v1/?action=filter_rules_get"
```

*Example Response*
```javascript
{
    "callid": "5e2060797a602",
    "action": "filter_rules_get",
    "message": "ok",
    "data": {
        "filter": {
            "rules": [
                {
                    "id": "",
                    "tracker": "1579178400",
                    "type": "pass",
                    "interface": "wan",
                    "ipprotocol": "inet",
                    "tag": "",
                    "tagged": "",
                    "max": "",
                    "max-src-nodes": "",
                    "max-src-conn": "",
                    "max-src-states": "",
                    "statetimeout": "",
                    "statetype": "keep state",
                    "os": "",
                    "protocol": "tcp",
                    "source": {
                        "address": "1.2.1.1"
                    },
                    "destination": {
                        "any": "",
                        "port": "1-65535"
                    },
                    "descr": "",
                    "updated": {
                        "time": "1579178400",
                        "username": "[email protected] (Local Database)"
                    },
                    "created": {
                        "time": "1579178400",
                        "username": "[email protected] (Local Database)"
                    }
                },
                {
                    "type": "block",
                    "interface": "wan",
                    "ipprotocol": "inet",
                    "source": {
                        "address": "EasyRuleBlockHostsWAN"
                    },
                    "destination": {
                        "any": ""
                    },
                    "descr": "Easy Rule: Blocked from Firewall Log View",
                    "created": {
                        "time": "1577436781",
                        "username": "Easy Rule"
                    },
                    "tracker": "1577436781"
                },
                {
                    "type": "drop",
                    "ipprotocol": "inet",
                    "descr": "Default allow LAN to any rule",
                    "interface": "lan",
                    "source": {
                        "network": "lan"
                    },
                    "destination": {
                        "ip": "192.10.1.1"
                    }
                }
            ]
        }
    }
}
```

Signed-off-by: lilinzhe <[email protected]>
@Korvuss
Copy link

Korvuss commented Mar 26, 2020

would it be possible to merge this as its exactly what I am currently looking for !

@slayercat
Copy link
Contributor Author

Hi, @Korvuss

You may want to review issues #56 .

Thanks.

@ndejong
Copy link
Owner

ndejong commented May 31, 2020

Hi @slayercat pardon the long delay in my getting to this.

The code is well written, but you are re-declaring the namespace in an unexpected location

  • fauxapi_pfsense_interface.inc - line 771
  • fauxapi_pfsense_interface.inc - line 773

This is messy and almost looks as if it is an accidental piece of code that has crept in at development time

Also - can you propose some tests for this? I'll add them to the Python client interface examples that get used in the test harness

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

manage rule
3 participants