Skip to content

Commit d36dc56

Browse files
author
Szymon Janikowski
committed
Info about remote repos
1 parent 7d3b66a commit d36dc56

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

docs/configure.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,93 @@ Configures a local Git repository for analysis:
414414
- **ExcludeProjectsMatching**: Excludes projects matching a regex pattern
415415
- **IncludeOnlyProjectsFromSolutions**: Limits analysis to projects from specific solution files
416416

417+
#### UseRemote
418+
Configures a remote Git repository for analysis:
419+
420+
```csharp
421+
// GitHub repository
422+
.UseRemote("Name", GitRepositoryProvider.GitHub,
423+
new Uri("https://github.com/org/repo.git"))
424+
425+
// GitHub with branch and configuration
426+
.UseRemote("Name", GitRepositoryProvider.GitHub,
427+
new Uri("https://github.com/org/repo.git"), "develop", repository => repository
428+
.ExcludeProjects("Tests", "Build")
429+
.IncludeOnlyProjectsFromSolutions("Main.sln"))
430+
431+
// GitLab Cloud
432+
.UseRemote("Name", GitRepositoryProvider.GitLabCloud,
433+
new Uri("https://gitlab.com/org/repo.git"))
434+
435+
// Azure DevOps
436+
.UseRemote("Name", GitRepositoryProvider.AzureDevOps,
437+
new Uri("https://dev.azure.com/org/project/_git/repo"))
438+
```
439+
440+
**Parameters:**
441+
- **Name**: Identifier for the repository in documentation
442+
- **GitRepositoryProvider**: The Git hosting platform (GitHub, GitLabCloud, GitLabOnPrem, AzureDevOps, Other)
443+
- **Uri**: Full URL to the Git repository (must end with .git)
444+
- **branch**: Git branch to analyze (defaults to "main")
445+
- **configure**: Optional lambda to configure repository-specific settings
446+
447+
**Available Providers:**
448+
- `GitRepositoryProvider.GitHub` - GitHub repositories
449+
- `GitRepositoryProvider.GitLabCloud` - GitLab.com repositories
450+
- `GitRepositoryProvider.GitLabOnPrem` - Self-hosted GitLab instances
451+
- `GitRepositoryProvider.AzureDevOps` - Azure DevOps repositories
452+
- `GitRepositoryProvider.Other` - Other Git hosting platforms
453+
454+
**Authentication:** See [Authentication for Remote Repositories](#authentication-for-remote-repositories) section below for security setup.
455+
456+
#### Authentication for Remote Repositories
457+
458+
When using remote repositories, you need to provide authentication credentials via environment variables.
459+
460+
:::danger SECURITY RECOMMENDATION
461+
**Always use Fine-Grained Personal Access Tokens with minimal permissions!**
462+
463+
We **strongly recommend** configuring your Personal Access Token to:
464+
- ✅ Grant access **only to specific repositories** you want to analyze (not all repositories)
465+
- ✅ Use **read-only permissions** (repository contents: read-only)
466+
- ✅ Set **expiration dates** and rotate tokens regularly
467+
- ✅ Use **service accounts** or dedicated bot accounts for production deployments
468+
-**Never commit** tokens to source code or configuration files in version control
469+
470+
**For GitHub:**
471+
- Use [Fine-grained Personal Access Tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token)
472+
- Select only specific repositories in "Repository access"
473+
- Grant only "Contents: Read-only" permission
474+
475+
**For GitLab:**
476+
- Create tokens with `read_repository` scope only
477+
- If you scan only one repository use [Project Access Tokens](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html) for specific projects
478+
- Consider using bot/service accounts with limited access to selected repos
479+
480+
**For Azure DevOps:**
481+
- Create [Personal Access Tokens](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate) with "Code: Read" scope only
482+
- Limit token to specific organizations/projects
483+
- Use dedicated service/bot accounts with PAT for production
484+
:::
485+
486+
**Environment Variables Configuration:**
487+
488+
Set the following environment variables:
489+
490+
```bash
491+
# Required: Personal Access Token
492+
export NOESIS_Git__PAT="your_token_here"
493+
494+
# Optional: Username (defaults to "pat" if not provided)
495+
export NOESIS_Git__Username="your-username"
496+
```
497+
498+
**How it works:**
499+
- Noesis clones the remote repository to a temporary directory
500+
- Authentication happens automatically using the provided PAT
501+
- The PAT is used as the password in Git credentials
502+
- Repository is analyzed from the cloned copy
503+
417504
### AnalyzersBuilder
418505

419506
The AnalyzersBuilder configures how Noesis identifies and categorizes different elements in your codebase. It has three main configuration areas: domain modules, domain objects, and domain behaviors.

0 commit comments

Comments
 (0)