Skip to content

feat: add GitHub Copilot privacy checks - #9

Merged
ygpark80 merged 3 commits into
mainfrom
feat/github-copilot-privacy
Jul 30, 2026
Merged

ygpark80 merged 3 commits into
mainfrom
feat/github-copilot-privacy

Conversation

@ygpark80

@ygpark80 ygpark80 commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

User description

Closes #8

Changes

  • Add account-centric GitHub Copilot checks for the license, model-training preference, cloud-agent repository scope, and Claude/Codex partner-agent states.
  • Merge duplicate browser sessions by GitHub login and surface expired, unreadable, or incomplete sessions instead of treating them as clean.
  • Add the confirmed nosnitch github training [--yes] opt-out and include it in nosnitch off without changing repository or partner-agent access.
  • Restrict credentials and CSRF values to the expected first-party GitHub request path, and document the read/write scope.

Testing

  • go test ./...
  • go vet ./...
  • go build ./...
  • NO_COLOR=1 go run . check
  • NO_COLOR=1 go run . check --json
  • Confirmed nosnitch github training defaults to cancellation on empty input.

Notes

  • The live GitHub write path was exercised: GitHub returned HTTP 406 after applying the change, and the read-back confirmed model training was OFF.
  • The write path now verifies the saved setting even after a non-success response; the 406-after-success behavior has a regression test.

CodeAnt-AI Description

Add GitHub Copilot privacy checks and controls

What Changed

  • check and status now report GitHub Copilot license, model-training preference, cloud-agent repository scope, and Claude/Codex partner-agent access.
  • GitHub sessions from multiple browsers are combined by account, while expired, unreadable, or incomplete sessions are reported as incomplete instead of clean.
  • Added nosnitch github training [--yes] to disable Copilot model training after confirmation and verify the change.
  • nosnitch off now disables GitHub Copilot model training without changing cloud-agent repository access or partner-agent settings.
  • GitHub updates reject unexpected forms and keep credentials and security tokens out of reports and output.

Impact

✅ GitHub Copilot training exposure is visible
✅ Incomplete GitHub checks are clearly reported
✅ Safer Copilot opt-out with post-change verification

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • New Features
    • Added GitHub Copilot account checks for license, model-training preferences, cloud-agent repository scope, and partner-agent settings.
    • Added nosnitch github training with optional confirmation bypass to disable Copilot model training.
    • Updated nosnitch off to include GitHub Copilot model-training settings.
    • Expanded status output and documentation with GitHub Copilot details and privacy protections.
  • Bug Fixes
    • Reports now clearly indicate when account information is incomplete or browser sessions are unavailable.
  • Tests
    • Added coverage for GitHub settings detection, updates, account merging, and confirmation prompts.

@ygpark80 ygpark80 linked an issue Jul 30, 2026 that may be closed by this pull request
@codeant-ai

codeant-ai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 20d1398 Jul 30, 2026 · 08:45 08:48

@codeant-ai

codeant-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ygpark80, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ddd95659-cbf9-419e-8f88-c56cea3bb7a5

📥 Commits

Reviewing files that changed from the base of the PR and between 20d1398 and 6b40834.

📒 Files selected for processing (8)
  • internal/account/account.go
  • internal/account/account_test.go
  • internal/cookies/cookies.go
  • internal/cookies/cookies_test.go
  • internal/cookies/safari.go
  • internal/github/github.go
  • internal/github/github_test.go
  • main.go
📝 Walkthrough

Walkthrough

GitHub Copilot settings are read from authenticated browser sessions, merged by GitHub login, included in reports and status output, and exposed through commands that disable model training while leaving repository and partner-agent settings unchanged.

Changes

GitHub Copilot settings

