Repository navigation
feat: authenticate and check registered accounts - #10
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
| if root == "" { | ||
| root = filepath.Join(os.Getenv("HOME"), ".cache") | ||
| } | ||
| return filepath.Join(root, "nosnitch", "credentials", id+".json") |
There was a problem hiding this comment.
Suggestion: id is used directly in the credential path, so an account ID containing ../ lets removal target files outside the credentials directory. [security]
Assessment: 🟠 Major · 🔁 Occurrence: Rarely
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/registry/registry.go
**Line:** 35:35
**Comment:**
*Security: `id` is used directly in the credential path, so an account ID containing `../` lets removal target files outside the credentials directory.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| return os.WriteFile(p, append(b, '\n'), 0600) | ||
| } | ||
| func Upsert(a Account) error { | ||
| all, e := Load() |
There was a problem hiding this comment.
Suggestion: Concurrent add or remove commands can load the same registry, overwrite each other’s changes, or read partially written JSON because updates are unlocked and direct. [race condition]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/registry/registry.go
**Line:** 64:64
**Comment:**
*Race Condition: Concurrent add or remove commands can load the same registry, overwrite each other’s changes, or read partially written JSON because updates are unlocked and direct.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| if e = Save(out); e != nil { | ||
| return e | ||
| } | ||
| _ = os.Remove(credentialPath(id)) |
There was a problem hiding this comment.
Suggestion: Credential deletion errors are discarded after metadata removal, so a failed delete leaves cached secrets behind while the command reports success. [error handling]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** internal/registry/registry.go
**Line:** 97:97
**Comment:**
*Error Handling: Credential deletion errors are discarded after metadata removal, so a failed delete leaves cached secrets behind while the command reports success.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| fmt.Fprintln(os.Stderr, "account identity required") | ||
| return 2 | ||
| } | ||
| a := registry.Account{ID: provider + ":" + id, Provider: provider, Email: id, UpdatedAt: time.Now().UTC()} |
There was a problem hiding this comment.
Suggestion: The add command only records typed identity text; it performs no authentication and creates no credential, so the registered account cannot be used by the current account checks. [incomplete implementation]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** main.go
**Line:** 104:104
**Comment:**
*Incomplete Implementation: The add command only records typed identity text; it performs no authentication and creates no credential, so the registered account cannot be used by the current account checks.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
CodeAnt Nitpicks1 code suggestion1. Writing an existing registry does not enforce mode
|
This reverts commit ce20b23.
User description
Adds end-to-end account registration and checking for nosnitch.
account add <provider>now starts PKCE/OAuth for OpenAI and Anthropic, or opens and monitors the first-party browser login for browser-only providers, then infers the account identity from provider readback. Metadata is stored in XDG config and credentials are stored in a hashed, mode-0600 XDG cache file.Registered credentials are used by
check --accountandcheck --all; expiring OAuth credentials refresh with rotation, missing or rejected credentials affect only that account, and browser cookie stores include profile discovery plus WAL/SHM snapshots. README now contains the complete command table and storage/authentication contract. Validation includes unit tests, race tests,go vet, macOS and Linux cross-builds, and read-only checks against the current local sessions.CodeAnt-AI Description
Register, authenticate, and audit individual provider accounts
What Changed
offnow covers registered OAuth accounts.Impact
✅ Checks for selected accounts without account mix-ups✅ Fewer reauthentication interruptions for expiring OAuth credentials✅ Privacy settings updated across registered OAuth accounts✅ Reliable discovery across Chromium profiles✅ Safer local storage for tokens and browser cookies💡 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:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
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:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
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.