How tenable/terrascan works
Terrascan is an IaC security and compliance scanner, usable from the CLI or as an API server. Its main workflow accepts IaC, loads and evaluates policies, optionally enriches results with image vulnerabilities, and presents findings in supported output formats. It also supports policy initialization, admission control, and webhook notifications. The graph reflects the sampled CLI, runtime, policy, and webhook code plus documented provider and format coverage; several server routes and provider implementations were not sampled, so those links are omitted or marked unverified.
Main entry points: executor.go Scan orchestration · run.go CLI commands · validating-webhook.go Admission scan · iac-providers IaC provider parsers
Components 20
Entry points
- Executable
cmd/terrascan/main.go - CLI commands
pkg/cli/run.go - Server command
pkg/cli/server.go - HTTP API
pkg/http-server - Admission scan
pkg/k8s/admission-webhook/validating-webhook.go - Policy initialization
pkg/initialize/run.go
IaC inputs
- IaC provider parsers
pkg/iac-providers - Terraform loading
pkg/iac-providers/terraform/commons/load-dir.go - Cloud resource mapping
pkg/mapper/iac-providers - Remote modules
pkg/downloader/module-download.go
Scan analysis
- Scan orchestration
pkg/runtime/executor.go - Policy evaluation
pkg/policy/opa/engine.go - Scan filters
pkg/filters/filter-specs.go
Results and integrations
- Finding store
pkg/results/store.go - Image vulnerabilities
pkg/vulnerability - Result formats
pkg/writer - Webhook notifications
pkg/notifications/webhook/webhook.go - Admission scan log
pkg/k8s/dblogs/webhook-scan-logger.go
Other components
- CLI user
- Kubernetes API
Connections 20
- CLI user → Executable: runs
cmd/terrascan/main.go - Executable → CLI commands: starts
cmd/terrascan/main.go - CLI commands → Scan orchestration: orchestrates scan
pkg/cli/run.go - CLI commands → Result formats: formats results
pkg/cli/run.go - CLI commands → Server command: runs server
- Server command → HTTP API: starts API
pkg/cli/server.go - HTTP API → Admission scan: dispatches admission
pkg/http-server/webhook-scan.go - Kubernetes API → HTTP API: sends review
pkg/http-server/webhook-scan.go - Admission scan → Scan orchestration: executes scan
pkg/k8s/admission-webhook/validating-webhook.go - Admission scan → Admission scan log: logs scan
pkg/k8s/admission-webhook/validating-webhook.go - CLI commands → Policy initialization: initializes policies
- Scan orchestration → IaC provider parsers: creates providers
pkg/runtime/executor.go - Scan orchestration → Policy evaluation: evaluates policies
pkg/runtime/executor.go - Scan orchestration → Scan filters: applies filters
pkg/runtime/executor.go - Scan orchestration → Finding store: stores findings
pkg/runtime/executor.go - Scan orchestration → Image vulnerabilities: fetches vulnerabilities
pkg/runtime/executor.go - Scan orchestration → Webhook notifications: sends notifications
pkg/runtime/executor.go - Terraform loading → Remote modules: downloads modules
pkg/iac-providers/terraform/commons/load-dir.go - IaC provider parsers → Cloud resource mapping: maps resources
- IaC provider parsers → Terraform loading: loads Terraform
pkg/iac-providers/terraform/commons/load-dir.go