githubpr

package
v0.0.0-...-c860128 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 9 Imported by: ? 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 githubpr opens a real pull request containing TheKnight's remediation output against a GitHub repository, using the GitHub REST API directly — no local git clone, no shelling out to the git binary. Every file lands in one new commit on one new branch off the target repo's default branch, alongside a PR description summarizing what's being fixed. Nothing here ever pushes to an existing branch or merges anything: opening the PR is the entire scope, same trust boundary as the rest of TheKnight (see the README's Security section) — a human still reviews and merges.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixFilePath

func FixFilePath(f rules.Finding) string

FixFilePath derives a safe repo-relative path for a fix from its finding. AWS-returned identifiers (an IAM role's Resource.ID is a full ARN, slashes and colons included) are run through remediate.SafeIdent — building a file path directly from an unsanitized AWS string is a path-safety problem, not just a display one, the same reasoning that drove the %q-escaping fixes in pkg/remediate's Terraform generation.

Types

type Client

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

Client opens remediation PRs via the GitHub API.

func New

func New(token string) *Client

New builds a Client authenticated with a GitHub personal access token (fine-grained or classic; needs Contents: Read & write and Pull requests: Read & write on the target repo). Deliberately takes the token as a parameter rather than reading an env var itself — the caller (cmd/theknight) owns exactly how it's sourced, and should never accept it as a CLI flag (shell history, process list — same reasoning as AWS credentials never being a --secret-key flag).

func (*Client) CreatePR

func (c *Client) CreatePR(ctx context.Context, owner, repo, baseBranch string, fixes []FileFix) (string, error)

CreatePR opens a pull request against owner/repo containing one file per fix, in a single new commit on a new branch off the repo's default branch (or baseBranch, if non-empty). Returns the PR's HTML URL.

type FileFix

type FileFix struct {
	Path string
	remediate.Fix
	// Briefing is an optional reviewer briefing written by a model and checked
	// against the finding by package explain. Empty means none was produced.
	Briefing string
}

FileFix is a single generated remediation, plus the repo-relative path it should land at.

Jump to

Keyboard shortcuts

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