// Package engine provides a mode-agnostic scan engine that can be used
// independently of any UI layer. This file defines core domain types
// shared across the engine and its consumers (TUI, daemon, etc.).
package engine

import "time"

// Finding represents a discovered credential exposure or misconfiguration.
// This is the core result type produced by the scanner when sensitive
// content is detected at a URL.
type Finding struct {
	// Domain is the target domain that was scanned (e.g., "example.com").
	Domain string

	// Path is the URL path where the exposure was found (e.g., "/.env").
	Path string

	// StatusCode is the HTTP status code returned (typically 200 for exposures).
	StatusCode int

	// ContentType is the Content-Type header from the response.
	ContentType string

	// BodySnippet is the first portion of the response body (up to 500 chars).
	// Used for display and verification without storing entire responses.
	BodySnippet string

	// Patterns lists the credential patterns that matched in the response.
	// Examples: "DB_PASSWORD", "AWS_SECRET_ACCESS_KEY", ".git-exposed"
	Patterns []string

	// Exposed indicates whether this finding represents an actual exposure.
	// True when credential patterns were detected in a 200 response.
	Exposed bool

	// FoundAt is the timestamp when this finding was discovered.
	FoundAt time.Time
}

// TargetStatus represents the current state of a scan target.
type TargetStatus int

const (
	// StatusQueued indicates the target is waiting to be scanned.
	StatusQueued TargetStatus = iota

	// StatusStarted indicates scanning has begun for this target.
	StatusStarted

	// StatusCompleted indicates scanning finished with no findings.
	StatusCompleted

	// StatusFound indicates scanning finished and exposures were discovered.
	StatusFound

	// StatusError indicates scanning failed due to an error.
	StatusError
)

// String returns a human-readable representation of the target status.
func (s TargetStatus) String() string {
	switch s {
	case StatusQueued:
		return "queued"
	case StatusStarted:
		return "started"
	case StatusCompleted:
		return "completed"
	case StatusFound:
		return "found"
	case StatusError:
		return "error"
	default:
		return "unknown"
	}
}
