system

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationJson        = "application/json"
	OpenRunServiceLocation = "openrun"
)
View Source
const (
	DB_CONNECTION_CONFIG = "db_connection"
)
View Source
const DEFAULT_CONFIG = "openrun.default.toml"
View Source
const Scheme = "http+unix"

Scheme is the URL scheme used for HTTP over UNIX domain sockets.

Variables

View Source
var (
	DB_SQLITE_POSTGRES = []DBType{DB_TYPE_SQLITE, DB_TYPE_POSTGRES}
	DB_SQLITE          = []DBType{DB_TYPE_SQLITE}
	DRIVER_MAP         = map[DBType]string{
		DB_TYPE_SQLITE:   "sqlite",
		DB_TYPE_POSTGRES: "pgx",
	}
)

Functions

func CleanAbsolutePath added in v0.17.0

func CleanAbsolutePath(name string) (string, error)

CleanAbsolutePath returns an absolute, cleaned local filesystem path. If the path exists, symlinks are resolved.

func CleanFilename added in v0.17.0

func CleanFilename(filename string) (string, error)

CleanFilename returns a single filename with no directory components.

As with CleanRelativePath, backslashes are treated as path separators on every platform so that filenames are validated portably. On Windows the result is also checked against reserved device names (NUL, CON, COM1, ...).

func CleanRelativeLocalPath added in v0.17.0

func CleanRelativeLocalPath(name string) (string, error)

CleanRelativeLocalPath returns a platform-local relative path that cannot escape its containing directory. On Windows, filepath.IsLocal additionally rejects reserved device names such as NUL, CON, COM1, etc.

For example, `sub\file.txt` is returned as `sub/file.txt` on Unix and `sub\file.txt` on Windows. Use this when the result is passed to filepath, os, or host commands.

func CleanRelativePath added in v0.17.0

func CleanRelativePath(name string) (string, error)

CleanRelativePath returns a slash-separated relative path that cannot escape its containing directory.

For example, `sub\file.txt` is returned as `sub/file.txt`. Use this for logical paths such as fs.FS names, URL/static paths, metadata paths, and tar header names.

Backslashes in the input are treated as path separators on every platform so that configs authored on Windows or Unix are validated identically. The trade-off is that a legitimate Unix filename containing a backslash will be re-interpreted as a multi-component path; callers that need to preserve such names should not route them through this function.

func FileExists

func FileExists(filename string) bool

func FindExec

func FindExec(name string) string

FindExec looks for the executable in the system PATH and returns its full path. If not found, it checks common Homebrew locations for the executable.

func FuncNow

func FuncNow(dbType DBType) string

func GetClientIP added in v0.17.0

func GetClientIP(r *http.Request, trustedProxies []string) string

GetClientIP returns the caller IP, honoring forwarding headers only when the direct peer is explicitly configured as a trusted proxy.

func GetConnectString

func GetConnectString(pluginContext *types.PluginContext) (string, error)

func GetContextAppId

func GetContextAppId(ctx context.Context) types.AppId

func GetContextGroups added in v0.15.0

func GetContextGroups(ctx context.Context) []string

func GetContextRequestId

func GetContextRequestId(ctx context.Context) string

func GetContextUserId

func GetContextUserId(ctx context.Context) string

func GetContextValue

func GetContextValue(ctx context.Context, key types.ContextKey) string

func GetCustomPerms added in v0.16.26

func GetCustomPerms(ctx context.Context) []string

func GetFuncMap

func GetFuncMap() template.FuncMap

GetFuncMap returns a template.FuncMap that includes all the sprig functions except for env and expandenv.

func GetHostname added in v0.17.0

func GetHostname(host string) string

GetHostname returns the hostname portion of an HTTP host header, handling hostnames, IPv4 addresses, and bracketed or bare IPv6 literals.

func GetRequestContext added in v0.15.14

func GetRequestContext(thread *starlark.Thread) context.Context

func GetRequestGroups added in v0.15.0

func GetRequestGroups(thread *starlark.Thread) []string

func GetRequestScheme added in v0.17.1

func GetRequestScheme(r *http.Request, trustedProxies []string) string

GetRequestScheme returns "https" if the request was received over TLS locally, or if the direct peer is listed in trustedProxies and set X-Forwarded-Proto: https. Otherwise it returns "http". Only the first value of X-Forwarded-Proto is honored and only when the direct peer is a trusted proxy.

func GetRequestUrl added in v0.15.3

func GetRequestUrl(r *http.Request, trustedProxies []string) string

func GetRequestUserId

func GetRequestUserId(thread *starlark.Thread) string

func GetThreadLocalKey

func GetThreadLocalKey(thread *starlark.Thread, key string) string

func HumanDuration added in v0.15.10

func HumanDuration(d time.Duration) string

HumanDuration returns a human readable duration string

func InsertIgnorePrefix

func InsertIgnorePrefix(dbType DBType) string

func InsertIgnoreSuffix

func InsertIgnoreSuffix(dbType DBType) string

