소스 정보
- 저장소
- tools-only/X-Skills
- 최근 소스 활동
- 2026년 2월 9일 04:32
- 감지된 SKILL.md 언어
- 영어
- 스타
- 7
- 포크
- 1
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/tools-only/X-Skills --skill security-scan명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
SOC 직업 분류 기준
| name | security-scan |
| description | Comprehensive database security scanner with OWASP compliance checks,... |
| shortcut | secu |
Implement production-grade database security scanning for PostgreSQL and MySQL that detects 50+ security vulnerabilities including weak passwords, excessive permissions, SQL injection vectors, missing encryption, exposed ports, and insecure configurations. Provides OWASP Database Security compliance reports, automated remediation scripts, and continuous security monitoring with SOC2/HIPAA/PCI DSS audit trails.
Use /security-scan when you need to:
DON'T use this when:
This command implements comprehensive multi-layer security scanning because:
Alternative considered: Manual security checklist
Alternative considered: Commercial security tools (Tenable, Qualys)
Before running this command:
Ensure connection has permissions to query user roles, grants, and configurations.
Check authentication, authorization, encryption, auditing, and network security.
Categorize vulnerabilities by severity (critical, high, medium, low).
Create SQL scripts to fix identified issues with rollback procedures.
Apply fixes in staging, validate, then re-scan to confirm remediation.
The command generates:
security_report.md - Human-readable security audit report with severity ratingsvulnerabilities.json - Machine-readable findings for CI/CD integrationremediation.sql - SQL script to fix identified vulnerabilitiescompliance_matrix.xlsx - Mapping to SOC2/HIPAA/PCI DSS controlssecurity_baseline.yml - Configuration baseline for future scans#!/usr/bin/env python3
"""
Production-ready PostgreSQL security scanner implementing OWASP
Database Security Project checks with automated remediation.
"""
import psycopg2
from psycopg2.extras import RealDictCursor
from typing import List, Dict, Optional
from dataclasses import dataclass
from enum import Enum
import json
import logging
from datetime import datetime
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class Severity(Enum):
"""Vulnerability severity levels."""
CRITICAL = "critical"
HIGH = "high"
MEDIUM = "medium"
LOW = "low"
INFO = "info"
@dataclass
class SecurityFinding:
"""Represents a security vulnerability finding."""
check_id: str
title: str
severity: Severity
description: str
affected_objects: List[str]
remediation: str
owasp_category: str
compliance_mappings: Dict[str, str]
class PostgreSQLSecurityScanner:
"""
Comprehensive PostgreSQL security scanner with OWASP compliance.
"""
def ():
.conn_string = conn_string
.findings: [SecurityFinding] = []
() -> [SecurityFinding]:
logger.info()
psycopg2.connect(.conn_string) conn:
._check_weak_passwords(conn)
._check_excessive_permissions(conn)
._check_superuser_roles(conn)
._check_public_schema_permissions(conn)
._check_ssl_encryption(conn)
._check_password_encryption(conn)
._check_data_encryption_at_rest(conn)
._check_audit_logging(conn)
._check_connection_logging(conn)
._check_statement_logging(conn)
._check_listen_addresses(conn)
._check_pg_hba_configuration(conn)
._check_dynamic_sql(conn)
._check_untrusted_extensions(conn)
._check_insecure_settings(conn)
._check_default_configurations(conn)
logger.info()
.findings
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
weak_roles = [row[] row cur.fetchall()]
weak_roles:
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.CRITICAL,
description=,
affected_objects=weak_roles,
remediation=,
owasp_category=,
compliance_mappings={
: ,
: ,
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
excessive_grants = cur.fetchall()
excessive_grants:
affected = [
row excessive_grants
]
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.HIGH,
description=,
affected_objects=affected,
remediation=,
owasp_category=,
compliance_mappings={
: ,
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
superusers = [row[] row cur.fetchall()]
(superusers) > :
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.HIGH,
description=,
affected_objects=superusers,
remediation=,
owasp_category=,
compliance_mappings={
: ,
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
can_create = cur.fetchone()[]
can_create:
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.MEDIUM,
description=,
affected_objects=[],
remediation=,
owasp_category=,
compliance_mappings={
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
ssl_enabled = cur.fetchone()[] ==
ssl_enabled:
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.CRITICAL,
description=,
affected_objects=[],
remediation=,
owasp_category=,
compliance_mappings={
: ,
: ,
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
method = cur.fetchone()[]
method != :
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.HIGH,
description=,
affected_objects=[],
remediation=,
owasp_category=,
compliance_mappings={
: ,
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
log_dest = cur.fetchone()[]
log_dest == :
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.HIGH,
description=,
affected_objects=[],
remediation=,
owasp_category=,
compliance_mappings={
: ,
: ,
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
log_connections = cur.fetchone()[] ==
log_connections:
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.MEDIUM,
description=,
affected_objects=[],
remediation=,
owasp_category=,
compliance_mappings={
: ,
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
listen = cur.fetchone()[]
listen (, ):
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.MEDIUM,
description=,
affected_objects=[],
remediation=,
owasp_category=,
compliance_mappings={
: ,
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
vulnerable_funcs = [row[] row cur.fetchall()]
vulnerable_funcs:
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.CRITICAL,
description=,
affected_objects=vulnerable_funcs,
remediation=,
owasp_category=,
compliance_mappings={
: ,
:
}
))
() -> :
conn.cursor(cursor_factory=RealDictCursor) cur:
cur.execute()
checksums = cur.fetchone()
checksums checksums.get() == :
.findings.append(SecurityFinding(
check_id=,
title=,
severity=Severity.LOW,
description=,
affected_objects=[],
remediation=,
owasp_category=,
compliance_mappings={
:
}
))
() -> :
report_lines = [
,
,
,
,
]
severity_counts = {s: s Severity}
finding .findings:
severity_counts[finding.severity] +=
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
i, finding ((.findings, key= f: f.severity.value), ):
severity_emoji = {
Severity.CRITICAL: ,
Severity.HIGH: ,
Severity.MEDIUM: ,
Severity.LOW: ,
Severity.INFO:
}
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
finding.affected_objects:
report_lines.append()
obj finding.affected_objects[:]:
report_lines.append()
(finding.affected_objects) > :
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
finding.compliance_mappings:
report_lines.append()
standard, requirement finding.compliance_mappings.items():
report_lines.append()
report_lines.append()
report_lines.append()
report_lines.append()
.join(report_lines)
() -> :
script_lines = [
,
,
,
,
,
,
,
]
critical_findings = [f f .findings f.severity == Severity.CRITICAL]
high_findings = [f f .findings f.severity == Severity.HIGH]
critical_findings:
script_lines.append()
script_lines.append()
finding critical_findings:
script_lines.append()
script_lines.append()
script_lines.append()
high_findings:
script_lines.append()
script_lines.append()
finding high_findings:
script_lines.append()
script_lines.append()
script_lines.append()
script_lines.append()
script_lines.append()
script_lines.append()
.join(script_lines)
__name__ == :
argparse
parser = argparse.ArgumentParser(description=)
parser.add_argument(, required=, =)
parser.add_argument(, default=, =)
args = parser.parse_args()
scanner = PostgreSQLSecurityScanner(conn_string=args.conn)
findings = scanner.scan_all()
os
os.makedirs(args.output_dir, exist_ok=)
(, ) f:
f.write(scanner.generate_report())
(, ) f:
f.write(scanner.generate_remediation_script())
(, ) f:
findings_json = [
{
: f.check_id,
: f.title,
: f.severity.value,
: f.description,
: f.affected_objects,
: f.remediation,
: f.owasp_category,
: f.compliance_mappings
}
f findings
]
json.dump(findings_json, f, indent=)
()
()
| Error | Cause | Solution |
|---|---|---|
| "Permission denied for pg_authid" | Insufficient scanner privileges | Grant pg_read_all_settings and pg_read_all_stats roles |
| "Could not connect to database" | Connection blocked by firewall | Add scanner IP to pg_hba.conf or connect from allowed host |
| "Function does not exist: pg_reload_conf" | Using older PostgreSQL version | Use SELECT pg_ctl reload instead (requires OS access) |
| "SSL connection required" | Database enforces SSL but scanner doesn't use it | Add ?sslmode=require to connection string |
| "Too many findings to process" | Very insecure database | Prioritize critical/high findings first, fix iteratively |
Scan Scope
Severity Thresholds
Remediation Modes
DO:
DON'T:
/database-audit-logger - Implement audit logging found by scanner/database-health-monitor - Monitor security metrics over time/database-backup-automator - Backup before applying security fixes/database-connection-pooler - Secure connection management