utils

package
v0.0.0-...-ba0629f Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package utils defines shared methods in package signing component

Index

Constants

This section is empty.

Variables

View Source
var (
	YumConf = "/etc/yum.conf"
	YumRepo = "/etc/yum.repos.d/"
)

Not const for testing purpose

Functions

func CompareRepoPerKeys

func CompareRepoPerKeys(a, b map[string][]Repository) []string

CompareRepoPerKeys is a method used on tests

func GetLinuxGlobalSigningPolicies

func GetLinuxGlobalSigningPolicies(logger log.Component) (bool, bool)

GetLinuxGlobalSigningPolicies returns: * if package signing is enabled on the host * if repository signing is enabled on the

func GetPackageManager

func GetPackageManager() string

GetPackageManager is a lazy implementation to detect if we use APT or YUM (RH or SUSE)

func GetRepoPathFromPkgManager

func GetRepoPathFromPkgManager(pkgManager string) (string, string)

GetRepoPathFromPkgManager returns the path to the configuration file and the path to the repository files for RH or SUSE based OS

func IsPackageSigningEnabled

func IsPackageSigningEnabled() (bool, error)

IsPackageSigningEnabled returns the signature policy for the host. When no-debsig is written (and uncommented) in the configuration it means GPG package signing verification is disabled

Types

type MainData

type MainData struct {
	Gpgcheck         bool
	LocalpkgGpgcheck bool
	RepoGpgcheck     bool
}

MainData contains the global definitions of gpg checks

func ParseRPMRepoFile

func ParseRPMRepoFile(inputFile string, mainConf MainData) (MainData, map[string][]Repository, error)

ParseRPMRepoFile extracts information from yum repo files Save the global gpgcheck value when encountering a [main] table (should only occur on `/etc/yum.conf`) Match several entries in gpgkey field, either file references (file://) or http(s)://. From observations, these reference can be separated either by space or by new line. We assume it possible to mix file and http references

type Repository

type Repository struct {
	Name         string `json:"name"`
	Enabled      bool   `json:"enabled"`
	GPGCheck     bool   `json:"gpgcheck"`
	RepoGPGCheck bool   `json:"repo_gpgcheck"`
}

Repository is a struct to store the repo name

Jump to

Keyboard shortcuts

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