compliance

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComplianceChecker

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

ComplianceChecker checks compliance status for various frameworks

Example

Example demonstrates how to use the compliance checker

// Create system info with current security configuration
info := SystemInfo{
	EncryptionEnabled:     true,
	TLSEnabled:            true,
	AuditLoggingEnabled:   true,
	DataMaskingEnabled:    true,
	KeyRotationEnabled:    true,
	AuthenticationEnabled: true,
	AccessControlEnabled:  true,
}

// Create compliance checker
checker := NewComplianceChecker(info)

// Check GDPR compliance
report, err := checker.CheckCompliance(FrameworkGDPR)
if err != nil {
	fmt.Printf("Error: %v\n", err)
	return
}

// Print summary
fmt.Printf("Framework: %s\n", report.Framework)
fmt.Printf("Total Controls: %d\n", report.Summary.TotalControls)
fmt.Printf("Compliant: %d\n", report.Summary.CompliantControls)
fmt.Printf("Compliance Score: %.1f%%\n", report.Summary.ComplianceScore)

// Export to different formats
checker.ExportReport(report, "json", os.Stdout)
checker.ExportReport(report, "text", os.Stdout)
checker.ExportReport(report, "markdown", os.Stdout)
Example (ControlEvaluation)

Example demonstrates control evaluation

info := SystemInfo{
	EncryptionEnabled:     true,
	TLSEnabled:            false, // TLS not enabled
	AuditLoggingEnabled:   true,
	DataMaskingEnabled:    true,
	KeyRotationEnabled:    true,
	AuthenticationEnabled: true,
	AccessControlEnabled:  true,
}

checker := NewComplianceChecker(info)
report, _ := checker.CheckCompliance(FrameworkSOC2)

// Show control statuses
for _, control := range report.Controls {
	fmt.Printf("%s: %s\n", control.ID, control.Status)
	if len(control.Evidence) > 0 {
		fmt.Printf("  Evidence: %s\n", control.Evidence[0].Description)
	}
	if control.Notes != "" {
		fmt.Printf("  Notes: %s\n", control.Notes)
	}
}
Example (MultiFramework)

Example demonstrates checking multiple frameworks

info := SystemInfo{
	EncryptionEnabled:     true,
	TLSEnabled:            true,
	AuditLoggingEnabled:   true,
	DataMaskingEnabled:    false, // Not all features enabled
	KeyRotationEnabled:    true,
	AuthenticationEnabled: true,
	AccessControlEnabled:  true,
}

checker := NewComplianceChecker(info)

// Check all frameworks
frameworks := []Framework{
	FrameworkGDPR,
	FrameworkSOC2,
	FrameworkHIPAA,
	FrameworkPCIDSS,
}

for _, framework := range frameworks {
	report, err := checker.CheckCompliance(framework)
	if err != nil {
		continue
	}

	fmt.Printf("\n%s Compliance: %.1f%%\n", framework, report.Summary.ComplianceScore)
}

func NewComplianceChecker

func NewComplianceChecker(info SystemInfo) *ComplianceChecker

NewComplianceChecker creates a new compliance checker

func (*ComplianceChecker) CheckCompliance

func (c *ComplianceChecker) CheckCompliance(framework Framework) (*ComplianceReport, error)

CheckCompliance evaluates compliance for a specific framework

func (*ComplianceChecker) ExportReport

func (c *ComplianceChecker) ExportReport(report *ComplianceReport, format string, writer io.Writer) error

ExportReport exports the compliance report in various formats

func (*ComplianceChecker) GetControlCount

func (c *ComplianceChecker) GetControlCount(framework Framework) int

GetControlCount returns the number of controls for a framework

type ComplianceReport

type ComplianceReport struct {
	Framework    Framework         `json:"framework"`
	GeneratedAt  time.Time         `json:"generated_at"`
	Version      string            `json:"version"`
	Organization string            `json:"organization"`
	Controls     []Control         `json:"controls"`
	Summary      ComplianceSummary `json:"summary"`
}

ComplianceReport represents a comprehensive compliance report

type ComplianceStatus

type ComplianceStatus string

ComplianceStatus represents the status of a control

const (
	StatusCompliant     ComplianceStatus = "compliant"
	StatusPartial       ComplianceStatus = "partial"
	StatusNonCompliant  ComplianceStatus = "non_compliant"
	StatusNotApplicable ComplianceStatus = "not_applicable"
)

type ComplianceSummary

type ComplianceSummary struct {
	TotalControls        int     `json:"total_controls"`
	CompliantControls    int     `json:"compliant_controls"`
	PartialControls      int     `json:"partial_controls"`
	NonCompliantControls int     `json:"non_compliant_controls"`
	NotApplicable        int     `json:"not_applicable"`
	ComplianceScore      float64 `json:"compliance_score"` // 0-100%
}

ComplianceSummary provides an overview of compliance status

type Control

type Control struct {
	ID          string           `json:"id"`
	Framework   Framework        `json:"framework"`
	Title       string           `json:"title"`
	Description string           `json:"description"`
	Status      ComplianceStatus `json:"status"`
	Evidence    []Evidence       `json:"evidence,omitempty"`
	Notes       string           `json:"notes,omitempty"`
	LastChecked time.Time        `json:"last_checked"`
}

Control represents a single compliance control

type Evidence

type Evidence struct {
	Type        string    `json:"type"`
	Description string    `json:"description"`
	Source      string    `json:"source"`
	Timestamp   time.Time `json:"timestamp"`
	Data        string    `json:"data,omitempty"`
}

Evidence represents evidence of compliance

type Framework

type Framework string

Framework represents a compliance framework

const (
	FrameworkGDPR     Framework = "GDPR"
	FrameworkSOC2     Framework = "SOC2"
	FrameworkHIPAA    Framework = "HIPAA"
	FrameworkPCIDSS   Framework = "PCI-DSS"
	FrameworkFIPS1402 Framework = "FIPS-140-2"
	FrameworkISO27001 Framework = "ISO-27001"
)

func GetFrameworks

func GetFrameworks() []Framework

GetFrameworks returns all supported frameworks

type SystemInfo

type SystemInfo struct {
	EncryptionEnabled     bool
	TLSEnabled            bool
	AuditLoggingEnabled   bool
	DataMaskingEnabled    bool
	KeyRotationEnabled    bool
	AuthenticationEnabled bool
	AccessControlEnabled  bool
}

SystemInfo holds information about the system being checked

Jump to

Keyboard shortcuts

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