# shigosag/gitshield architecture

> Architecture diagram of the GitHub repository shigosag/gitshield, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shigosag/gitshield
- Repository: https://github.com/shigosag/gitshield

## Overview

GitShield is a developer-facing security CLI. Its main workflow scans repository files (or staged changes), checks contents for secrets and lockfiles for vulnerable dependencies, then reports findings and applies a configurable failure threshold. It also installs Git hooks that invoke scans before commits and pushes. The graph includes README-documented secret heuristics and CI use; source for the secret implementation and workflow was not excerpted, so those internal links are unverified or omitted.

Main entry points: [`cmd/gitshield/main.go`](https://github.com/shigosag/gitshield/blob/main/cmd/gitshield/main.go) (CLI Commands), [`internal/scanner/runner.go`](https://github.com/shigosag/gitshield/blob/main/internal/scanner/runner.go) (Scan Orchestrator), [`internal/scanner/secret_scanner.go`](https://github.com/shigosag/gitshield/blob/main/internal/scanner/secret_scanner.go) (Secret Detection), [`internal/githooks/installer.go`](https://github.com/shigosag/gitshield/blob/main/internal/githooks/installer.go) (Hook Installer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and Configuration"]
  node_cli["CLI Commands<br/>[main.go]"]
  node_config["Scan Configuration<br/>[config.go]"]
end

subgraph group_scan["Security Scanning"]
  node_runner["Scan Orchestrator<br/>[runner.go]"]
  node_secret_scanner["Secret Detection<br/>[secret_scanner.go]"]
  node_secret_rules["Secret Rules<br/>[secret_rules.go]"]
  node_entropy["Entropy Heuristics<br/>[secret_scanner.go]"]
  node_lockfile_parser["Lockfile Parsing"]
  node_dependency_audit["Dependency Audit"]
  node_osv_client["OSV API Client<br/>[osv_client.go]"]
end

subgraph group_hooks["Git Protection"]
  node_hook_installer["Hook Installer<br/>[installer.go]"]
  node_git_hooks["Pre-commit and Push Hooks<br/>[installer.go]"]
end

subgraph group_results["Findings and Output"]
  node_findings["Scan Findings<br/>[runner.go]"]
  node_reporter["Terminal Report<br/>[terminal.go]"]
end

node_developer(("Developer"))
node_git_repo[("Git Repository")]
node_github_actions(("GitHub Actions"))
node_osv_service{{"OSV Advisory Service"}}

node_developer -->|"runs commands"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"starts scan"| node_runner
node_config -->|"sets threshold"| node_runner
node_runner -->|"scans content"| node_secret_scanner
node_runner -->|"parses lockfiles"| node_lockfile_parser
node_runner -->|"audits packages"| node_dependency_audit
node_dependency_audit -->|"queries advisories"| node_osv_client
node_osv_client -->|"posts batch query"| node_osv_service
node_secret_scanner -.->|"uses patterns"| node_secret_rules
node_secret_scanner -.->|"checks entropy"| node_entropy
node_runner -->|"reads files"| node_git_repo
node_runner -->|"aggregates findings"| node_findings
node_cli -->|"prints results"| node_reporter
node_cli -->|"encodes JSON"| node_findings
node_developer -->|"installs hooks"| node_hook_installer
node_cli -->|"runs init"| node_hook_installer
node_hook_installer -->|"writes hooks"| node_git_repo
node_git_hooks -->|"invokes staged scan"| node_cli
node_github_actions -.->|"runs security checks"| node_cli

click node_cli "https://github.com/shigosag/gitshield/blob/main/cmd/gitshield/main.go"
click node_config "https://github.com/shigosag/gitshield/blob/main/internal/config/config.go"
click node_runner "https://github.com/shigosag/gitshield/blob/main/internal/scanner/runner.go"
click node_secret_scanner "https://github.com/shigosag/gitshield/blob/main/internal/scanner/secret_scanner.go"
click node_secret_rules "https://github.com/shigosag/gitshield/blob/main/internal/scanner/secret_rules.go"
click node_entropy "https://github.com/shigosag/gitshield/blob/main/internal/scanner/secret_scanner.go"
click node_lockfile_parser "https://github.com/shigosag/gitshield/blob/main/internal/scanner/dependency_scanner.go"
click node_dependency_audit "https://github.com/shigosag/gitshield/blob/main/internal/scanner/dependency_scanner.go"
click node_osv_client "https://github.com/shigosag/gitshield/blob/main/internal/scanner/osv_client.go"
click node_hook_installer "https://github.com/shigosag/gitshield/blob/main/internal/githooks/installer.go"
click node_git_hooks "https://github.com/shigosag/gitshield/blob/main/internal/githooks/installer.go"
click node_findings "https://github.com/shigosag/gitshield/blob/main/internal/scanner/runner.go"
click node_reporter "https://github.com/shigosag/gitshield/blob/main/internal/output/terminal.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_config toneBlue
class node_runner,node_secret_scanner,node_secret_rules,node_entropy,node_lockfile_parser,node_dependency_audit,node_osv_client,node_git_repo toneAmber
class node_hook_installer,node_git_hooks toneMint
class node_findings,node_reporter toneRose
class node_developer,node_github_actions,node_osv_service toneIndigo
```

## Components

### CLI and Configuration

- [CLI Commands](https://github.com/shigosag/gitshield/blob/main/cmd/gitshield/main.go): `cmd/gitshield/main.go`
- [Scan Configuration](https://github.com/shigosag/gitshield/blob/main/internal/config/config.go): `internal/config/config.go`

### Security Scanning

- [Scan Orchestrator](https://github.com/shigosag/gitshield/blob/main/internal/scanner/runner.go): `internal/scanner/runner.go`
- [Secret Detection](https://github.com/shigosag/gitshield/blob/main/internal/scanner/secret_scanner.go): `internal/scanner/secret_scanner.go`
- [Secret Rules](https://github.com/shigosag/gitshield/blob/main/internal/scanner/secret_rules.go): `internal/scanner/secret_rules.go`
- [Entropy Heuristics](https://github.com/shigosag/gitshield/blob/main/internal/scanner/secret_scanner.go): `internal/scanner/secret_scanner.go`
- [Lockfile Parsing](https://github.com/shigosag/gitshield/blob/main/internal/scanner/dependency_scanner.go): `internal/scanner/dependency_scanner.go`
- [Dependency Audit](https://github.com/shigosag/gitshield/blob/main/internal/scanner/dependency_scanner.go): `internal/scanner/dependency_scanner.go`
- [OSV API Client](https://github.com/shigosag/gitshield/blob/main/internal/scanner/osv_client.go): `internal/scanner/osv_client.go`

### Git Protection

- [Hook Installer](https://github.com/shigosag/gitshield/blob/main/internal/githooks/installer.go): `internal/githooks/installer.go`
- [Pre-commit and Push Hooks](https://github.com/shigosag/gitshield/blob/main/internal/githooks/installer.go): `internal/githooks/installer.go`

### Findings and Output

- [Scan Findings](https://github.com/shigosag/gitshield/blob/main/internal/scanner/runner.go): `internal/scanner/runner.go`
- [Terminal Report](https://github.com/shigosag/gitshield/blob/main/internal/output/terminal.go): `internal/output/terminal.go`

### Other components

- **Developer**
- **Git Repository**
- **GitHub Actions**
- **OSV Advisory Service**

## Connections

- Developer → CLI Commands: runs commands (evidence: `README.md`)
- CLI Commands → Scan Configuration: loads settings (evidence: `cmd/gitshield/main.go`)
- CLI Commands → Scan Orchestrator: starts scan (evidence: `cmd/gitshield/main.go`)
- Scan Configuration → Scan Orchestrator: sets threshold
- Scan Orchestrator → Secret Detection: scans content (evidence: `internal/scanner/runner.go`)
- Scan Orchestrator → Lockfile Parsing: parses lockfiles (evidence: `internal/scanner/runner.go`)
- Scan Orchestrator → Dependency Audit: audits packages (evidence: `internal/scanner/runner.go`)
- Dependency Audit → OSV API Client: queries advisories (evidence: `internal/scanner/dependency_scanner.go`)
- OSV API Client → OSV Advisory Service: posts batch query (evidence: `internal/scanner/osv_client.go`)
- Secret Detection → Secret Rules: uses patterns
- Secret Detection → Entropy Heuristics: checks entropy
- Scan Orchestrator → Git Repository: reads files (evidence: `internal/scanner/runner.go`)
- Scan Orchestrator → Scan Findings: aggregates findings (evidence: `internal/scanner/runner.go`)
- CLI Commands → Terminal Report: prints results (evidence: `cmd/gitshield/main.go`)
- CLI Commands → Scan Findings: encodes JSON (evidence: `cmd/gitshield/main.go`)
- Developer → Hook Installer: installs hooks (evidence: `README.md`)
- CLI Commands → Hook Installer: runs init (evidence: `cmd/gitshield/main.go`)
- Hook Installer → Git Repository: writes hooks (evidence: `internal/githooks/installer.go`)
- Pre-commit and Push Hooks → CLI Commands: invokes staged scan (evidence: `internal/githooks/installer.go`)
- GitHub Actions → CLI Commands: runs security checks (evidence: `README.md`)
