security

package
v1.0.0-rc07 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package security provides security utilities for handling sensitive data, credential masking, secure temporary file operations, and audit logging.

Index

Constants

View Source
const (
	// MaskString is the string used to mask sensitive data
	MaskString = "***REDACTED***"

	// PartialMaskString shows partial information
	PartialMaskString = "***"
)

Variables

This section is empty.

Functions

func MaskEmail

func MaskEmail(email string) string

MaskEmail masks an email address but shows domain

func MaskPartial

func MaskPartial(input string, showChars int) string

MaskPartial masks a string but shows partial information (first and last few chars)

func MaskURL

func MaskURL(url string) string

MaskURL masks sensitive parts of a URL (password in connection strings)

Types

type CredentialMasker

type CredentialMasker interface {
	MaskString(input string) string
	MaskMap(data map[string]interface{}) map[string]interface{}
	MaskError(err error) error
	AddSensitivePattern(pattern string)
	AddSensitiveField(fieldName string)
	IsSensitiveField(fieldName string) bool
}

CredentialMasker interface for masking sensitive data in logs and errors

type DefaultCredentialMasker

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

DefaultCredentialMasker implements CredentialMasker interface

func NewDefaultCredentialMasker

func NewDefaultCredentialMasker() *DefaultCredentialMasker

NewDefaultCredentialMasker creates a new credential masker with default patterns

func (*DefaultCredentialMasker) AddSensitiveField

func (m *DefaultCredentialMasker) AddSensitiveField(fieldName string)

AddSensitiveField adds a custom sensitive field name

func (*DefaultCredentialMasker) AddSensitivePattern

func (m *DefaultCredentialMasker) AddSensitivePattern(pattern string)

AddSensitivePattern adds a custom sensitive pattern

func (*DefaultCredentialMasker) IsSensitiveField

func (m *DefaultCredentialMasker) IsSensitiveField(fieldName string) bool

IsSensitiveField checks if a field name is sensitive

func (*DefaultCredentialMasker) MaskError

func (m *DefaultCredentialMasker) MaskError(err error) error

MaskError masks sensitive data in error messages

func (*DefaultCredentialMasker) MaskMap

func (m *DefaultCredentialMasker) MaskMap(data map[string]interface{}) map[string]interface{}

MaskMap masks sensitive data in a map

func (*DefaultCredentialMasker) MaskString

func (m *DefaultCredentialMasker) MaskString(input string) string

MaskString masks sensitive data in a string

type DefaultSecureTempFileManager

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

DefaultSecureTempFileManager implements SecureTempFileManager interface

func NewDefaultSecureTempFileManager

func NewDefaultSecureTempFileManager() *DefaultSecureTempFileManager

NewDefaultSecureTempFileManager creates a new secure temp file manager

func (*DefaultSecureTempFileManager) CleanupAll

func (m *DefaultSecureTempFileManager) CleanupAll() error

CleanupAll removes all tracked temporary files and directories

func (*DefaultSecureTempFileManager) CleanupTempDir

func (m *DefaultSecureTempFileManager) CleanupTempDir(path string) error

CleanupTempDir securely removes a temporary directory

func (*DefaultSecureTempFileManager) CleanupTempFile

func (m *DefaultSecureTempFileManager) CleanupTempFile(path string) error

CleanupTempFile securely removes a temporary file

func (*DefaultSecureTempFileManager) CreateSecureTempDir

func (m *DefaultSecureTempFileManager) CreateSecureTempDir(pattern string) (string, error)

CreateSecureTempDir creates a secure temporary directory with restricted permissions

func (*DefaultSecureTempFileManager) CreateSecureTempFile

func (m *DefaultSecureTempFileManager) CreateSecureTempFile(pattern string) (*SecureTempFile, error)

CreateSecureTempFile creates a secure temporary file with restricted permissions

type SecureFileWriter

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

SecureFileWriter wraps a file with automatic cleanup

func NewSecureFileWriter

func NewSecureFileWriter(pattern string) (*SecureFileWriter, error)

NewSecureFileWriter creates a new secure file writer

func (*SecureFileWriter) Close

func (w *SecureFileWriter) Close() error

Close closes and cleans up the secure file

func (*SecureFileWriter) GetPath

func (w *SecureFileWriter) GetPath() string

GetPath returns the path of the temporary file

func (*SecureFileWriter) Sync

func (w *SecureFileWriter) Sync() error

Sync syncs the file to disk

func (*SecureFileWriter) Write

func (w *SecureFileWriter) Write(data []byte) (int, error)

Write writes data to the secure file

type SecureTempFile

type SecureTempFile struct {
	File        *os.File
	Path        string
	Permissions os.FileMode
	CreatedAt   time.Time
}

SecureTempFile represents a secure temporary file

func CreateSecureTempFileWithContent

func CreateSecureTempFileWithContent(pattern string, content []byte) (*SecureTempFile, error)

CreateSecureTempFileWithContent creates a secure temp file with initial content

func (*SecureTempFile) Close

func (stf *SecureTempFile) Close() error

Close closes the secure temporary file

func (*SecureTempFile) Remove

func (stf *SecureTempFile) Remove() error

Remove removes the secure temporary file

func (*SecureTempFile) Write

func (stf *SecureTempFile) Write(data []byte) (int, error)

Write writes data to the secure temporary file

type SecureTempFileManager

type SecureTempFileManager interface {
	CreateSecureTempFile(pattern string) (*SecureTempFile, error)
	CreateSecureTempDir(pattern string) (string, error)
	CleanupTempFile(path string) error
	CleanupTempDir(path string) error
	CleanupAll() error
}

SecureTempFileManager interface for secure temporary file operations

Jump to

Keyboard shortcuts

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