hybrid

package
v0.7.42 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package hybrid looks up a run's risky inputs on CrowdStrike's Hybrid Analysis by SHA-256 alone. The CLI process asks, never a container, and nothing of a file but its hash leaves the machine: the one call is GET /api/v2/overview/{sha256}, and no submission route is ever called. What the service answers is reduced to a fixed vocabulary: malicious refuses the run, suspicious is noted with its threat score, anything else and an unseen hash are clean. A lookup that cannot answer is recorded and does not stop the run.

Index

Constants

View Source
const DefaultBase = "https://hybrid-analysis.com"

DefaultBase is Hybrid Analysis's origin.

View Source
const (
	// MaxWait is the most a run waits in all on rate limits before the
	// rest of its lookups are not checked, quota.
	MaxWait = time.Minute
)

The bounds on one lookup.

Variables

This section is empty.

Functions

func Key

func Key(pol *policy.Policy) (string, error)

Key is the Hybrid Analysis key as the runner policy says to read it: the variable its hybridAnalysis block names (HYBRID_API_KEY by default, where a sandbox host hands the platform's key), else, with apiKeySource keyring, the OS keychain entry provider:hybrid-analysis. "" is no key; an error is a keychain the policy names that could not be read.

func Risky

func Risky(mime, p string) bool

Risky says whether a file of this detected type, at this report path, is looked up. Everything else is never sent.

func ValidSHA256

func ValidSHA256(s string) bool

ValidSHA256 says whether s is a lower-case hex SHA-256.

Types

type Client

type Client struct {
	Key  string
	Base string
	HTTP *http.Client
	// contains filtered or unexported fields
}

Client asks Hybrid Analysis with one key. A nil Client, or one with no key, asks nothing and answers every hash not checked, no key.

func FromPolicy

func FromPolicy(pol *policy.Policy) (*Client, error)

FromPolicy is the client a run looks up with: the policy's key, or none, which asks nothing and says so.

func (*Client) Look

func (c *Client) Look(ctx context.Context, hashes []string) map[string]Result

Look asks for each distinct hash once, in order, and answers every one. A rate limit waits, up to MaxWait in all; past that, a refused key, an outage or an answer that is not the overview's ends the lookups, and the hash and those after it are not checked, with the reason. A string that is not a SHA-256 is never asked and is not checked, unavailable.

type Outcome

type Outcome string

Outcome is what the lookup made of one hash, in the receipt's words.

const (
	Clean      Outcome = "clean"
	Noted      Outcome = "noted"
	Refused    Outcome = "refused"
	NotChecked Outcome = "not checked"
)

The outcomes.

type Reason

type Reason string

Reason is why a hash was not checked.

const (
	ReasonNoKey       Reason = "no key"
	ReasonQuota       Reason = "quota"
	ReasonUnavailable Reason = "unavailable"
	ReasonKeyRefused  Reason = "the key was refused"
	// ReasonNoDigest: the decode gave a risky file no digest, so it was
	// not asked about.
	ReasonNoDigest Reason = "no digest"
)

The reasons.

type Result

type Result struct {
	Outcome     Outcome
	Reason      Reason
	ThreatScore int
}

Result is one hash's lookup. ThreatScore is the service's 0–100 score for a noted or refused hash, 0 when it gave none.

func (Result) String

func (r Result) String() string

String is the result in the receipt's words. The verdict is named from the outcome, never echoed from the service's answer.

func (Result) Verdict

func (r Result) Verdict() string

Verdict names a noted or refused hash's verdict and threat score, as "malicious, threat score 100"; empty for any other outcome.

func (Result) VerdictWord

func (r Result) VerdictWord() string

VerdictWord is the verdict alone, "malicious" or "suspicious", from the outcome and never from the service's answer; empty for any other.

Jump to

Keyboard shortcuts

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