utils

package
v0.1.31 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Copyright © 2020 Red Hat Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	OPENSCAP = iota
	OPERATOR
	CONTENT
)

Variables

This section is empty.

Functions

func AnyMcfgPoolLabelMatches added in v0.1.6

func AnyMcfgPoolLabelMatches(nodeSelector map[string]string, poolList *mcfgv1.MachineConfigPoolList) bool

AnyMcfgPoolLabelMatches verifies if the given nodeSelector matches the nodeSelector in any of the given MachineConfigPools

func ComplianceOperatorRootCA

func ComplianceOperatorRootCA(certname string, expire int) ([]byte, []byte, error)

func DNSLengthName added in v0.1.9

func DNSLengthName(hashPrefix string, format string, a ...interface{}) string

func FindNewestPod added in v0.1.15

func FindNewestPod(pods []corev1.Pod) *corev1.Pod

FindNewestPod finds the newest pod in the given set

func GetComponentImage added in v0.1.9

func GetComponentImage(component ComplianceComponent) string

GetComponentImage returns a full image pull spec for a given component based on the component type

func GetFirstNodeRole

func GetFirstNodeRole(nodeSelector map[string]string) string

func GetFirstNodeRoleLabel

func GetFirstNodeRoleLabel(nodeSelector map[string]string) string

func GetNodeRoleSelector

func GetNodeRoleSelector(role string) map[string]string

func GetPathFromWarningXML added in v0.1.31

func GetPathFromWarningXML(in string) string

getPathsFromRuleWarning finds the API endpoint from in. The expected structure is:

<warning category="general" lang="en-US"><code class="ocp-api-endpoint">/apis/config.openshift.io/v1/oauths/cluster
</code></warning>

func GetResultConfigMap added in v0.1.14

func GetResultConfigMap(owner metav1.Object, configMapName, filename, nodeName string, contents io.Reader, compressed bool, exitcode string, warnings string) *corev1.ConfigMap

GetResultConfigMap gets a configmap that reflects a result or an error for a scan

func HaveOutdatedRemediations added in v0.1.12

func HaveOutdatedRemediations(client runtimeclient.Client) (error, bool)

func IsMachineConfig added in v0.1.9

func IsMachineConfig(obj *unstructured.Unstructured) bool

IsMachineConfig checks if the specified object is a MachineConfig object

func LengthName added in v0.1.9

func LengthName(maxLen int, hashPrefix string, format string, a ...interface{}) (string, error)

LengthName creates a string of maximum defined length.

func McfgPoolLabelMatches added in v0.1.6

func McfgPoolLabelMatches(nodeSelector map[string]string, pool *mcfgv1.MachineConfigPool) bool

McfgPoolLabelMatches verifies if the given nodeSelector matches the given MachineConfigPool's nodeSelector

func NewClientCert

func NewClientCert(caCert, caKey []byte, certname string, expire int) ([]byte, []byte, error)

func NewServerCert

func NewServerCert(caCert, caKey []byte, certname string, expire int) ([]byte, []byte, error)

func ParseMachineConfig added in v0.1.9

ParseMachineConfig parses a Machineconfig object from an unstructured object for a specific remediation.

Types

type ComplianceComponent added in v0.1.9

type ComplianceComponent uint

type Directory added in v0.1.13

type Directory struct {
	CreationTime time.Time
	Path         string
}

Directory is a holding struct used to sort directories by time

func NewDirectory added in v0.1.13

func NewDirectory(path string, info os.FileInfo) Directory

type ParseResult added in v0.1.9

type ParseResult struct {
	Id          string
	CheckResult *compv1alpha1.ComplianceCheckResult
	Remediation *compv1alpha1.ComplianceRemediation
}

func ParseResultsFromContentAndXccdf added in v0.1.9

func ParseResultsFromContentAndXccdf(scheme *runtime.Scheme, scanName string, namespace string,
	dsDom *XMLDocument, resultsReader io.Reader) ([]*ParseResult, error)

type ParseResultContext added in v0.1.10

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

ParseResultContext keeps track of items that are consistent across all "sources" in a ComplianceScan as well as items that are inconsistent

func NewParseResultContext added in v0.1.10

func NewParseResultContext() *ParseResultContext

func (*ParseResultContext) AddResults added in v0.1.10

func (prCtx *ParseResultContext) AddResults(source string, parsedResList []*ParseResult)

ParseResultContext.AddResults adds a batch of results coming from the parser and partitions them into either the consistent or the inconsistent list

func (*ParseResultContext) GetConsistentResults added in v0.1.10

func (prCtx *ParseResultContext) GetConsistentResults() []*ParseResultContextItem

type ParseResultContextItem added in v0.1.10

type ParseResultContextItem struct {
	ParseResult

	Annotations map[string]string
	Labels      map[string]string
	// contains filtered or unexported fields
}

ParseResultContextItem wraps ParseResult with some metadata that need to be added to the created k8s object based on the processing result as well as which nodes the result comes from and whether it's been processed during a single loop that processes a single CM yet or not. The sources are used to keep track of which nodes differ from the "canonical" state of the check

type XMLDocument

type XMLDocument struct {
	*xmldom.Document
}

XMLDocument is a wrapper that keeps the interface XML-parser-agnostic

func ParseContent

func ParseContent(dsReader io.Reader) (*XMLDocument, error)

ParseContent parses the DataStream and returns the XML document

Jump to

Keyboard shortcuts

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