add a per-agent egress log mode
This commit is contained in:
parent
9140d063d7
commit
e46ad07226
1 changed files with 637 additions and 31 deletions
|
|
@ -1670,7 +1670,13 @@ let
|
|||
# The default render, pinned so moving the options changes none of it:
|
||||
# the listen address squid binds and hive-c0re hands out, and the users
|
||||
# file hive-c0re writes, on a hive holding a store identity.
|
||||
name = "squid's default listen address and users file reach squid.conf and hive-c0re unchanged";
|
||||
#
|
||||
# Also the order hive-c0re's `log`-mode rules rely on: the include of
|
||||
# `agent-allow.conf` follows every safety deny and `deny !authed`, and
|
||||
# precedes `deny !allowed_dst`, so a log rule in it cannot let through
|
||||
# what those refuse. The `would_deny` log line sits beside the unchanged
|
||||
# request line.
|
||||
name = "squid's default listen address and users file reach squid.conf and hive-c0re unchanged, and the include sits after the safety denies";
|
||||
ok =
|
||||
let
|
||||
withIdentity = hiveWithController {
|
||||
|
|
@ -1679,12 +1685,36 @@ let
|
|||
};
|
||||
e = withIdentity.systemd.services.hive-c0re.environment;
|
||||
conf = withIdentity.services.squid.configText;
|
||||
lines = map lib.strings.trim (lib.splitString "\n" conf);
|
||||
at = line: lib.lists.findFirstIndex (l: l == line) null lines;
|
||||
include = at "include /var/lib/hive-squid/agent-allow.conf";
|
||||
before = [
|
||||
"http_access deny !Safe_ports"
|
||||
"http_access deny CONNECT !SSL_ports"
|
||||
"http_access deny ip_v4_host"
|
||||
"http_access deny ip_v6_host"
|
||||
"http_access deny to_localhost"
|
||||
"http_access deny to_linklocal"
|
||||
"http_access deny to_bridge"
|
||||
"http_access deny to_private"
|
||||
"http_access deny !authed"
|
||||
];
|
||||
in
|
||||
e.HIVE_SQUID_PROXY == "${withIdentity.services.hyperhive.network.bridgeIp}:3128"
|
||||
&& e.HIVE_SQUID_USERS_FILE == "/var/lib/hive-squid/users"
|
||||
&& lib.hasInfix "http_port ${e.HIVE_SQUID_PROXY}" conf
|
||||
&& lib.hasInfix "basic_ncsa_auth /var/lib/hive-squid/users" conf
|
||||
&& lib.hasInfix "acl allowed_dst dstdomain cache.nixos.org" conf;
|
||||
&& lib.hasInfix "acl allowed_dst dstdomain cache.nixos.org" conf
|
||||
# Presence controls: the include and the policy deny are found at all.
|
||||
&& include != null
|
||||
&& at "http_access deny !allowed_dst" != null
|
||||
&& include < at "http_access deny !allowed_dst"
|
||||
&& lib.all (rule: at rule != null && at rule < include) before
|
||||
# The request line is unchanged; the would_deny line is a second one.
|
||||
&& at "access_log syslog:daemon.info squid !manager" != null
|
||||
&& at "acl would_denied note would_deny 1" != null
|
||||
&& at "access_log syslog:daemon.info logformat=would_deny would_denied" != null
|
||||
&& lib.hasInfix "logformat would_deny would_deny user=%[un " conf;
|
||||
}
|
||||
{
|
||||
# A hive's rendered identity, pinned so moving the option changes none of
|
||||
|
|
|
|||
Loading…
Reference in a new issue