From d3beddd2e6cf9ac11beadd784496d8eba8a5f8ec Mon Sep 17 00:00:00 2001 From: latenighthackathon Date: Thu, 9 Apr 2026 22:18:39 -0500 Subject: [PATCH] fix(policy): add protocol/enforcement/tls to GitHub endpoints Replace access: full with scoped L7 rules in the github preset (moved from base policy to presets/github.yaml by #1583). github.com gets GET + POST scoped to git-upload-pack / git-receive-pack. api.github.com gets GET + PR/issue/refs/contents writes; DELETE excluded to block destructive ops. Closes #1111 Signed-off-by: latenighthackathon --- .../policies/presets/github.yaml | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/nemoclaw-blueprint/policies/presets/github.yaml b/nemoclaw-blueprint/policies/presets/github.yaml index 518d8780ff4..d965b0a07d8 100644 --- a/nemoclaw-blueprint/policies/presets/github.yaml +++ b/nemoclaw-blueprint/policies/presets/github.yaml @@ -19,12 +19,56 @@ network_policies: github: name: github endpoints: + # git transport (clone, fetch, push) over smart HTTP. + # POST scoped to git-upload-pack / git-receive-pack only. - host: github.com port: 443 - access: full + protocol: rest + enforcement: enforce + tls: terminate + rules: + - allow: { method: GET, path: "/**" } + - allow: { method: POST, path: "/**/git-upload-pack" } + - allow: { method: POST, path: "/**/git-receive-pack" } + # REST API: GET is unrestricted; writes scoped to PR/issue + # workflows and git ref/content operations. DELETE excluded to + # block destructive ops (repo deletion, branch force-delete, + # org membership changes). - host: api.github.com port: 443 - access: full + protocol: rest + enforcement: enforce + tls: terminate + rules: + - allow: { method: GET, path: "/**" } + # PR workflow + - allow: { method: POST, path: "/repos/*/*/pulls" } + - allow: { method: PATCH, path: "/repos/*/*/pulls/*" } + - allow: { method: PUT, path: "/repos/*/*/pulls/*/merge" } + - allow: { method: PUT, path: "/repos/*/*/pulls/*/update-branch" } + - allow: { method: POST, path: "/repos/*/*/pulls/*/reviews" } + - allow: { method: POST, path: "/repos/*/*/pulls/*/requested_reviewers" } + # Issues + - allow: { method: POST, path: "/repos/*/*/issues" } + - allow: { method: PATCH, path: "/repos/*/*/issues/*" } + - allow: { method: POST, path: "/repos/*/*/issues/*/comments" } + # Labels + - allow: { method: POST, path: "/repos/*/*/labels" } + - allow: { method: PATCH, path: "/repos/*/*/labels/*" } + # Milestones + - allow: { method: POST, path: "/repos/*/*/milestones" } + - allow: { method: PATCH, path: "/repos/*/*/milestones/*" } + # Releases + - allow: { method: POST, path: "/repos/*/*/releases" } + - allow: { method: PATCH, path: "/repos/*/*/releases/*" } + # Forks + - allow: { method: POST, path: "/repos/*/*/forks" } + # Branch creation and file commits via API + - allow: { method: POST, path: "/repos/*/*/git/refs" } + - allow: { method: PATCH, path: "/repos/*/*/git/refs/**" } + - allow: { method: PUT, path: "/repos/*/*/contents/**" } + # Manual workflow dispatch (gh workflow run) + - allow: { method: POST, path: "/repos/*/*/actions/workflows/*/dispatches" } binaries: - { path: /usr/bin/gh } - { path: /usr/bin/git }