jira

package
v0.0.0-...-a02776c Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jira ships idempotent finding → Jira-issue sync. Sprint 14 (Phase 5.2): create one Jira issue per finding above a severity floor; auto-resolve when a finding stops appearing in subsequent scans. Each issue carries a `fendix-id:<finding.ID>` label as the idempotency key.

Like notify (Sprint 15), the package is designed as a library + CLI subcommand so it ships without waiting on Sprint 07 (`fendix serve`). The serve-mode hook from the brief is a future caller, not a prerequisite.

Config is read from environment variables (12-factor):

FENDIX_JIRA_URL          https://your-org.atlassian.net
FENDIX_JIRA_PROJECT_KEY  e.g. "SEC"
FENDIX_JIRA_EMAIL        Jira account email
FENDIX_JIRA_API_TOKEN    Jira API token
FENDIX_JIRA_MIN_SEVERITY CRITICAL | HIGH | MEDIUM | LOW | INFO
                         Default: HIGH.
FENDIX_JIRA_ISSUE_TYPE   Default: "Bug". Some Jira projects use
                         "Task" or "Vulnerability".

Auth is HTTP Basic with `email:api_token` per Atlassian's docs.

Index

Constants

View Source
const (
	EnvURL         = "FENDIX_JIRA_URL"
	EnvProjectKey  = "FENDIX_JIRA_PROJECT_KEY"
	EnvEmail       = "FENDIX_JIRA_EMAIL"
	EnvAPIToken    = "FENDIX_JIRA_API_TOKEN"
	EnvMinSeverity = "FENDIX_JIRA_MIN_SEVERITY"
	EnvIssueType   = "FENDIX_JIRA_ISSUE_TYPE"
)

Environment variable names. Kept in one place so the CLI --help can reference them without divergence.

Variables

View Source
var ErrEmptyConfig = errors.New("jira: BaseURL, ProjectKey, Email, and APIToken are all required")

ErrEmptyConfig signals at least one required field on Config is unset. Callers errors.Is-check it to distinguish "user didn't configure Jira" from a transport error.

View Source
var ErrUnsafeFindingID = errors.New("jira: finding ID contains characters not permitted in a Jira label (allowed: A-Z a-z 0-9 . _ -)")

ErrUnsafeFindingID is returned when a finding ID contains characters that would break the JQL idempotency search or split into multiple Jira labels (which silently breaks idempotency — every sync run creates a fresh duplicate issue). Allowed characters: A-Z a-z 0-9 . _ -

Functions

This section is empty.

Types

type Client

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

Client is the API surface callers use. Construct via NewClient.

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient validates cfg and returns a ready-to-use Client. Returns ErrEmptyConfig if BaseURL / Email / APIToken / ProjectKey are missing — these are required and not user-overridable to a reasonable default.

func NewFromEnv

func NewFromEnv() (*Client, error)

NewFromEnv populates Config from environment variables and returns a ready Client. Used by the `fendix jira` CLI subcommand.

func (*Client) SyncFindings

func (c *Client) SyncFindings(ctx context.Context, findings []models.Finding) (SyncResult, error)

SyncFindings is the package's main entry point. It iterates findings ≥ MinSeverity and ensures one Jira issue exists per finding (idempotency via the label `fendix-id:<id>`).

Auto-resolution (transition issues to Done when the finding stops appearing) is a follow-up — Sprint 14.5 — because it requires querying all existing fendix-labelled issues, which depends on a stable persistence story (Sprint 07.5 SQLite) to know "this scan is the latest." See PLAN.md decision gate D1.

Finding IDs are validated against [A-Za-z0-9._-]+ at this boundary — once, here — so neither findExisting nor createIssue can ever see an ID that would inject JQL or split-on-whitespace into multiple Jira labels. Both helpers assert the invariant defensively; any future caller bypassing SyncFindings will get an immediate ErrUnsafeFindingID instead of a silent idempotency break.

type Config

type Config struct {
	BaseURL     string // e.g. https://your-org.atlassian.net
	ProjectKey  string // e.g. SEC
	Email       string
	APIToken    string
	IssueType   string          // default "Bug"
	MinSeverity models.Severity // default HIGH
	HTTPClient  *http.Client    // default 30s timeout
	Now         func() time.Time
}

Config carries the per-process Jira credentials. Use NewFromEnv to populate from env vars; or build it directly in tests.

func (Config) GoString

func (c Config) GoString() string

func (Config) String

func (c Config) String() string

String redacts the API token so accidental `%+v` / log dumps of Config don't leak credentials. GoString covers the `%#v` verb.

type SyncError

type SyncError struct {
	FindingID string
	Phase     string // "search" | "create" | "transition"
	Err       error
}

SyncError is one finding's failure mode. The caller can log per-error; SyncFindings returns nil when the whole sync was transport-OK even if individual ops failed.

func (SyncError) Error

func (e SyncError) Error() string

type SyncResult

type SyncResult struct {
	Created   []string    // Jira issue keys created this run
	Resolved  []string    // Jira issue keys transitioned to Done
	Unchanged []string    // Jira issue keys that already matched the scan state
	Skipped   []string    // Finding IDs below MinSeverity
	Errors    []SyncError // per-operation errors; sync continues past each
}

SyncResult summarises a sync run.

Jump to

Keyboard shortcuts

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