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

Improve opensnitch rules more #18

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions modules/jetbrains.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let idePath = "${lib.getBin pkgs.jetbrains.rust-rover}/rust-rover/bin/.rustrover
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^([a-z0-9|-]+\.)*jetbrains\.com$";
data = "^([a-z0-9|-]+\\.)*jetbrains\\.com$";
}
];
};
Expand All @@ -50,7 +50,7 @@ let idePath = "${lib.getBin pkgs.jetbrains.rust-rover}/rust-rover/bin/.rustrover
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^(github\.com|raw\.githubusercontent\.com)$";
data = "^(github\\.com|raw\\.githubusercontent\\.com)$";
}
];
};
Expand Down Expand Up @@ -99,7 +99,31 @@ let idePath = "${lib.getBin pkgs.jetbrains.rust-rover}/rust-rover/bin/.rustrover
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^([a-z0-9|-]+\.)*schemastore\.org$";
data = "^([a-z0-9|-]+\\.)*schemastore\\.org$";
}
];
};
};
rule-500-jetbrains-to-pypi = {
name = "Allow Jetbrains tools to reach out to pypi";
enable = true;
action = "allow";
duration = "always";
operator = {
type = "list";
operand = "list";
list = [
{
type = "simple";
sensitive = false;
operand = "process.path";
data = idePath;
}
{
type = "simple";
operand = "dest.host";
sensitive = false;
data = "pypi.python.org";
}
];
};
Expand Down
2 changes: 1 addition & 1 deletion modules/opensnitch.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^(([a-z0-9|-]+\.)*github\.com|([a-z0-9|-]+\.)*nixos\.org)$";
data = "^(([a-z0-9|-]+\\.)*github\\.com|([a-z0-9|-]+\\.)*nixos\\.org)$";
}
];
};
Expand Down
2 changes: 1 addition & 1 deletion modules/rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^(([a-z0-9|-]+\.)*crates\.io)|(([a-z0-9|-]+\.)*github\.com)$";
data = "^(([a-z0-9|-]+\\.)*crates\\.io)|(([a-z0-9|-]+\\.)*github\\.com)$";
}
];
};
Expand Down
2 changes: 1 addition & 1 deletion modules/signal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^([a-z0-9|-]+\.)*signal\.org$";
data = "^([a-z0-9|-]+\\.)*signal\\.org$";
}
];
};
Expand Down
107 changes: 102 additions & 5 deletions modules/steam.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ pkgs, lib, ... }:
let steamRegex = "^/home/stusmall/.local/share/Steam/ubuntu12_32/steam|/home/stusmall/.local/share/Steam/ubuntu12_64/steamwebhelper$"; in

{
environment.systemPackages = with pkgs; [
steam
Expand All @@ -12,8 +14,56 @@
};

services.opensnitch.rules = {
rule-500-steam = {
name = "Allow Steam";
rule-600-steam-lan = {
name = "Allow Steam to reach out on LAN";
enabled = true;
action = "allow";
duration = "always";
operator = {
type = "list";
operand = "list";
list = [
{
type = "simple";
sensitive = false;
operand = "process.path";
data = "/home/stusmall/.local/share/Steam/ubuntu12_32/steam";
}
{
type = "simple";
operand = "dest.host";
sensitive = false;
data = "192.168.1.255";
}
];
};
};
rule-600-steam-static-content = {
name = "Allow Steam to fetch static content";
enabled = true;
action = "allow";
duration = "always";
operator = {
type = "list";
operand = "list";
list = [
{
type = "regexp";
sensitive = false;
operand = "process.path";
data = steamRegex;
}
{
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^([a-z0-9|-]+\\.)*steamstatic\\.com$";
}
];
};
};
rule-600-steam-api = {
name = "Allow Steam to reach steam domains";
enabled = true;
action = "allow";
duration = "always";
Expand All @@ -25,17 +75,64 @@
type = "regexp";
sensitive = false;
operand = "process.path";
data = "^/home/stusmall/.local/share/Steam/ubuntu12_32/steam|/home/stusmall/.local/share/Steam/ubuntu12_64/steamwebhelper$";
data = steamRegex;
}
{
type = "regexp";
operand = "dest.host";
sensitive = false;
data = "^(api.steampowered.com|([a-z0-9|-]+\.)*steamcontent.com|([a-z0-9|-]+\.)*steamstatic.com|([a-z0-9|-]+\.)*steamserver.net|steamcommunity.com|steamstore-a.akamaihd.net|steamuserimages-a.akamaihd.net|steamcommunity-a.akamaihd.net|([a-z0-9|-]+\.)*.steampowered.com|([a-z0-9|-]+\.)*.youtube.com)$";
data = "^([a-z0-9|-]+\\.)*(steampowered\\.com|steamcommunity\\.com|steamserver\\.net)$";
}
];
};
};
rule-600-steam-webhelper-google = {
name = "Allow Steam web helper to reach google APIs";
enabled = true;
action = "allow";
duration = "always";
operator = {
type = "list";
operand = "list";
list = [
{
type = "simple";
sensitive = false;
operand = "process.path";
data = "/home/stusmall/.local/share/Steam/ubuntu12_64/steamwebhelper";
}
{
type = "simple";
operand = "dest.host";
sensitive = false;
data = "update.googleapis.com";
}
];
};
};
rule-600-steam-webhelper-youtube = {
name = "Allow Steam web helper to reach youtube";
enabled = true;
action = "allow";
duration = "always";
operator = {
type = "list";
operand = "list";
list = [
{
type = "simple";
sensitive = false;
operand = "process.path";
data = "/home/stusmall/.local/share/Steam/ubuntu12_64/steamwebhelper";
}
{
type = "simple";
operand = "dest.host";
sensitive = false;
data = "www.youtube.com";
}
];
};
};
};

}