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