Skip to content

feat(coderepo): Add Gitea support and enhance repository configuration#164

Merged
therealbrad merged 2 commits intomainfrom
feature/support-local-git-repos-lile-Gitea
Mar 28, 2026
Merged

feat(coderepo): Add Gitea support and enhance repository configuration#164
therealbrad merged 2 commits intomainfrom
feature/support-local-git-repos-lile-Gitea

Conversation

@therealbrad
Copy link
Copy Markdown
Contributor

@therealbrad therealbrad commented Mar 28, 2026

Description

Add support for connecting to self-hosted Git servers (Gitea, Forgejo, Gogs) as code repository providers for QuickScript code context. Also hardens SSRF protections across all existing providers by adding DNS resolution validation and redirect protection.

New provider:

  • GITEA enum value added to CodeRepositoryProvider
  • GiteaRepoAdapter implements the abstract GitRepoAdapter using the /api/v1/ REST API shared by Gitea, Forgejo, Gogs, and compatible servers
  • UI fields: Server URL, Personal Access Token, Owner, Repository
  • Help text and admin column labels included

Security hardening (all providers):

  • assertSsrfSafeResolved() — resolves DNS before every fetch and verifies the IP is not private, closing the DNS rebinding attack vector where a public hostname resolves to an internal IP (e.g., evil.com → 169.254.169.254)
  • redirect: "manual" on all fetch calls with single-hop redirect following that validates the Location URL through SSRF checks before proceeding
  • IPv6 link-local (fe80::) added to blocked ranges
  • HTTP plaintext warning shown in the UI when any provider URL field uses http:// instead of https://

Related Issue

Closes #157

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement

How Has This Been Tested?

Describe the tests you ran to verify your changes:

  • Unit tests
  • Integration tests
  • E2E tests
  • Manual testing

New and updated test files:

  • GiteaRepoAdapter.test.ts — 15 tests covering constructor, getDefaultBranch, listAllFiles (pagination, truncation, SHA fallback, URL encoding), getFileContent, testConnection, auth headers
  • ssrf.test.ts — 9 new tests (32 total) for assertSsrfSafeResolved (DNS rebinding with loopback/10.x/192.168.x/AWS metadata, safe resolution, raw IP skip, DNS failure) plus fe80:: link-local and Gitea URL allowlist
  • GitRepoAdapter.test.ts — 4 new tests (11 total) for Gitea instantiation, redirect following with SSRF validation, missing Location header, redirect: "manual" enforcement

All 226 adapter tests and 58 SSRF/adapter-specific tests pass.

Test Configuration:

  • OS: macOS Darwin 25.4.0 (ARM)
  • Node version: v22.x

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have signed the CLA

Screenshots (if applicable)

Untitled

Additional Notes

  • Database migration required: The GITEA enum value is added to CodeRepositoryProvider. Running pnpm generate updates the Prisma schema; prisma db push applies it.
  • Forgejo/Gogs compatibility: All three platforms share the same /api/v1/ REST API, so a single adapter covers them. The help text and labels make this explicit. Other servers with a Gitea-compatible API will work on a best-effort basis.
  • SSRF hardening is provider-agnostic: The DNS resolution check and redirect protection apply to all providers (GitHub, GitLab, Bitbucket, Azure DevOps, Gitea), not just the new one. This is a security improvement independent of the feature.
  • No breaking changes: Existing provider configurations are unaffected. The new enum value is additive.

- Introduced Gitea as a supported code repository provider, including configuration options for personal access tokens and server URLs.
- Updated documentation to reflect Gitea integration and provide clear instructions for users.
- Enhanced SSRF protection by implementing DNS resolution checks for Gitea URLs.
- Added tests for Gitea repository adapter to ensure proper functionality and integration.
- Improved user interface to display Gitea options in the code repository settings.
@therealbrad
Copy link
Copy Markdown
Contributor Author

This was coded to the spec, but i haven't fully tested since I don't have Gitea set up. I'll get to that and test it soon unless someone else has it set up and wants to help test for me.

- Updated the logic for retrieving the tree SHA in the Gitea repository adapter to ensure compatibility with different commit structures. This change allows for fallback to the commit ID if the tree SHA is not available, improving robustness in handling Gitea responses.
@therealbrad
Copy link
Copy Markdown
Contributor Author

I was able to set up a local Gitea repo and connect/pull files to use as context for QuickScript.

@therealbrad therealbrad merged commit 3e349de into main Mar 28, 2026
6 checks passed
@therealbrad therealbrad deleted the feature/support-local-git-repos-lile-Gitea branch March 28, 2026 22:28
@therealbrad
Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 0.19.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

clFaster pushed a commit to clFaster/testplanit that referenced this pull request Mar 29, 2026
## [0.19.0](TestPlanIt/testplanit@v0.18.12...v0.19.0) (2026-03-28)

### Features

* **coderepo:** Add Gitea support and enhance repository configuration ([TestPlanIt#164](TestPlanIt#164)) ([3e349de](TestPlanIt@3e349de))

### Bug Fixes

* **ci:** fix Docker latest tag not updating and harden semantic-release version detection ([5167980](TestPlanIt@5167980))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support connecting to local git servers like Gitea for QuickScript code context

1 participant