policydef

package
Version: v0.0.0-...-005854d Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package policydef defines the interface that policies must implement to be included in Allstar.

Policies should define and retrieve their own config in the same way that Allstar does. There should be an org-level config and repo-level config. Each config should include the OptConfig defined in github.com/ossf/allstar/pkg/config to determine if the policy is enabled or disabled. The config package also provided helper functions to retreive config from the repo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy interface {

	// Name must return the human readable name of the policy.
	Name() string

	// Check checks whether the provided repo is in compliance with the policy or
	// not. It must use the provided context and github client. See Result for
	// more details on the return value.
	Check(ctx context.Context, c *github.Client, owner, repo string) (*Result, error)

	// Fix should modify the provided repo to be in compliance with the
	// policy. The provided github client must be used to either edit repo
	// settings or modify files. Fix is optional and the policy may simply
	// return.
	Fix(ctx context.Context, c *github.Client, owner, repo string) error

	// GetAction must return the configured action from the policy's config. No
	// validation is needed by the policy, it will be done centrally.
	GetAction(ctx context.Context, c *github.Client, owner, repo string) string
}

Policy is the interface that policies must implement to be included in Allstar.

type Result

type Result struct {
	// Enabled is whether the policy is enabled or not.
	Enabled bool

	// Pass is whether the policy passes or not.
	Pass bool

	// NotifyText is the human readable message to provide to the user if the
	// configured action is a notify action (issue, email, rpc). It should inform
	// the user of the problem and how to fix it.
	NotifyText string

	// Details are logged on failure. it should be serailizable to json and allow
	// useful log querying.
	Details interface{}
}

Result is returned from a policy check.

Source Files

Jump to

Keyboard shortcuts

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