Skip to main content 首页 创作者 forceinjection domain-driven-design-skills security-compliance-audit
security-compliance-audit Conduct comprehensive security compliance audits for SOC 2, GDPR, HIPAA, PCI-DSS, and ISO 27001. Use when preparing for certification, annual audits, or compliance validation.
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ForceInjection/domain-driven-design-skills --skill security-compliance-audit命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... Conduct deep academic research for philosophy, neuroscience, cognitive science, and theoretical computer science (computability, complexity, AI theory, logic). Use when user asks to: research academic topics, find scholarly papers, conduct literature reviews, analyze citations, synthesize research findings, explore philosophical arguments, investigate consciousness/cognition, study computability/decidability/Turing machines, or analyze academic debates. Triggers on: 'research papers', 'literature review', 'academic sources', 'scholarly articles', 'philosophy of mind', 'computability theory', 'neuroscience studies', 'find papers on', 'what does the research say'.
name security-compliance-audit description Conduct comprehensive security compliance audits for SOC 2, GDPR, HIPAA, PCI-DSS, and ISO 27001. Use when preparing for certification, annual audits, or compliance validation.
Security Compliance Audit
Overview
Systematic evaluation of security controls, policies, and procedures to ensure compliance with industry standards and regulatory requirements.
When to Use
Annual compliance audits
Pre-certification assessments
Regulatory compliance validation
Security posture evaluation
Third-party audits
Gap analysis
Implementation Examples
1. Automated Compliance Checker
from dataclasses import dataclass, field
from typing import List , Dict
from enum import Enum
import json
from datetime import datetime
class ComplianceFramework (Enum ):
SOC2 = "SOC 2"
GDPR = "GDPR"
HIPAA = "HIPAA"
PCI_DSS = "PCI-DSS"
ISO_27001 = "ISO 27001"
class ControlStatus ( ):
COMPLIANT =
NON_COMPLIANT =
PARTIALLY_COMPLIANT =
NOT_APPLICABLE =
:
control_id:
framework: ComplianceFramework
category:
description:
requirement:
status: ControlStatus
evidence: [ ] = field(default_factory= )
findings: [ ] = field(default_factory= )
remediation: =
owner: =
due_date: =
:
( ):
.framework = framework
.controls: [Control] = []
.load_controls()
( ):
.framework == ComplianceFramework.SOC2:
.load_soc2_controls()
.framework == ComplianceFramework.GDPR:
.load_gdpr_controls()
.framework == ComplianceFramework.HIPAA:
.load_hipaa_controls()
.framework == ComplianceFramework.PCI_DSS:
.load_pci_dss_controls()
( ):
soc2_controls = [
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
}
]
ctrl soc2_controls:
.controls.append(Control(
control_id=ctrl[ ],
framework= .framework,
category=ctrl[ ],
description=ctrl[ ],
requirement=ctrl[ ],
status=ControlStatus.NOT_APPLICABLE
))
( ):
gdpr_controls = [
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
}
]
ctrl gdpr_controls:
.controls.append(Control(
control_id=ctrl[ ],
framework= .framework,
category=ctrl[ ],
description=ctrl[ ],
requirement=ctrl[ ],
status=ControlStatus.NOT_APPLICABLE
))
( ):
pci_controls = [
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
}
]
ctrl pci_controls:
.controls.append(Control(
control_id=ctrl[ ],
framework= .framework,
category=ctrl[ ],
description=ctrl[ ],
requirement=ctrl[ ],
status=ControlStatus.NOT_APPLICABLE
))
( ):
hipaa_controls = [
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
},
{
: ,
: ,
: ,
:
}
]
ctrl hipaa_controls:
.controls.append(Control(
control_id=ctrl[ ],
framework= .framework,
category=ctrl[ ],
description=ctrl[ ],
requirement=ctrl[ ],
status=ControlStatus.NOT_APPLICABLE
))
( ):
control .controls:
control.control_id == control_id:
control.status = status
control.evidence = evidence []
control.findings = findings []
control.remediation = remediation
control.owner = owner
control.due_date = due_date
( ) -> :
summary = {
: ,
: ,
: ,
:
}
categories = {}
control .controls:
summary[control.status.value] +=
control.category categories:
categories[control.category] = {
: [],
: ,
:
}
categories[control.category][ ].append({
: control.control_id,
: control.description,
: control.status.value,
: control.findings,
: control.remediation
})
control.status == ControlStatus.COMPLIANT:
categories[control.category][ ] +=
control.status == ControlStatus.NON_COMPLIANT:
categories[control.category][ ] +=
total_assessed = ([c c .controls c.status != ControlStatus.NOT_APPLICABLE])
compliance_rate = (summary[ ] / total_assessed * ) total_assessed >
{
: .framework.value,
: datetime.now().isoformat(),
: summary,
: ,
: categories,
: .get_action_items()
}
( ) -> [ ]:
action_items = []
control .controls:
control.status [ControlStatus.NON_COMPLIANT, ControlStatus.PARTIALLY_COMPLIANT]:
action_items.append({
: control.control_id,
: control.category,
: control.description,
: control.status.value,
: control.findings,
: control.remediation,
: control.owner,
: control.due_date
})
(action_items, key= x: x[ ] == , reverse= )
( ):
report = .generate_report()
(filename, ) f:
json.dump(report, f, indent= )
( )
__name__ == :
auditor = ComplianceAuditor(ComplianceFramework.SOC2)
auditor.assess_control(
,
ControlStatus.COMPLIANT,
evidence=[ , ],
findings=[]
)
auditor.assess_control(
,
ControlStatus.PARTIALLY_COMPLIANT,
evidence=[ ],
findings=[ ],
remediation= ,
owner= ,
due_date=
)
auditor.assess_control(
,
ControlStatus.NON_COMPLIANT,
findings=[ ],
remediation= ,
owner= ,
due_date=
)
report = auditor.generate_report()
( )
( )
( )
( )
( )
( )
( )
item report[ ][: ]:
( )
auditor.export_report( )
Enum
"compliant"
"non_compliant"
"partially_compliant"
"not_applicable"
@dataclass
class
Control
str
str
str
str
List
str
list
List
str
list
str
""
str
""
str
""
class
ComplianceAuditor
def
__init__
self, framework: ComplianceFramework
self
self
List
self
def
load_controls
self
"""Load compliance controls for the framework"""
if
self
self
elif
self
self
elif
self
self
elif
self
self
def
load_soc2_controls
self
"""Load SOC 2 Trust Service Criteria"""
'control_id'
'CC6.1'
'category'
'Logical and Physical Access Controls'
'description'
'Restrict logical access'
'requirement'
'Implement authentication and authorization mechanisms'
'control_id'
'CC6.2'
'category'
'Logical and Physical Access Controls'
'description'
'Use encryption'
'requirement'
'Encrypt data in transit and at rest'
'control_id'
'CC6.6'
'category'
'Logical and Physical Access Controls'
'description'
'Restrict physical access'
'requirement'
'Implement physical access controls'
'control_id'
'CC7.2'
'category'
'System Monitoring'
'description'
'Detect security incidents'
'requirement'
'Implement monitoring and alerting'
'control_id'
'CC7.3'
'category'
'System Monitoring'
'description'
'Evaluate security events'
'requirement'
'Review and analyze security logs'
for
in
self
'control_id'
self
'category'
'description'
'requirement'
def
load_gdpr_controls
self
"""Load GDPR requirements"""
'control_id'
'Art.5'
'category'
'Data Processing Principles'
'description'
'Lawfulness, fairness, and transparency'
'requirement'
'Process data lawfully, fairly, and transparently'
'control_id'
'Art.15'
'category'
'Data Subject Rights'
'description'
'Right of access'
'requirement'
'Provide data subject access to their data'
'control_id'
'Art.17'
'category'
'Data Subject Rights'
'description'
'Right to erasure'
'requirement'
'Implement data deletion capabilities'
'control_id'
'Art.25'
'category'
'Data Protection by Design'
'description'
'Privacy by design and default'
'requirement'
'Implement privacy from the start'
'control_id'
'Art.32'
'category'
'Security of Processing'
'description'
'Security measures'
'requirement'
'Implement appropriate technical and organizational measures'
'control_id'
'Art.33'
'category'
'Data Breach'
'description'
'Breach notification'
'requirement'
'Notify breaches within 72 hours'
for
in
self
'control_id'
self
'category'
'description'
'requirement'
def
load_pci_dss_controls
self
"""Load PCI-DSS requirements"""
'control_id'
'1.1'
'category'
'Build and Maintain Secure Network'
'description'
'Firewall configuration standards'
'requirement'
'Install and maintain firewall configuration'
'control_id'
'3.4'
'category'
'Protect Cardholder Data'
'description'
'Render PAN unreadable'
'requirement'
'Encrypt cardholder data'
'control_id'
'6.5'
'category'
'Maintain Vulnerability Management'
'description'
'Address common vulnerabilities'
'requirement'
'Protect against OWASP Top 10'
'control_id'
'8.2'
'category'
'Implement Strong Access Control'
'description'
'Multi-factor authentication'
'requirement'
'Implement MFA for all users'
'control_id'
'10.2'
'category'
'Regularly Monitor and Test Networks'
'description'
'Audit trails'
'requirement'
'Implement audit logging for all access'
for
in
self
'control_id'
self
'category'
'description'
'requirement'
def
load_hipaa_controls
self
"""Load HIPAA requirements"""
'control_id'
'164.308(a)(1)'
'category'
'Administrative Safeguards'
'description'
'Security management process'
'requirement'
'Implement security management procedures'
'control_id'
'164.312(a)(1)'
'category'
'Technical Safeguards'
'description'
'Access control'
'requirement'
'Implement unique user identification'
'control_id'
'164.312(a)(2)(iv)'
'category'
'Technical Safeguards'
'description'
'Encryption'
'requirement'
'Encrypt ePHI at rest and in transit'
'control_id'
'164.312(b)'
'category'
'Technical Safeguards'
'description'
'Audit controls'
'requirement'
'Implement audit logging mechanisms'
'control_id'
'164.308(a)(6)'
'category'
'Administrative Safeguards'
'description'
'Incident response'
'requirement'
'Implement security incident procedures'
for
in
self
'control_id'
self
'category'
'description'
'requirement'
def
assess_control
self, control_id: str , status: ControlStatus,
evidence: List [str ] = None , findings: List [str ] = None ,
remediation: str = "" , owner: str = "" , due_date: str = ""
"""Assess a specific control"""
for
in
self
if
or
or
break
def
generate_report
self
Dict
"""Generate compliance audit report"""
'compliant'
0
'non_compliant'
0
'partially_compliant'
0
'not_applicable'
0
for
in
self
1
if
not
in
'controls'
'compliant'
0
'non_compliant'
0
'controls'
'control_id'
'description'
'status'
'findings'
'remediation'
if
'compliant'
1
elif
'non_compliant'
1
len
for
in
self
if
'compliant'
100
if
0
else
0
return
'framework'
self
'timestamp'
'summary'
'compliance_rate'
f"{compliance_rate:.2 f} %"
'categories'
'action_items'
self
def
get_action_items
self
List
Dict
"""Get prioritized action items"""
for
in
self
if
in
'control_id'
'category'
'description'
'status'
'findings'
'remediation'
'owner'
'due_date'
return
sorted
lambda
'status'
'non_compliant'
True
def
export_report
self, filename: str
"""Export report to JSON"""
self
with
open
'w'
as
2
print
f"Report exported to {filename} "
if
'__main__'
'CC6.1'
'MFA enabled'
'RBAC implemented'
'CC6.2'
'TLS enabled'
'Data at rest not encrypted'
'Implement database encryption'
'Security Team'
'2024-03-31'
'CC7.2'
'No security monitoring in place'
'Implement SIEM solution'
'Infrastructure Team'
'2024-02-28'
print
f"\n=== {report['framework' ]} Compliance Audit ==="
print
f"Compliance Rate: {report['compliance_rate' ]} "
print
f"\nSummary:"
print
f" Compliant: {report['summary' ]['compliant' ]} "
print
f" Non-Compliant: {report['summary' ]['non_compliant' ]} "
print
f" Partially Compliant: {report['summary' ]['partially_compliant' ]} "
print
f"\nAction Items: {len (report['action_items' ])} "
for
in
'action_items'
5
print
f" - {item['control_id' ]} : {item['description' ]} "
'compliance-audit-report.json'
2. Node.js Compliance Automation
const axios = require ('axios' );
const fs = require ('fs' ).promises ;
class ComplianceAutomation {
constructor ( ) {
this .checks = [];
}
async checkEncryptionAtRest ( ) {
console .log ('Checking encryption at rest...' );
const findings = [];
const dbEncrypted = false ;
if (!dbEncrypted) {
findings.push ('Database encryption not enabled' );
}
return {
control : 'Encryption at Rest' ,
compliant : findings.length === 0 ,
findings
};
}
async checkEncryptionInTransit ( ) {
console .log ('Checking encryption in transit...' );
const findings = [];
const endpoints = ['https://api.example.com' ];
for (const endpoint of endpoints) {
try {
const response = await axios.get (endpoint, {
httpsAgent : new (require ('https' )).Agent ({
rejectUnauthorized : true ,
minVersion : 'TLSv1.2'
})
});
const tls = response.request .socket .getProtocol ();
const cipher = response.request .socket .getCipher ();
if (!tls.includes ('TLSv1.2' ) && !tls.includes ('TLSv1.3' )) {
findings.push (`Weak TLS version: ${tls} ` );
}
if (cipher.name .includes ('DES' ) || cipher.name .includes ('RC4' )) {
findings.push (`Weak cipher: ${cipher.name} ` );
}
} catch (error) {
findings.push (`TLS check failed: ${error.message} ` );
}
}
return {
control : 'Encryption in Transit' ,
compliant : findings.length === 0 ,
findings
};
}
async checkAccessControls ( ) {
console .log ('Checking access controls...' );
const findings = [];
const mfaEnabled = true ;
if (!mfaEnabled) {
findings.push ('MFA not enabled for all users' );
}
const passwordPolicy = {
minLength : 12 ,
requireUppercase : true ,
requireNumbers : true ,
requireSpecial : true
};
if (passwordPolicy.minLength < 12 ) {
findings.push ('Password minimum length less than 12' );
}
return {
control : 'Access Controls' ,
compliant : findings.length === 0 ,
findings
};
}
async checkAuditLogging ( ) {
console .log ('Checking audit logging...' );
const findings = [];
const logRetentionDays = 90 ;
if (logRetentionDays < 90 ) {
findings.push ('Log retention less than 90 days' );
}
const requiredEvents = [
'authentication' ,
'authorization' ,
'data_access' ,
'configuration_changes'
];
const loggedEvents = ['authentication' , 'authorization' ];
const missingEvents = requiredEvents.filter (e => !loggedEvents.includes (e));
if (missingEvents.length > 0 ) {
findings.push (`Missing log events: ${missingEvents.join(', ' )} ` );
}
return {
control : 'Audit Logging' ,
compliant : findings.length === 0 ,
findings
};
}
async runAllChecks ( ) {
this .checks = [
await this .checkEncryptionAtRest (),
await this .checkEncryptionInTransit (),
await this .checkAccessControls (),
await this .checkAuditLogging ()
];
return this .generateReport ();
}
generateReport ( ) {
const compliant = this .checks .filter (c => c.compliant ).length ;
const nonCompliant = this .checks .length - compliant;
const complianceRate = (compliant / this .checks .length ) * 100 ;
return {
timestamp : new Date ().toISOString (),
summary : {
total : this .checks .length ,
compliant,
nonCompliant,
complianceRate : `${complianceRate.toFixed(2 )} %`
},
checks : this .checks
};
}
}
async function main ( ) {
const automation = new ComplianceAutomation ();
const report = await automation.runAllChecks ();
console .log ('\n=== Compliance Report ===' );
console .log (`Compliance Rate: ${report.summary.complianceRate} ` );
console .log (`Compliant: ${report.summary.compliant} /${report.summary.total} ` );
await fs.writeFile ('compliance-report.json' , JSON .stringify (report, null , 2 ));
}
main ().catch (console .error );
Best Practices
✅ DO
Automate compliance checks
Document all controls
Maintain evidence repository
Conduct regular audits
Track remediation progress
Involve stakeholders
Keep policies updated
❌ DON'T
Skip documentation
Ignore findings
Delay remediation
Cherry-pick controls
Forget evidence collection
Compliance Frameworks
SOC 2 : Trust Service Criteria
GDPR : Data protection
HIPAA : Healthcare data
PCI-DSS : Payment card data
ISO 27001 : Information security
NIST : Cybersecurity framework
Resources