policydef

package
v0.0.0-...-3d71f35 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 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 retrieve 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 whether this policy is enabled or not
	IsEnabled(ctx context.Context, c *github.Client, owner, repo string) (bool, error)

	// 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 serializable to json and allow
	// useful log querying.
	Details interface{}
}

Result is returned from a policy check.

Jump to

Keyboard shortcuts

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