Layer / File(s) Summary
Settings parsing and model-training updates
internal/github/github.go, internal/github/github_test.go
Parses Copilot features and coding-agent pages, reports license and access settings, and disables model training through a verified update request.
Account aggregation and report state
internal/account/*, internal/cookies/cookies.go
Merges GitHub sessions by login, stores Copilot settings, evaluates risk and completeness, and marks skipped or blocked sessions indeterminate.
CLI commands and status output
main.go, main_test.go
Adds GitHub training commands, integrates GitHub into nosnitch off, renders Copilot settings, and tests confirmation behavior.
Usage and security documentation
README.md
Documents GitHub checks, commands, unchanged access settings, sample output, and in-memory credential handling.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant nosnitch
  participant Browser
  participant GitHub
  User->>nosnitch: run github training
  nosnitch->>Browser: read GitHub session cookies
  Browser-->>nosnitch: return cookies
  nosnitch->>GitHub: check Copilot features and coding-agent settings
  GitHub-->>nosnitch: return account and settings
  nosnitch->>User: request confirmation
  User-->>nosnitch: confirm disablement
  nosnitch->>GitHub: submit training disablement
  GitHub-->>nosnitch: return updated settings
  nosnitch->>User: report result
Loading

Possibly related PRs

  • circlesac/nosnitch-cli#2: Refactors related provider-aware account aggregation and report-state logic in the same code paths.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes cover GitHub account discovery, merged reporting, training opt-out, tests, and README updates required by #8.
Out of Scope Changes check ✅ Passed No clear unrelated code changes are indicated beyond the GitHub Copilot privacy work in scope.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding GitHub Copilot privacy checks.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/github-copilot-privacy

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.

@codeant-ai codeant-ai Bot added the size:XL This PR changes 500-999 lines, ignoring generated files label Jul 30, 2026
Comment thread internal/github/github.go
Comment thread internal/github/github.go Outdated
Comment thread internal/github/github.go Outdated
Comment thread main.go Outdated
Comment thread internal/account/account.go
Comment thread internal/cookies/cookies.go

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
internal/github/github.go (1)

338-368: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Address flagged errcheck/noctx findings.

golangci-lint flags unchecked resp.Body.Close() errors (Lines 348, 365) and http.NewRequest instead of NewRequestWithContext (Lines 339, 354). Both are cheap to fix without changing the exported API.

🛠️ Proposed fix
+import (
+	"context"
 ...
 )

 func get(client doer, target, cookie string) (int, []byte, error) {
-	req, err := http.NewRequest(http.MethodGet, target, nil)
+	req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, target, nil)
 	if err != nil {
 		return 0, nil, err
 	}
 	requestHeaders(req, cookie)
 	resp, err := client.Do(req)
 	if err != nil {
 		return 0, nil, err
 	}
-	defer resp.Body.Close()
+	defer func() { _ = resp.Body.Close() }()
 	body, err := io.ReadAll(resp.Body)
 	return resp.StatusCode, body, err
 }

 func postForm(client doer, target, referer, cookie string, form url.Values) (int, []byte, error) {
-	req, err := http.NewRequest(http.MethodPost, target, strings.NewReader(form.Encode()))
+	req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, target, strings.NewReader(form.Encode()))
 	if err != nil {
 		return 0, nil, err
 	}
 	requestHeaders(req, cookie)
 	req.Header.Set("content-type", "application/x-www-form-urlencoded")
 	req.Header.Set("referer", referer)
 	resp, err := client.Do(req)
 	if err != nil {
 		return 0, nil, err
 	}
-	defer resp.Body.Close()
+	defer func() { _ = resp.Body.Close() }()
 	body, err := io.ReadAll(resp.Body)
 	return resp.StatusCode, body, err
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/github/github.go` around lines 338 - 368, Update get and postForm to
create requests with http.NewRequestWithContext using an appropriate context,
and handle errors returned by resp.Body.Close instead of discarding them.
Preserve the existing request behavior and function signatures while satisfying
the errcheck/noctx findings.

Source: Linters/SAST tools

internal/account/account_test.go (1)

64-95: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider testing partial-result merges, not just identical duplicates.

Both mergeGitHub calls here use the same fully-populated result, so the test doesn't cover the nil-safe merge behavior in account.go's mergeGitHub (e.g., a second session with ModelTraining == nil should preserve the first session's value instead of clobbering it). A second scenario with a partially-populated Result would give more confidence in that logic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/account/account_test.go` around lines 64 - 95, Extend
TestGitHubBrowserSessionsMergeByLogin with a second mergeGitHub call using a
partially populated Result, including ModelTraining set to nil, while retaining
the same login. Assert the merged account still preserves the first result’s
non-nil settings and existing metadata, while continuing to merge the session
source as expected.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@main.go`:
- Around line 442-455: Update the GitHub session loop around CheckWith and the
cookie-read error branch so unreadable cookies and checks with a populated
Reason are marked outcome.indeterminate before continuing. Preserve continuing
to OffWith for usable sessions, including checks reporting OK with partial-read
details, so finishOff cannot report clean after an incomplete GitHub check.

---

Nitpick comments:
In `@internal/account/account_test.go`:
- Around line 64-95: Extend TestGitHubBrowserSessionsMergeByLogin with a second
mergeGitHub call using a partially populated Result, including ModelTraining set
to nil, while retaining the same login. Assert the merged account still
preserves the first result’s non-nil settings and existing metadata, while
continuing to merge the session source as expected.

In `@internal/github/github.go`:
- Around line 338-368: Update get and postForm to create requests with
http.NewRequestWithContext using an appropriate context, and handle errors
returned by resp.Body.Close instead of discarding them. Preserve the existing
request behavior and function signatures while satisfying the errcheck/noctx
findings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 80244acd-222c-478d-86d2-61cdc4c5a937

📥 Commits

Reviewing files that changed from the base of the PR and between f1c0bdb and 20d1398.

📒 Files selected for processing (8)
  • README.md
  • internal/account/account.go
  • internal/account/account_test.go
  • internal/cookies/cookies.go
  • internal/github/github.go
  • internal/github/github_test.go
  • main.go
  • main_test.go

Comment thread main.go Outdated
@ygpark80
ygpark80 merged commit 4aedf3d into main Jul 30, 2026
2 checks passed
@ygpark80
ygpark80 deleted the feat/github-copilot-privacy branch July 30, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GitHub Copilot privacy and coding-agent access checks

1 participant