Skip to content

v2.0.0: rebuild policy model, safe search, default policy, proxy enforcement - #183

Merged
fifthsegment merged 4 commits into
masterfrom
v2-policy-rebuild
Sep 24, 2026
Merged

fifthsegment merged 4 commits into
masterfrom
v2-policy-rebuild

Conversation

@fifthsegment

Copy link
Copy Markdown
Owner

What this does

Rebuilds the policy feature from scratch so it actually works as a per-device internet safety gateway.

The old model was broken

  • A group held one action over one shared set of domains, so "block TikTok but allow YouTube" was impossible for a single device
  • A rule narrowed to a URL (e.g. youtube.com/shorts) blocked the whole domain on DNS
  • Pauses only checked the group-level action, so rule blocks kept blocking while "paused"
  • An authenticated proxy user lost the device's assignment entirely
  • Unassigned, unknown, and NATed clients had no policy at all
  • URL rules were only tested after the response had been fetched
  • The transparent HTTP path dropped connections instead of showing a block page

The new model (policy document v2)

  • One policy per request: proxy user → device assignment → undeletable Default policy
  • Blocked and allowed lists: blocked_categories, blocked_domains, allowed_domains (allowed wins over everything)
  • Targeted rules: each rule names its own target (all traffic / domains / categories), schedule, user scope, URL patterns, and response-type conditions
  • Safe search: DNS-enforced for Google, Bing, DuckDuckGo, and YouTube restricted mode; fails closed
  • Short block TTL (60s) so schedules and pauses apply promptly
  • Typed proxy contract replaces reflection; URL patterns tested before upstream; CONNECT tunnels not matched
  • v1 → v2 upgrade on read, preserving enforcement; next write persists v2

Tests

  • All Go tests pass across application, gatesentryproxy, and root modules (except TestAuthAndFilters which fails on the baseline too)
  • All UI tests pass (vitest 29/29, svelte-check baseline matched)

Breaking changes

  • Policy document v2 (auto-upgraded from v1)
  • API fields action, domains, categories on a group → blocked_domains, blocked_categories, allowed_domains
  • Per-rule mitm_action removed (URL/response conditions turn inspection on automatically)
  • Proxy RuleMatchHandler returns *PolicyDecision instead of interface{}

🤖 Generated with [CC]

fifthsegment and others added 2 commits September 24, 2026 01:48
…rcement

Breaking: the policy document format changes from version 1 to version 2.
Existing policies upgrade automatically on first read and keep enforcing
what they enforced before; the next policy write persists the new format.

Policy model:
- One policy per request: proxy user > device assignment > Default policy
- Blocked/allowed domain lists, blocked categories, safe search, and
  ordered first-match rules with their own targets and schedules
- DNS safe search for Google, Bing, DuckDuckGo, YouTube restricted mode
- Short block TTL (60s) so schedules and pauses apply promptly
- Typed proxy contract replaces reflection; URL patterns tested before
  upstream; CONNECT tunnels not matched by URL patterns
- v1 documents upgrade on read preserving enforcement

UI: policies page rebuilt with per-policy device assignment, test-a-site
evaluator, and useful starter policies. Device detail shows effective
policy.

Co-Authored-By: Claude <noreply@anthropic.com>
…k baseline

The smoke scripts posted v1 group fields (domains/action), which v2 ignores,
so nothing was blocked. Blocks now serve a page naming the rule, so check
for the block page instead of an empty body.

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Sep 24, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 79.57560% with 154 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.05%. Comparing base (f1d4868) to head (4f16035).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
application/policy/service.go 76.35% 38 Missing and 10 partials ⚠️
application/policy/upgrade.go 70.23% 17 Missing and 8 partials ⚠️
application/policy/rules.go 90.37% 9 Missing and 9 partials ⚠️
application/policy/safesearch.go 0.00% 17 Missing ⚠️
application/dns/server/server.go 69.04% 7 Missing and 6 partials ⚠️
gatesentryproxy/proxy.go 74.41% 9 Missing and 2 partials ⚠️
gatesentryproxy/transparent_listener.go 0.00% 10 Missing ⚠️
application/webserver/endpoints/handler_policy.go 75.00% 4 Missing ⚠️
gatesentryproxy/types.go 81.81% 2 Missing and 2 partials ⚠️
...ation/webserver/endpoints/handler_device_policy.go 90.00% 2 Missing ⚠️
... and 2 more
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #183      +/-   ##
==========================================
+ Coverage   46.73%   48.05%   +1.31%     
==========================================
  Files         120      123       +3     
  Lines       10689    10956     +267     
==========================================
+ Hits         4996     5265     +269     
+ Misses       5019     5009      -10     
- Partials      674      682       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

fifthsegment and others added 2 commits September 24, 2026 02:11
A push to master whose main.go version has no v<version> tag yet now builds,
smoke-tests, tags that commit, and publishes a GitHub release with the
matching CHANGELOG section as notes. No release branch or manual tag needed.

Also restores the 2.0.0 version and CHANGELOG entry lost when the branch
was rebuilt onto master.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@fifthsegment
fifthsegment merged commit 790cf08 into master Sep 24, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants