ticketing

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: GPL-3.0 Imports: 13 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 ticketing holds shared logic for creating issue-tracker tickets (Jira, GitHub Issues, ...) from findings. The secret-redaction routine lives here so every provider scrubs ticket text through ONE implementation and they cannot diverge — a divergence would risk leaking a credential into a ticket that one provider redacts and another does not.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoGitHubIntegration = fmt.Errorf("%w: no connected GitHub integration is configured for this tenant", shared.ErrValidation)

ErrNoGitHubIntegration is returned when the tenant has no connected GitHub integration whose credentials can be used to create issues. It wraps shared.ErrValidation so the HTTP layer maps it to 400.

Functions

func RedactSecrets

func RedactSecrets(text string) string

RedactSecrets scrubs credential-shaped substrings from text before it is embedded in an outbound ticket. It is intentionally provider-agnostic and shared by every ticketing provider. It never returns the original secret.

Types

type GitHubTicketInput

type GitHubTicketInput struct {
	TenantID  string
	FindingID string
	Owner     string
	Repo      string
}

GitHubTicketInput is the payload for auto-creating a GitHub issue from a finding.

type GitHubTicketService

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

GitHubTicketService creates GitHub issues from findings and links them.

This is the GitHub analog of jira.SyncService.CreateTicketFromFinding: resolve the tenant's GitHub integration → load finding → idempotency via work_item_uris → create issue → link the issue URL back onto the finding.

CREATE + link only. Inbound status sync (webhooks) is a documented follow-up; see docs/architecture/github-issue-ticketing.md.

func NewGitHubTicketService

func NewGitHubTicketService(
	findingRepo vulnerability.FindingRepository,
	integrationRepo integration.Repository,
	encryptor crypto.Encryptor,
	log *logger.Logger,
) *GitHubTicketService

NewGitHubTicketService constructs a GitHubTicketService.

The encryptor is used to decrypt the integration's stored credential the same way the SCM integration layer does (IntegrationService.decryptCredentials): encryptor.DecryptString, falling back to the stored value as plaintext when decryption fails. If encryptor is nil, credentials are treated as plaintext.

func (*GitHubTicketService) CreateTicketFromFinding

func (s *GitHubTicketService) CreateTicketFromFinding(ctx context.Context, in GitHubTicketInput) (*TicketInfo, error)

CreateTicketFromFinding creates a GitHub issue from a finding and links it.

func (*GitHubTicketService) HandleIssueEvent

func (s *GitHubTicketService) HandleIssueEvent(ctx context.Context, tenantID shared.ID, issueHTMLURL, action string) error

HandleIssueEvent is the inbound half of GitHub Issues sync: a webhook reporting a linked issue closed/reopened updates the finding's status. Mirrors the Jira inbound path. No-op when the action isn't a state change, no finding is linked to the issue URL, or the resulting transition isn't allowed. Best-effort — errors are returned for logging but a not-found link is a clean nil.

func (*GitHubTicketService) SyncFindingStatus

func (s *GitHubTicketService) SyncFindingStatus(ctx context.Context, tenantID, findingID shared.ID) error

SyncFindingStatus is the outbound half of GitHub Issues sync: when a finding's status changes in OpenCTEM, close (resolved/closed-category) or reopen (active) its linked GitHub issue. No-op when the finding has no linked GitHub issue. Best-effort; enqueued from the same status-change hook as Jira and runs in the background worker.

type TicketInfo

type TicketInfo struct {
	FindingID string    `json:"finding_id"`
	TicketKey string    `json:"ticket_key"`
	TicketURL string    `json:"ticket_url"`
	LinkedAt  time.Time `json:"linked_at"`
}

TicketInfo describes a ticket linked to a finding. Mirrors the Jira SyncService.TicketInfo so the HTTP response shape is identical across providers.

Jump to

Keyboard shortcuts

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