EresusSecurity
Back to Research
Open Source

CodeSpider: Self-Hosted AI Code Review for Gitea

Eresus SecuritySecurity Researcher
November 27, 2026
5 min read
CodeSpider logo and a Go gopher examining code changes with a magnifying glass.
AnnouncementSource: CodeSpider GitHub

If you run your own Gitea instance, you can keep code review in the same pull request workflow. CodeSpider is an open-source, self-hosted AI code reviewer for Gitea. When a pull request (PR) opens or changes, CodeSpider reads the diff and relevant files, then posts inline comments and a review summary directly in Gitea. We built it in Go at Eresus Security and published the source under Apache 2.0.

View CodeSpider on GitHub or see the Docker Compose and source build options.

A real Gitea pull request: adding a timeout in Go

We created go-review-demo on a local Gitea instance and opened PR #1 to add a 30-second timeout to a Go report generator. The change looked small: Generate passed a new context.WithTimeout to the report loader. But it assigned the second return value, cancel, to _.

Files Changed on Gitea PR #1, showing report.go line 9 discarding the cancel function returned by context.WithTimeout.

The actual PR in our local Gitea test repository, captured before the fix.

We ran CodeSpider against that PR with --offline --dry-run. It read the diff and commit, ran its deterministic checks without calling a model, and printed findings in the terminal without posting to Gitea. Two lines from the review output:

- [WARNING] CS-FLOW-003 (report.go:9): Context cancel function discarded or never called
- [WARNING] CS-TEST-001 (report.go:11): Exported Go behavior changed without test coverage

The first warning points to something a reviewer can verify in the diff. Even if the report finishes in a second, Generate does not release the timeout's resources when it returns. The Go context documentation calls out why a caller should invoke cancel when the work is done. The second warning gives the reviewer a separate question: what test shows the new behavior is correct?

Fixing the finding and reviewing the same PR again

We kept the cancel value, added defer cancel(), and wrote TestGenerateCancelsContextOnReturn. The test lets the report loader return immediately, then checks that its context is already context.Canceled when Generate returns.

The test passed. When we ran CodeSpider on the new PR head, both warnings were gone and the summary listed the new test. This was a single local demonstration with the open-source CodeSpider review command, not a production benchmark. It shows the review loop: inspect the changed line, agree on a fix, and verify it on the next commit.

How the Gitea webhook becomes an inline review

  1. Gitea sends a webhook when a pull request opens or changes. CodeSpider verifies the signature with the configured shared secret.
  2. CodeSpider opens a separate Git worktree for the commit under review. It can inspect files beyond the diff and use repository review guidance in places such as AGENTS.md or .gitea/review-instructions.md.
  3. CodeSpider returns inline comments, a summary, and a commit status to Gitea. A developer can mention @codespider in the PR thread to ask about a comment.

The CodeSpider architecture notes show where repository context and tool calls enter the review.

CodeSpider connects to an OpenAI-compatible model endpoint with tool calling. You can host the reviewer and model on infrastructure you control, or choose an external endpoint. Self-hosting the reviewer alone does not keep source context on your network when you use a hosted model. Review your provider's retention terms and your organization's source-sharing policy before connecting private repositories.

Roll out automated pull request review on one repository first

Use the CodeSpider configuration reference to set up a dedicated Gitea bot account and a repository-level webhook. Grant the account only the permissions it needs on the pilot repository. The gitea.repos setting limits periodic reconciliation; it does not replace repository permissions or webhook scoping.

For the pilot, leave code writing and agent-initiated test execution disabled. These settings are a partial excerpt to merge into codespider.yaml, not a complete installation configuration:

gitea:
  allow_unsigned_webhooks: false
agent:
  enable_write: false
  adversarial_security: false
  enable_proof_of_bug: false

Follow the Gitea setup guide for the webhook events and set the same webhook secret on both sides. If a review doesn't appear, check Gitea's webhook delivery result before changing model settings. Then check the CodeSpider service logs and confirm that the bot can both read the repository and submit review comments.

Run the pilot on a PR your team already reviewed, ideally one with a behavior change, a caller, and an existing test. Confirm that comments attach to the relevant diff lines in Gitea. Ask maintainers which comments were useful, which repeated a CI result, and which they would dismiss. A review that creates more triage work than it saves should stay out of the merge gate.

Where CodeSpider fits alongside CI and human review

Check What it does best
CI tests and linting Run defined checks and produce repeatable results for failures such as a broken build or a regression.
CodeSpider Reviews the diff in context and flags questions about behavior, callers, and test coverage in the PR.
Human review Verifies findings, weighs product intent and risk, and owns the merge decision.

A run with no findings does not establish that a change is safe. Keep required CI checks and human approval in place. For a practical merge policy, see how to review AI-authored code before it merges.

Frequently asked questions

Which platform does CodeSpider support?

CodeSpider currently works with Gitea. It reviews new and updated pull requests and posts its comments and summary directly on the PR.

Can CodeSpider leave comments without writing code?

Yes. With agent.enable_write: false, CodeSpider can still send review comments to Gitea while code-writing tools are disabled. You do not need to give the review bot merge authority.

Is CodeSpider free and open source?

Yes. CodeSpider's source is available under Apache 2.0. You may still pay for the infrastructure or model endpoint you choose to run it with.

Try CodeSpider on one Gitea pull request. Get the source on GitHub, start with a test repository, and see which comments your team would act on. Find more project notes in the Eresus OSS hub.

AI Security Starter Training

Request a practical checklist for prompt injection, RAG data leakage, MCP risks, and model-file security before launch.

Prompt injection and guardrail bypass checks.
RAG data leakage and permission-boundary review.
MCP identity, transport, and command-risk controls.

No spam. Used only to send the resource and related security notes.

Related Services

Scope Estimator

Get a rough engagement size before the scoping call.

What this depth covers
Full coverage of the OWASP-family test plan for the in-scope targets: broken access control, injection, authn and authz flaws, business-logic abuse, findings with reproduction steps.
What it does not cover
Multi-week adversary emulation, physical and phishing vectors, custom exploit development, source-code review.

Indicative effort

~5 tester-days

Estimate only, not a quote. It scales with the three factors above and assumes the targets are reachable and test accounts are provided in the test window.

Request exact scope