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 ¶
- Variables
- func RedactSecrets(text string) string
- type GitHubTicketInput
- type GitHubTicketService
- func (s *GitHubTicketService) CreateTicketFromFinding(ctx context.Context, in GitHubTicketInput) (*TicketInfo, error)
- func (s *GitHubTicketService) HandleIssueEvent(ctx context.Context, tenantID shared.ID, issueHTMLURL, action string) error
- func (s *GitHubTicketService) SyncFindingStatus(ctx context.Context, tenantID, findingID shared.ID) error
- type TicketInfo
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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.