ソース情報
- リポジトリ
- 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コマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?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