{"modulePath":"github.com/codefit-cli/codefit","version":"v0.2.9","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package findings\n\nPackage findings defines the universal, language-agnostic vocabulary of an audit: the [Finding](#Finding) hallazgo, its [Severity](#Severity) and [Dimension](#Dimension), the [ConsentRecord](#ConsentRecord) that authorizes suppressing a critical security finding, and the [SensorResult](#SensorResult) every sensor returns.\n\nThis package is a leaf: it has no dependencies on other codefit packages so that every layer (core, sensors, providers, cli, mcp) can import it without risking an import cycle.\n\n## Functions\n\n```go\nfunc Fingerprint(category, file, content string) string\n```\nFingerprint is the BASELINE identity of a finding or surface item: a short hash of (category, file, normalized content), deliberately WITHOUT the line so it is stable when code moves (e.g. an import added above) and re-detects only when the item's own content changes. The content is hashed, never stored, so a fingerprint of a hardcoded-secret finding can be committed to .codefit-baseline without leaking the secret. Whitespace is normalized so re-indentation does not churn it.\n\n## Types\n\n```go\ntype ConsentRecord struct {\n\tAcceptedBy string `json:\"accepted_by\"`\n\tAcceptedAt string `json:\"accepted_at\"`\n\tReason     string `json:\"reason\"`\n}\n```\nConsentRecord is the committed record that a critical security finding was reviewed and explicitly accepted. It lives in .codefit.yaml as an audit trail.\n\n```go\ntype Dimension string\n```\nDimension is the audit axis a finding belongs to. Each sensor maps to exactly one dimension, and the global score is a weighted average across dimensions.\n\n```go\nconst (\n\tDimensionSecurity   Dimension = \"security\"\n\tDimensionReview     Dimension = \"review\"\n\tDimensionDB         Dimension = \"db\"\n\tDimensionComplexity Dimension = \"complexity\"\n\tDimensionPractices  Dimension = \"practices\"\n\tDimensionTests      Dimension = \"tests\"\n)\n```\n\n```go\ntype Finding struct {\n\tID          string    `json:\"id\"`\n\tDimension   Dimension `json:\"dimension\"`\n\tSeverity    Severity  `json:\"severity\"`\n\tFile        string    `json:\"file,omitempty\"`\n\tLine        int       `json:\"line,omitempty\"`\n\tTitle       string    `json:\"title\"`\n\tDescription string    `json:\"description\"`\n\tSuggestion  string    `json:\"suggestion\"`\n\t// Reasoning explains why the finding was flagged. Only set for findings the\n\t// agent reasoned from mapped surface; it records the agent's rationale so it\n\t// survives beyond the conversation (PRD section 11).\n\tReasoning string `json:\"reasoning,omitempty\"`\n\t// Confidence is 1.0 for deterministic (regex/AST) findings and \u003c 1.0 for\n\t// findings the agent reasoned from surface.\n\tConfidence float64 `json:\"confidence\"`\n\t// Probabilistic is true when the finding comes from the agent's reasoning\n\t// over mapped surface rather than a deterministic match.\n\tProbabilistic bool `json:\"probabilistic\"`\n\t// RequiresConsent is true for critical security findings, which cannot be\n\t// silenced with a plain ignore — they need an explicit ConsentRecord.\n\tRequiresConsent bool `json:\"requires_consent\"`\n\t// Baselined is true when the finding is pre-existing debt recorded in a\n\t// baseline snapshot; baselined findings never trigger the deploy block.\n\tBaselined bool `json:\"baselined,omitempty\"`\n\t// Suppressed, when non-nil, holds the consent under which a finding was\n\t// accepted and silenced.\n\tSuppressed *ConsentRecord `json:\"suppressed,omitempty\"`\n\t// Fingerprint is the content identity used by the baseline (see Fingerprint).\n\t// It is a one-way hash, safe to commit. Empty until stamped at the scan boundary.\n\tFingerprint string `json:\"fingerprint,omitempty\"`\n}\n```\nFinding is a single hallazgo produced by a sensor. The JSON tags define the canonical report contract; consumers (dashboards, CI, MCP clients) depend on it, so changes here are governed by the report's schema\\_version.\n\n```go\ntype SensorResult struct {\n\tSensor   string        `json:\"sensor\"`\n\tScore    int           `json:\"score\"`\n\tFindings []Finding     `json:\"findings\"`\n\tSurface  []SurfaceItem `json:\"surface,omitempty\"`\n\t// AuditableTotal is how many files the walk COULD have audited — every file\n\t// matching the provider's extensions outside a skipped directory, counted\n\t// whether or not the scope let it be analysed. Narrowing must not shrink the\n\t// denominator, or \"3 of 412\" becomes \"3 of 3\" and the narrowing disappears.\n\tAuditableTotal int `json:\"auditable_total\"`\n\t// AuditedFiles are the project-relative paths the walk actually ANALYSED,\n\t// sorted. It is the difference between \"audited and clean\" and \"never\n\t// looked\": a requested path missing from here was never examined.\n\tAuditedFiles []string `json:\"audited_files,omitempty\"`\n\tDurationMs   int64    `json:\"duration_ms\"`\n\tError        string   `json:\"error,omitempty\"`\n}\n```\nSensorResult is what a single sensor returns after a run: its deterministic findings, the surface to be reasoned by the agent, the dimension score, how long it took, and an error string if it failed (kept as a string so partial results survive serialization).\n\nAuditableTotal and AuditedFiles are the sensor's own account of what it looked at, and they exist so a PARTIAL audit cannot pass itself off as a full one. A sensor that WALKS the project reports both; under a full audit they agree. A sensor whose inputs are CONFIGURED rather than walked (the DB dimension) reports the sources it read in AuditedFiles and leaves AuditableTotal zero: there is no file census to be a denominator of, and whether that dimension ran at all is answered by its own measured/not-measured flag.\n\n```go\ntype Severity string\n```\nSeverity ranks how serious a finding is. Higher severities can block a deploy (see the report's blocked field and the --fail-on flag).\n\n```go\nconst (\n\tSeverityCritical Severity = \"critical\"\n\tSeverityHigh     Severity = \"high\"\n\tSeverityMedium   Severity = \"medium\"\n\tSeverityLow      Severity = \"low\"\n\tSeverityInfo     Severity = \"info\"\n)\n```\n\n```go\ntype SurfaceItem struct {\n\t// ID is a stable anchor derived from (file, line, category) — see\n\t// core/surface.StableID. The agent returns it in a verdict, and codefit\n\t// recomputes it to validate the verdict statelessly.\n\tID string `json:\"id\"`\n\t// Category is the surface class: \"idor\" | \"authz\" | \"overfetch\" | ...\n\tCategory string `json:\"category\"`\n\tFile     string `json:\"file\"`\n\tLine     int    `json:\"line\"`\n\t// Snippet is the relevant source fragment for the agent to read.\n\tSnippet string `json:\"snippet\"`\n\t// StructuralSignals are verifiable syntactic FACTS about the item (\"reads\n\t// params.id\", \"no call to a known authz helper was detected in the body\"),\n\t// never judgments (\"is vulnerable\", \"missing authorization\"). They are what\n\t// the agent reasons over.\n\tStructuralSignals []string `json:\"structural_signals\"`\n\t// StructuralFacts is the queryable form of the same facts: boolean detections\n\t// a consumer can filter/sort by without parsing prose (e.g. authz →\n\t// \"known_authz_detected\", idor → \"local_access_detected\"). They are FACTS\n\t// (\"a known pattern was/wasn't detected\"), never judgments and never severity:\n\t// known_authz_detected=false means \"no known authz pattern was seen\", NOT \"this\n\t// is unauthorized\". Ordering by a fact is allowed; concluding from it is the\n\t// agent's.\n\tStructuralFacts map[string]bool `json:\"structural_facts\"`\n\t// IndirectCall names the external function a handler delegates to when the\n\t// resource access is NOT local to the body (e.g. an Express controller calling\n\t// a service that owns the Prisma query). It is paired with the structural fact\n\t// indirect_access=true. codefit does NOT follow the call across files — it\n\t// names the callee so the agent can reason about where the access happens\n\t// (cross-file option C). Empty when the access is local.\n\tIndirectCall string `json:\"indirect_call,omitempty\"`\n\t// ReasonToReview is the QUESTION the agent must answer about this item, never\n\t// a conclusion.\n\tReasonToReview string `json:\"reason_to_review\"`\n\t// Fingerprint is the content identity used by the baseline (see Fingerprint).\n\t// Empty until stamped at the scan boundary.\n\tFingerprint string `json:\"fingerprint,omitempty\"`\n}\n```\nSurfaceItem is one element of the auditable surface a sensor enumerates for the agent to reason about (PRD section 10). codefit does not decide whether a surface item is vulnerable — it maps the complete structural surface of a category (IDOR endpoints, protectable handlers, data serializations, ...) so the agent reasons over each with its own LLM, with no blind spots.\n\n","path":"github.com/codefit-cli/codefit/internal/core/findings","name":"findings","synopsis":"Package findings defines the universal, language-agnostic vocabulary of an audit: the Finding hallazgo, its Severity and Dimension, the ConsentRecord that authorizes suppressing a critical security finding, and the SensorResult every sensor returns.","isRedistributable":true}