func IsAppRBACEnabled added in v0.16.26

func IsAppRBACEnabled(ctx context.Context) bool

func IsGit

func IsGit(url string) bool

IsGit returns true if the sourceURL is a git URL

func IsOrigRequestHTTPS added in v0.17.1

func IsOrigRequestHTTPS(r *http.Request, trustedProxies []string) bool

IsOrigRequestHTTPS reports whether the request is (or originally came in as) HTTPS, honoring X-Forwarded-Proto only when the direct peer is a trusted proxy.

func KillGroup

func KillGroup(process *os.Process) error

KillGroup kills the process group

func LoadClientConfig

func LoadClientConfig(contents string, config *types.ClientConfig) error

LoadClientConfig load a ClientConfig from the given contents

func LoadGlobalConfig

func LoadGlobalConfig(contents string, config *types.GlobalConfig) error

LoadGlobalConfig load a GlobalConfig from the given contents

func LoadProperties

func LoadProperties(filename string) (map[string]string, error)

func LoadServerConfig

func LoadServerConfig(contents string, config *types.ServerConfig) error

LoadServerConfig loads a ServerConfig from the given contents

func MapDataType

func MapDataType(dbType DBType, dataType string) string

func MapServerHost

func MapServerHost(host string) string

func NewClientConfigEmbedded

func NewClientConfigEmbedded() (*types.ClientConfig, error)

NewClientConfigEmbedded reads the embedded toml file and creates a ClientConfig

func NewServerConfigEmbedded

func NewServerConfigEmbedded() (*types.ServerConfig, error)

NewServerConfigEmbedded reads the embedded toml file and creates a ServerConfig

func PathInDir added in v0.17.0

func PathInDir(root, relPath string) (string, error)

PathInDir joins relPath under root after validating that relPath is local.

Because CleanRelativeLocalPath enforces filepath.IsLocal, the resulting joined path is guaranteed to be lexically inside root. This is a lexical guarantee only: it does not resolve symlinks. For symlink-safe access use os.Root from the standard library.

func PathWithinDir added in v0.17.0

func PathWithinDir(root, targetPath string) (bool, error)

PathWithinDir reports whether targetPath is lexically inside root.

This is a purely lexical check: symlinks under root that point outside root are not detected. For symlink-safe access prefer os.Root from the standard library.

func PostgresRebind

func PostgresRebind(q string) string

func RebindQuery

func RebindQuery(dbType DBType, q string) string

func SQLItePragmas

func SQLItePragmas(db *sql.DB) error

func SetProcessGroup

func SetProcessGroup(cmd *exec.Cmd)

SetProcessGroup sets the process group flag for the command

Types

type DBType

type DBType string
const (
	DB_TYPE_SQLITE   DBType = "sqlite"
	DB_TYPE_POSTGRES DBType = "postgres"
)

func CheckConnectString

func CheckConnectString(connStr string, invoker string, supportedDBs []DBType) (DBType, string, error)

func InitDBConnection

func InitDBConnection(connectString string, invoker string, supportedDBs []DBType) (*sql.DB, DBType, error)

type HttpClient

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

func NewHttpClient

func NewHttpClient(serverUri, user, password string, skipCertCheck bool) *HttpClient

NewHttpClient creates a new HttpClient instance

func (*HttpClient) Delete

func (h *HttpClient) Delete(url string, params url.Values, output any) error

func (*HttpClient) Get

func (h *HttpClient) Get(url string, params url.Values, output any) error

func (*HttpClient) Post

func (h *HttpClient) Post(url string, params url.Values, input any, output any) error

type SecretManager

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

SecretManager provides access to the secrets for the system

func NewSecretManager

func NewSecretManager(ctx context.Context, secretConfig map[string]types.SecretConfig, defaultProvider string, serverConfig *types.ServerConfig) (*SecretManager, error)

func (*SecretManager) AppEvalTemplate

func (s *SecretManager) AppEvalTemplate(appSecrets [][]string, defaultProvider, input string) (string, error)

EvalTemplate evaluates the input string and replaces any secret placeholders with the actual secret value

func (*SecretManager) EvalTemplate

func (s *SecretManager) EvalTemplate(input string) (string, error)

EvalTemplate evaluates the input string and replaces any secret placeholders with the actual secret value

type Transport

type Transport struct {
	// DialTimeout is deprecated. Use context instead.
	DialTimeout time.Duration
	// RequestTimeout is deprecated and has no effect.
	RequestTimeout time.Duration
	// ResponseHeaderTimeout is deprecated. Use context instead.
	ResponseHeaderTimeout time.Duration
	// contains filtered or unexported fields
}

Transport is a http.RoundTripper that connects to Unix domain sockets.

func (*Transport) RegisterLocation

func (t *Transport) RegisterLocation(loc string, path string)

RegisterLocation registers an URL location and maps it to the given file system path.

Calling RegisterLocation twice for the same location is a programmer error, and causes a panic.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction. See net/http.RoundTripper.

Jump to

Keyboard shortcuts

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