Documentation
¶
Overview ¶
Package core provides a small, stable facade over Redactyl's internal engine for external integrations. It deliberately re-exports a narrow API surface to allow Enterprise and third-party tools to depend on a stable import path without exposing internal implementation packages.
Example:
cfg := core.Config{Root: ".", Threads: 0}
findings, err := core.Scan(cfg)
if err != nil { /* handle */ }
_ = core.MarshalFindings(os.Stdout, findings)
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectorIDs ¶
func DetectorIDs() []string
DetectorIDs returns the list of configured detector IDs. This is exposed for convenience to avoid importing internals directly.
Types ¶
type Config ¶
Re-export selected internal types as a stable public API surface. These are type aliases so external consumers can depend on a stable path. We can replace these with decoupled structs later without breaking callers.
type Finding ¶
func Scan ¶
Scan is the stable entrypoint for other programs.
Example ¶
ExampleScan demonstrates how to perform a simple scan of a directory.
package main
import (
"fmt"
"os"
"github.com/varalys/redactyl/pkg/core"
)
func main() {
// 1. Configure the scan
cfg := core.Config{
Root: ".", // Scan the current directory
Threads: 4, // Number of concurrent workers
IncludeGlobs: "*.go", // Only scan Go files (optional)
MaxBytes: 1024 * 1024, // Skip files larger than 1MB
}
// 2. Run the scan
findings, err := core.Scan(cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "Scan failed: %v\n", err)
return
}
// 3. Process findings
if len(findings) == 0 {
fmt.Println("No secrets found.")
} else {
fmt.Printf("Found %d secrets.\n", len(findings))
// Helper to write JSON output to stdout
_ = core.MarshalFindings(os.Stdout, findings)
}
}
type Result ¶
func ScanWithStats ¶
ScanWithStats is the extended entrypoint that returns findings plus statistics. This is useful for integrations that need to report on scan performance or partial failures.
Example ¶
ExampleScanWithStats shows how to run a scan and retrieve execution statistics.
package main
import (
"fmt"
"time"
"github.com/varalys/redactyl/pkg/core"
)
func main() {
cfg := core.Config{
Root: "test/integration/fixtures", // Point to a directory
ScanTimeBudget: 5 * time.Second, // Set a time limit per artifact
}
// Run scan and get detailed result object
result, err := core.ScanWithStats(cfg)
if err != nil {
panic(err)
}
fmt.Printf("Scanned %d files in %s\n", result.FilesScanned, result.Duration)
fmt.Printf("Found %d secrets\n", len(result.Findings))
// Check artifact scanning stats
if result.ArtifactStats.AbortedByTime > 0 {
fmt.Printf("Warning: %d artifacts timed out\n", result.ArtifactStats.AbortedByTime)
}
}