rules

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 5 Imported by: 0

Documentation

Overview

Package rules maintains established validation for shared aspects relating to either Jacamar specifically or the ECP CI effort as a whole. All checks that have been defined realize the validator.Func interface for the github.com/go-playground/validator/v10 and are meant to be a component in any validation strategy.

Example code:

     type Header struct {
     	Alg string `json:"alg" validate:"len=5,alphanum"`
	        Kid string `json:"kid" validate:"kid"`
	        Typ string `json:"typ" validate:"eq=JWT"`
     }

     func Assert(h Header) error {
         v := validator.New()
	        _ = v.RegisterValidation("kid", rules.CheckKID)
         return v.Struct(h)
     }

When using any rules within this package ensure that the desired value is optional or required. Many rules established are labeled as optional, meaning the lack of an expected value is acceptable. In these cases combining rules others found in validator package may be required. Additionally, always check the expected value type outlined in the function documentation. Type conversations are not handled and strict expectation are required to avoid failures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAuthToken

func CheckAuthToken(v validator.FieldLevel) bool

CheckAuthToken optionally ensures a valid generic authorization token has been supplied that contains no potentially malicious characters and generic maximum header length. Implements validator.Func for String types only.

func CheckDirectory added in v0.7.0

func CheckDirectory(v validator.FieldLevel) bool

CheckDirectory verifies the validity of an expected Unix path without checking for its existence on the system. Non-absolute paths are allowed. Implements validator.Func for String types only.

func CheckGitLabToken

func CheckGitLabToken(v validator.FieldLevel) bool

CheckGitLabToken optionally ensures a potential GitLab job/personal/deploy token is present and potentially invalid web characters are not included. The length of the token is not guaranteed to correctly match all potentially token types. Implements validator.Func for String types only.

func CheckJWT added in v0.4.1

func CheckJWT(v validator.FieldLevel) bool

CheckJWT provide basic check of characters found in a valid JSON Web Token, implements validator.Func.

func CheckKID

func CheckKID(v validator.FieldLevel) bool

CheckKID ensures a valid Key ID in a JWT header, implement validator.Func for string type.

func CheckPipelineSource added in v0.8.0

func CheckPipelineSource(v validator.FieldLevel) bool

CheckPipelineSource verifies the structure of a CI_PIPELINE_SOURCE string and no potentially illegal characters. The string itself is not checked ot ensure it is recognized as a source. Implements validator.Func for String types only.

func CheckProjectPath

func CheckProjectPath(v validator.FieldLevel) bool

CheckProjectPath ensures the values adheres to expectations of a GitLab group/project., implements validator.Func. Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'.

func CheckQualifiedDirectory added in v0.9.0

func CheckQualifiedDirectory(v validator.FieldLevel) bool

CheckQualifiedDirectory verifies the validity of an expected Unix path without checking for its existence on the system. Absolute and fully qualified (filepath.Clean should not be required by provided value) is required. Implements validator.Func for String types only.

func CheckSHA256

func CheckSHA256(v validator.FieldLevel) bool

CheckSHA256 ensures the string matches the structure of a SHA256 checksum, implements validator.Func for string type.

func CheckUnexpandedDirectory added in v0.9.0

func CheckUnexpandedDirectory(v validator.FieldLevel) bool

CheckUnexpandedDirectory identify if a valid directory is found with potentially un-expanded keys allowed, without checking for its existence on the system or required it be fully qualified. Implements validator.Func for String types only.

func CheckUsername

func CheckUsername(v validator.FieldLevel) bool

CheckUsername optionally examines the provided username for validity based upon the GitLab server requirements while observing potentially egregious unix characters. Implements validator.Func for String types only.

Types

This section is empty.

Jump to

Keyboard shortcuts

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