inspect

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveEntryNamesFromSummary

func ArchiveEntryNamesFromSummary(raw json.RawMessage) []string

func ArchiveFamilyFiles

func ArchiveFamilyFiles(candidateFile string, files []pgindex.CatalogReleaseFile) []pgindex.CatalogReleaseFile

func ArchiveFamilyKey

func ArchiveFamilyKey(fileName string) string

func ArchiveProbePath

func ArchiveProbePath(fileName string) string

func BestMediaEntry

func BestMediaEntry(entries []string) string

func DetectMIMEType

func DetectMIMEType(data []byte, fileName string) string

func DetectSignature

func DetectSignature(data []byte, fileName string) string

func ExtractPasswordCandidates

func ExtractPasswordCandidates(values ...string) []string

func ExtractTextTokens

func ExtractTextTokens(text string) []string

func InferEncrypted

func InferEncrypted(candidate pgindex.BinaryInspectionCandidate) bool

func IsArchiveFile

func IsArchiveFile(fileName string) bool

func IsArchiveRepresentative

func IsArchiveRepresentative(fileName string) bool

func IsAudioFile

func IsAudioFile(fileName string) bool

func IsVideoFile

func IsVideoFile(fileName string) bool

func MarshalArchiveEntries

func MarshalArchiveEntries(entries []string) json.RawMessage

func ParseInt64

func ParseInt64(value string) int64

func ParseSeconds

func ParseSeconds(value string) float64

func ToolProvenance

func ToolProvenance(opts Options, stageName string) map[string]any

Types

type ArchiveEntryInfo

type ArchiveEntryInfo struct {
	Name             string
	IsDir            bool
	UncompressedSize int64
	CompressedSize   int64
	Encrypted        bool
	Comment          string
}

type ArchiveMediaMaterialization

type ArchiveMediaMaterialization struct {
	ArchivePath       string
	ArchiveBytes      int64
	ExtractedBytes    int64
	Signature         string
	MIMEType          string
	ExtractStderr     string
	PartialExtraction bool
	FFProbeResult     *FFProbeResult
	FFProbeOutput     []byte
	FFProbeError      string
}

func MaterializeArchiveMediaToWorkspace

func MaterializeArchiveMediaToWorkspace(ctx context.Context, repo CatalogReader, fetcher ArticleFetcher, runner CommandRunner, candidate pgindex.BinaryInspectionCandidate, entryName string, workspaceDir string, opts Options, log logger) (*ArchiveMediaMaterialization, error)

type ArchiveProbeResult

type ArchiveProbeResult struct {
	Strategy          string
	ProbePath         string
	MaterializedBytes int64
	Entries           []ArchiveEntryInfo
	EntryNames        []string
	Encrypted         bool
	ProbeError        string
	FamilyFileNames   []string
}

func PrepareArchiveProbe

func PrepareArchiveProbe(ctx context.Context, workspace *Workspace, repo CatalogReader, fetcher ArticleFetcher, runner CommandRunner, log logger, opts Options, candidate pgindex.BinaryInspectionCandidate) (*ArchiveProbeResult, error)

type ArticleFetcher

type ArticleFetcher interface {
	Fetch(ctx context.Context, msgID string, groups []string) (io.Reader, error)
}

type BinaryPrefixSample

type BinaryPrefixSample struct {
	File       pgindex.CatalogReleaseFile
	Groups     []string
	Prefix     []byte
	Signature  string
	MIMEType   string
	BytesRead  int64
	ExactSize  int64
	OutputName string
}

func SampleBinaryPrefix

func SampleBinaryPrefix(ctx context.Context, repo CatalogReader, fetcher ArticleFetcher, candidate pgindex.BinaryInspectionCandidate, maxBytes int64) (*BinaryPrefixSample, error)

type CatalogReader

type CatalogReader interface {
	ListCatalogReleaseFiles(ctx context.Context, releaseID string) ([]pgindex.CatalogReleaseFile, error)
	ListCatalogReleaseFileArticles(ctx context.Context, releaseFileID int64) ([]pgindex.CatalogArticleRef, error)
	ListCatalogReleaseNewsgroups(ctx context.Context, releaseID string) ([]string, error)
}

type CommandRunner

type CommandRunner interface {
	Run(ctx context.Context, name string, args ...string) ([]byte, error)
	RunInput(ctx context.Context, input io.Reader, name string, args ...string) ([]byte, error)
}

type ContentFilterDecision added in v0.7.3

type ContentFilterDecision struct {
	Filtered bool
	Reason   string
	Rule     string
}

func EvaluateContentFilter added in v0.7.3

func EvaluateContentFilter(opts Options, sample *BinaryPrefixSample) ContentFilterDecision

