Skip to content

Commit 62bf4ec

Browse files
Merge pull request #220 from profullstack/codex/agentdb-caddy-access-log-20261031
dev2: log AgentDB access safely for ThreatCrush
2 parents a9f2555 + 577bdee commit 62bf4ec

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎dev2/dev2-edge‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,16 @@ def caddy_site(site, s):
155155
if site.get("gzip"):
156156
lines.append("\tencode gzip")
157157
if site.get("access_log"):
158-
lines += ["\tlog {", f"\t\toutput file /var/log/caddy/{site['hosts'][0]}.access.log", "\t}"]
158+
lines += ["\tlog {", f"\t\toutput file /var/log/caddy/{site['hosts'][0]}.access.log"]
159+
if site.get("sanitize_query"):
160+
lines += [
161+
"\t\tformat filter {",
162+
'\t\t\trequest>uri regexp `\\?.*` ""',
163+
"\t\t\trequest>headers delete",
164+
"\t\t\tresp_headers delete",
165+
"\t\t}",
166+
]
167+
lines.append("\t}")
159168
if "proxy" in site and site.get("retry"):
160169
# While the app restarts (a deploy), hold the request and keep dialing instead of
161170
# answering 502: webhooks that drive live calls (Telnyx) must not fail mid-call.

‎dev2/edge/edge.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
{ "hosts": ["pit.world"], "proxy": 8787, "max_body": "1MiB" },
1919
{ "hosts": ["www.pit.world"], "redirect": "https://pit.world{uri}" },
2020
{ "hosts": ["ad.network.pit.world"], "proxy": 8800, "max_body": "1MiB", "gzip": true },
21+
{ "hosts": ["agent.database.pit.world"], "proxy": 18080, "max_body": "512KiB", "gzip": true, "access_log": true, "sanitize_query": true },
2122
{ "hosts": ["group.call.pit.world"], "proxy": 8810, "max_body": "1MiB", "retry": "20s",
2223
"//": "group.call (moshcoder/group.call): no gzip, so the room page's server-sent events are not held back; retry holds Telnyx webhooks across a deploy instead of 502" },
2324
{ "hosts": ["*.*.pit.world", "*.*.*.pit.world"], "proxy": 8787, "max_body": "30MiB", "gzip": true,

‎test/dev2-edge.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,18 @@ describe('dev2-edge render', () => {
157157
const head = site.hosts.map((h: string) => `https://${h}`).join(', ') + ' {';
158158
expect(caddy).toContain(head);
159159
const block = caddy.slice(caddy.indexOf(head), caddy.indexOf('\n}\n', caddy.indexOf(head)));
160-
if (site.proxy) expect(block).toContain(`import edge_proxy ${site.proxy}`);
160+
if (site.proxy && site.retry) expect(block).toContain(`reverse_proxy 127.0.0.1:${site.proxy}`);
161+
else if (site.proxy) expect(block).toContain(`import edge_proxy ${site.proxy}`);
161162
if (site.root) expect(block).toContain(`root * ${site.root}`);
162163
if (site.redirect) expect(block).toContain(`redir ${site.redirect} 301`);
163164
if (site.max_body) expect(block).toContain(`max_size ${site.max_body}`);
164165
expect(block).toContain(site.moshpit ? 'import edge_tls_moshpit' : 'import edge_tls');
165166
}
167+
const agentDb = caddy.slice(caddy.indexOf('https://agent.database.pit.world {'));
168+
expect(agentDb).toContain('output file /var/log/caddy/agent.database.pit.world.access.log');
169+
expect(agentDb).toContain('request>uri regexp `\\?.*` ""');
170+
expect(agentDb).toContain('request>headers delete');
171+
expect(agentDb).toContain('resp_headers delete');
166172
expect(caddy).toMatch(/\(edge_tls_moshpit\) \{\s+tls \{\s+load \/etc\/caddy\/edge-certs\s+protocols tls1\.3/);
167173
});
168174

0 commit comments

Comments
 (0)