Commit graph

371 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
4949ab1e4e allow to filter connections by protocol
Added option to filter connections by protocol.

Just add an operand "protocol" as follow:
```
  "operator": {
    "type": "simple",
    "operand": "protocol",
    "sensitive": false,
    "data": "tcp",
    "list": []
  }
```

closes #64
2020-10-20 19:00:00 +02:00
Gustavo Iñiguez Goia
1e6d03e332 do not assign an IP to the DstHost field
In case we're connecting to an IP directly, or if an IP is not resolved,
leave the DstHost field empty and format it appropiately on the UIs.

Otherwise we can't know (easily) if the field DstHost of a connection is
an IP or a domain.
2020-10-19 01:29:00 +02:00
Gustavo Iñiguez Goia
d6cf18ef27 show domain name when establishing a new connection
When a new connection is about to be established and the system performs
a dns resolution, we displayed it like this: 9.9.9.9 (www.opensnitch.io)

It added visibility of what was going on, but if you created a rule to
filter by destination host, you were prompted twice to allow firstly the
DNS query, and secondly the TCP connection, which was a bit annoying.

Some users (#5) also asked to display just the domain, so now we only
display the domain name.
2020-10-19 01:02:05 +02:00
Gustavo Iñiguez Goia
bc70423997 make rules case-insensitive by default
Destination host, process path and process arguments are now case
insensitive by default.

There's a new rule operator field (sensitive), to change this behaviour:
```
      {
        "type": "simple",
        "operand": "dest.host",
        "sensitive": false,
        "data": "opensnitch.io",
        "list": null
      }
```

Rules without this field will evaluate as false by default.

closes #45
2020-10-19 00:25:04 +02:00
NP-Hardass
08abdd0950 go.mod: add netns as indirect dependency for netlink 2020-09-08 17:07:28 -04:00
Gustavo Iñiguez Goia
544ce11a21 Bump daemon version to 1.0.1 2020-07-30 22:04:56 +02:00
Gustavo Iñiguez Goia
df9e781051 Do not panic if we can't insert fw rules
Some systems has the IPV6 protocol disabled, so we failed starting up
with the error "Address family not supported by protocol" (#52).

Now we don't exist even if we can't insert the needed rules, we'll just
log the error.
2020-07-30 01:10:53 +02:00
Gustavo Iñiguez Goia
f4845240cc fixed typo and lint errors 2020-07-29 01:17:05 +02:00
Gustavo Iñiguez Goia
00b249a171 remove useless debug message when executing a command
As we return the error message if the execution fail, use it from where
the method is called.
2020-07-29 00:48:37 +02:00
Gustavo Iñiguez Goia
08245a075e intercept RELATED packets
We must intercept RELATED packets, not only for intercept protocols like
ftp-data, but also to handle connection errors (ICMP errors), like the
ones originated when dis/connecting from a wifi network.
2020-07-25 21:48:16 +02:00
Gustavo Iñiguez Goia
214e1b3c49 added priority rules to bypass/extend interception
In some scenarios (#47) may be useful to have a set of rules handled from
OpenSnitch, although you can accomplish it with other software (ufw,...).

This rules will sit just above default intercetion, so if you want to
allow or deny something, just place it here.

These priority rules are defined in /etc/opensnitchd/fw.json, with the
following format (example):

{
    "PriorityRules": {
        "out": {
            "allow": [
            ],
            "deny": [
                "-m conntrack --ctstate INVALID",
                "-p tcp ! --syn -m conntrack --ctstate NEW"
            ]
        }
    }
}

The structure must exist even if you haven't defined any rule, for
example:
{
    "PriorityRules": {
        "out": {
            "allow": [
            ],
            "deny": [
            ]
        }
    }
}
2020-07-25 21:23:53 +02:00
Gustavo Iñiguez Goia
c0fb84a0e3 changed go.mod to not depend on a fixed release 2020-07-17 02:03:03 +02:00
Gustavo Iñiguez Goia
b547067f61 close nfqueue descriptors gracefully
When the daemon is stopped, we need to close opened netfilter recurses.
Otherwise we can fall into a situation where we leave NFQUEUE queues
opened, which causes opensnitch to not run anymore until system restart
or a manual intervention, because there's a NFQUEUE queue already created
with the same ID.

This is what was happening as a collateral effect of #41.
2020-07-17 01:29:58 +02:00
Gustavo Iñiguez Goia
078df0ffb2 removed dep ensure when building rpm packages 2020-07-16 23:54:50 +02:00
Raphael
ffbb138bd6 equip go.mod file with packages 2020-07-16 23:06:32 +02:00
Raphael
563247a87c add go.mod and remove old Gopkg.lock 2020-07-16 23:05:25 +02:00
Raphael
1248a2326c remove go dep from Makefile 2020-07-16 23:04:11 +02:00
Gustavo Iñiguez Goia
9eb589a3ea v1.0.0 release
Current version is stable enough (based on users' feedback) to get it out
of the release candidate state. OpenSnitch works and is usable.

There's a lot of work yet to do, so let's start from a fresh and shiny
release number.
2020-07-16 00:48:32 +02:00
Gustavo Iñiguez Goia
a5994b0c4f stop receiving notifications properly
Under certain circunstances, the notifications goroutine entered into an
infinite loop.
2020-07-06 18:49:58 +02:00
Gustavo Iñiguez Goia
3853d412b4 audit: better rules deletion
if the daemon does not exit cleanly, the rules were not cleaned
correctly.
2020-07-03 08:28:33 +02:00
Gustavo Iñiguez Goia
714aa311a0 Bump version to v1.0.0rc11 2020-06-24 00:41:36 +02:00
Gustavo Iñiguez Goia
2522b8ef02 fixed CWD parsing when using audit proc monitor method 2020-06-22 14:26:07 +02:00
Gustavo Iñiguez Goia
6d24c5464c fixed race conditions when manipulating rules 2020-06-20 18:58:59 +02:00
Gustavo Iñiguez Goia
fc2212f073 return better errors if a regexp rule fails to compile
If a regexp rule fails to compile, return the reason instead of a
generic error. It'll help to debug problems.
2020-06-19 18:02:09 +02:00
Gustavo Iñiguez Goia
cfc32cbd1c fixed race condition when deleting a rule 2020-06-14 20:30:19 +02:00
Gustavo Iñiguez Goia
b03bbf0506 fixed race conditions setting log level and monitor methods 2020-06-14 20:14:24 +02:00
Gustavo Iñiguez Goia
edfbfbdcb4 Bump version to 1.0.0rc10 2020-06-14 12:34:20 +02:00
Gustavo Iñiguez Goia
506b9b6d87 fixed daemon running with old libnetfilter_queue libs
In old libnetfilter_queue libs, we can't know the UID of the packet
because the function nfq_get_uid is not present.

We check it dynamically on run time, but we were doing it wrong, so the
daemon didn't run with old libs.

Thaks to Pain-Patate for reporting it in #18.
2020-06-14 12:01:34 +02:00
Gustavo Iñiguez Goia
034a95918e removed useless firewall log 2020-06-12 01:21:36 +02:00
Gustavo Iñiguez Goia
a1bba4da3f send on new connection CWD and envrionment vars of the process
CWD allow us to know from where was a process executed.
The environment variables allows to know more about a process execution.
2020-06-04 01:14:25 +02:00
Gustavo Iñiguez Goia
78c0da83c0 increase default timeout to ask for a rule
Explained here: https://github.com/gustavo-iniguez-goya/opensnitch/issues/28#issuecomment-637484501
2020-06-04 00:38:11 +02:00
Gustavo Iñiguez Goia
36a11b4102 don't configure log level if the item does not exist in the config
Reported here:
https://github.com/gustavo-iniguez-goya/opensnitch/issues/31#issuecomment-633759613

The LogLevel conf item should always exist, but just in case.
2020-06-01 01:54:08 +02:00
Gustavo Iñiguez Goia
6c9d9b28f6 added default log level to default conf 2020-05-30 23:03:59 +02:00
Gustavo Iñiguez Goia
558e511718 delete rules by its name without deserializing 2020-05-30 01:44:22 +02:00
Gustavo Iñiguez Goia
6bbf3b33be misc: sources formatting 2020-05-30 01:36:43 +02:00
Gustavo Iñiguez Goia
cb4b62f36a Improved process path parsing (with spaces)
Processes paths with spaces were not handled correctly.
If the /proc/<pid>/exe link contained the word "(deleted)",
we deleted that part from the process path. But the way we
did it caused to not handle paths with spaces correctly.

Should fix #24
2020-05-23 12:16:35 +02:00
Gustavo Iñiguez Goia
1331bcb91f Reload config after changing it from the UI.
closes #20
2020-05-18 01:07:09 +02:00
Gustavo Iñiguez Goia
c36b09db55 Bump version to v1.0.0rc9 2020-05-17 19:55:07 +02:00
Gustavo Iñiguez Goia
061d7a2ecd ignore malformed rules
Don't exist if a rule is malformed.

Reported by @jonau01 here #17
2020-05-11 10:39:56 +02:00
Gustavo Iñiguez Goia
ca1cbe3084 added functions to retrieve system information 2020-05-10 17:52:08 +02:00
Gustavo Iñiguez Goia
85699622f6 Added logic to handle changes/notifications from the GUI.
- Allow to perform the following actions from the GUI:
  * Load/unload firewall (i.e.: interception)
  * Change daemon default configuration.
  * Enable/disable rules.
  * Delete rules.
  * Change/Add rules.
  * Change log level.
2020-05-10 17:44:56 +02:00
Gustavo Iñiguez Goia
c44fdf4342 added delete, getall, replace to the rules loader 2020-05-10 17:33:39 +02:00
Gustavo Iñiguez Goia
a39a2000fd return error if the daemon configuration can not be saved 2020-05-10 17:20:27 +02:00
Gustavo Iñiguez Goia
43898bc4c9 Allow to configure if a rule is enabled or not. 2020-05-10 17:17:05 +02:00
Gustavo Iñiguez Goia
d8b2f41e08 Apply default action if a rule is disabled. 2020-05-10 17:08:08 +02:00
Gustavo Iñiguez Goia
1d1d9f4456 Bump version to v1.0.0rc8 2020-04-29 22:02:30 +02:00
Gustavo Iñiguez Goia
83ffaaad44 decrease log level of denied connections
Denied connections were logged with Warning level.
However if you had a rule that denied a particular noisy connection, it
generated too much logs that didn't add value.

In the future it would be nice to log as warning, denied connections
that do not have a rule created by a user.

Discussion: https://github.com/gustavo-iniguez-goya/opensnitch/issues/10#issuecomment-615854975
2020-04-20 01:00:16 +02:00
Gustavo Iñiguez Goia
6ee80b1640 Allow to change settings from the UI
(1/2)
We start receiving notifications from the UI, which allow us to change
configurations and perform actions on the daemon.

The concept of Node has also been introduced, which identifies every
daemon (client) connected to the UI (server).

These options has been added:
- Enable/Disable firewall interception (for all nodes)
- Change daemons (clients) configuration. globally or per node.
- Change prompt dialog options.

We have fixed some bugs along the way:
- Close audit client connection gracefully.
- Exclude our own connections from being intercepted.
- Better handling of client connection status with the UI.

We probably has also introduced some other bugs (not listed here).
2020-04-19 20:13:31 +02:00
Gustavo Iñiguez Goia
09121ba74b Bump rpm package version to v1.0.0rc7 2020-04-13 01:16:01 +02:00
Gustavo Iñiguez Goia
32e527e503 Bump version to v1.0.0rc7 2020-04-13 00:23:38 +02:00