type ExecCommandRunner

type ExecCommandRunner struct{}

func (ExecCommandRunner) Run

func (ExecCommandRunner) Run(ctx context.Context, name string, args ...string) ([]byte, error)

func (ExecCommandRunner) RunInput added in v0.7.2

func (ExecCommandRunner) RunInput(ctx context.Context, input io.Reader, name string, args ...string) ([]byte, error)

type FFProbeFormat

type FFProbeFormat struct {
	Filename       string            `json:"filename"`
	FormatName     string            `json:"format_name"`
	FormatLongName string            `json:"format_long_name"`
	Duration       string            `json:"duration"`
	BitRate        string            `json:"bit_rate"`
	Size           string            `json:"size"`
	ProbeScore     int               `json:"probe_score"`
	Tags           map[string]string `json:"tags"`
}

type FFProbeResult

type FFProbeResult struct {
	Format  FFProbeFormat   `json:"format"`
	Streams []FFProbeStream `json:"streams"`
}

func RunFFProbe

func RunFFProbe(ctx context.Context, runner CommandRunner, ffprobePath, targetPath string) (*FFProbeResult, []byte, error)

func RunFFProbeInput added in v0.7.2

func RunFFProbeInput(ctx context.Context, runner CommandRunner, ffprobePath string, input io.Reader) (*FFProbeResult, []byte, error)

type FFProbeStream

type FFProbeStream struct {
	Index              int               `json:"index"`
	CodecType          string            `json:"codec_type"`
	CodecName          string            `json:"codec_name"`
	CodecLong          string            `json:"codec_long_name"`
	CodecTagString     string            `json:"codec_tag_string"`
	CodecTag           string            `json:"codec_tag"`
	Profile            string            `json:"profile"`
	Width              int               `json:"width"`
	Height             int               `json:"height"`
	Channels           int               `json:"channels"`
	SampleRate         string            `json:"sample_rate"`
	ChannelLayout      string            `json:"channel_layout"`
	SampleFormat       string            `json:"sample_fmt"`
	BitsPerSample      int               `json:"bits_per_sample"`
	PixFmt             string            `json:"pix_fmt"`
	DisplayAspectRatio string            `json:"display_aspect_ratio"`
	RFrameRate         string            `json:"r_frame_rate"`
	AvgFrameRate       string            `json:"avg_frame_rate"`
	Duration           string            `json:"duration"`
	BitRate            string            `json:"bit_rate"`
	Tags               map[string]string `json:"tags"`
	Disposition        struct {
		Default int `json:"default"`
		Forced  int `json:"forced"`
	} `json:"disposition"`
}

type MaterializedBinary

type MaterializedBinary struct {
	File         pgindex.CatalogReleaseFile
	Groups       []string
	Header       *nzb.YencHeader
	OutputPath   string
	BytesWritten int64
	ExactSize    int64
	Signature    string
	MIMEType     string
}

func MaterializeBinaryToWorkspace

func MaterializeBinaryToWorkspace(ctx context.Context, repo CatalogReader, fetcher ArticleFetcher, candidate pgindex.BinaryInspectionCandidate, outputPath string, maxBytes int64) (*MaterializedBinary, error)

type Options

type Options struct {
	WorkDir            string
	WorkspaceBackend   string
	MemoryWorkDir      string
	MaxBytes           int64
	MinBinaryBytes     int64
	MaxBinaryBytes     int64
	BlockedMagicHex    []string
	MaxArchiveDepth    int
	ToolTimeout        time.Duration
	FFProbePath        string
	SevenZipPath       string
	UnrarPath          string
	PAR2Path           string
	CandidateBatchSize int
	Concurrency        int
	ClaimOwner         string
	ClaimLease         time.Duration
}

func DefaultOptions

func DefaultOptions(opts Options) Options

type Runner

type Runner interface {
	RunOnce(ctx context.Context) error
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(log logger, runners map[string]Runner) *Service

func (*Service) RunOnce

func (s *Service) RunOnce(ctx context.Context) error

type Workspace

type Workspace struct {
	Dir               string
	ManifestPath      string
	MaterializedBytes int64
}

func (*Workspace) Cleanup

func (w *Workspace) Cleanup() error

type WorkspaceManager

type WorkspaceManager struct {
	// contains filtered or unexported fields
}

func NewWorkspaceManager

func NewWorkspaceManager(opts Options) *WorkspaceManager

func (*WorkspaceManager) PrepareBinaryWorkspace

func (m *WorkspaceManager) PrepareBinaryWorkspace(ctx context.Context, stageName string, candidate pgindex.BinaryInspectionCandidate) (*Workspace, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL