dockerhub

package
v3.88.7 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var (
	PermissionStrings = map[Permission]string{
		RepoRead:       "repo:read",
		RepoWrite:      "repo:write",
		RepoAdmin:      "repo:admin",
		RepoPublicRead: "repo:public_read",
	}

	StringToPermission = map[string]Permission{
		"repo:read":        RepoRead,
		"repo:write":       RepoWrite,
		"repo:admin":       RepoAdmin,
		"repo:public_read": RepoPublicRead,
	}

	PermissionIDs = map[Permission]int{
		RepoRead:       1,
		RepoWrite:      2,
		RepoAdmin:      3,
		RepoPublicRead: 4,
	}

	IdToPermission = map[int]Permission{
		1: RepoRead,
		2: RepoWrite,
		3: RepoAdmin,
		4: RepoPublicRead,
	}
)

Functions

func AnalyzeAndPrintPermissions

func AnalyzeAndPrintPermissions(cfg *config.Config, username, pat string)

Types

type Analyzer

type Analyzer struct {
	Cfg *config.Config
}

func (Analyzer) Analyze

func (a Analyzer) Analyze(_ context.Context, credInfo map[string]string) (*analyzers.AnalyzerResult, error)

func (Analyzer) Type

func (a Analyzer) Type() analyzers.AnalyzerType

type ErrorLoginResponse

type ErrorLoginResponse struct {
	Detail        string `json:"detail"`
	Login2FAToken string `json:"login_2fa_token"` // if login require 2FA authentication
}

ErrorLoginResponse is the error response from the /login API

type LoginResponse

type LoginResponse struct {
	Token string `json:"token"`
}

LoginResponse is the successful response from the /login API

type Permission

type Permission int
const (
	Invalid        Permission = iota
	RepoRead       Permission = iota
	RepoWrite      Permission = iota
	RepoAdmin      Permission = iota
	RepoPublicRead Permission = iota
)

func PermissionFromID

func PermissionFromID(id int) (Permission, error)

PermissionFromID converts an ID to its Permission enum

func PermissionFromString

func PermissionFromString(s string) (Permission, error)

PermissionFromString converts a string representation to its Permission enum

func (Permission) ToID

func (p Permission) ToID() (int, error)

ToID converts a Permission enum to its ID

func (Permission) ToString

func (p Permission) ToString() (string, error)

ToString converts a Permission enum to its string representation

type RepositoriesResponse

type RepositoriesResponse struct {
	Result []struct {
		Name      string `json:"name"`
		Type      string `json:"repository_type"`
		IsPrivate bool   `json:"is_private"`
		StarCount int    `json:"star_count"`
		PullCount int    `json:"pull_count"`
	} `json:"results"`
}

RepositoriesResponse is the /repositories/<namespace> response

type Repository

type Repository struct {
	ID        string
	Name      string
	Type      string
	IsPrivate bool
	StarCount int
	PullCount int
}

Repository hold information about each repository the user can access

type SecretInfo

type SecretInfo struct {
	User         User
	Valid        bool
	Reference    string
	Permissions  []string
	Repositories []Repository
	ExpiresIn    string
	Misc         map[string]string
}

SecretInfo hold the information about the token generated from username and pat

func AnalyzePermissions

func AnalyzePermissions(cfg *config.Config, username, pat string) (*SecretInfo, error)

AnalyzePermissions will collect all the scopes assigned to token along with resource it can access

type User

type User struct {
	ID       string
	Username string
	Email    string
}

User hold the information about user to whom the personal access token belongs

Jump to

Keyboard shortcuts

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