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
|
|
@ -545,6 +545,34 @@ pkgs.testers.runNixOSTest {
|
|||
wait_status("agentonly.t.local", ATLAS, "403")
|
||||
assert connect("forge.t.local", RUTH) == "200", "the hive's own name after the swarm list is gone"
|
||||
|
||||
with subtest("a log-mode agent reaches an unlisted name and is logged as would_deny, and nothing else changes"):
|
||||
# What hive-c0re renders for `ruth` in log mode, after the agent rules.
|
||||
write_allow(
|
||||
seeded,
|
||||
"# source: swarm\n"
|
||||
"acl log_mark annotate_transaction would_deny=1\n"
|
||||
"acl agent_log_ruth proxy_auth ruth\n"
|
||||
"http_access allow agent_log_ruth !allowed_dst log_mark\n",
|
||||
)
|
||||
wait_status("other.t.local", RUTH, "200")
|
||||
proxy.wait_until_succeeds(
|
||||
"journalctl -u squid.service -o cat | grep -E "
|
||||
"'would_deny user=ruth method=CONNECT host=other\\.t\\.local port=443 result='"
|
||||
)
|
||||
assert connect("forge.t.local", RUTH) == "200", "a listed name"
|
||||
assert connect("other.t.local", ATLAS) == "403", "control: a restricted agent is still refused"
|
||||
assert connect("other.t.local") == "407", "no credential"
|
||||
assert connect("other.t.local", "ruth:" + secrets.token_urlsafe(24)) == "407", "wrong password"
|
||||
assert connect("deny-canary.invalid", SELFCHECK) == "403", "the self-check's deny canary"
|
||||
for name in ["loop.t.local", "bridge.t.local", "meta.t.local", "127.0.0.1", "203.0.113.2", "priv10.t.local", "other.t.local:22", "other.t.local:80"]:
|
||||
assert connect(name, RUTH) == "403", f"log mode still refuses {name}"
|
||||
assert squid_saw(r"would_deny user=ruth method=CONNECT host=other\.t\.local port=443 "), "the unlisted name is marked"
|
||||
assert not squid_saw(r"would_deny user=ruth .* host=forge\.t\.local"), "a listed name is not marked"
|
||||
assert not squid_saw(r"would_deny user=atlas "), "a restricted agent is not marked"
|
||||
assert not squid_saw(r"would_deny .* host=loop\.t\.local"), "a refused request is not marked"
|
||||
write_allow(seeded, "")
|
||||
wait_status("other.t.local", RUTH, "403")
|
||||
|
||||
with subtest("squid starts on a missing list, treats every user as restricted, and recovers when it appears"):
|
||||
proxy.succeed(f"rm {LIST}")
|
||||
proxy.succeed("systemctl restart squid.service")
|
||||
|
|
|
|||
Loading…
Reference in a new issue