Skip to content
Back to skills

1207 Pgaudit Guide 8b713058

ASecurity

1. PostgreSQL cluster wide auditing is set by pgaudit params in cnpg-cluster-deploy.yaml 2. Object auditing is set in owl db/\_\_init\_\_.py ---

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
databasespythonsqlgitdatabase

Works with

  • cli

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 1207-pgaudit_guide_8b713058 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 1207 Pgaudit Guide 8b713058?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 1207 Pgaudit Guide 8b713058
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-1207-pgaudit-guide-8b713058/badge)](https://www.skillsdirectory.com/skills/tools-only-1207-pgaudit-guide-8b713058)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# JamAIBase — pgaudit Setup

1. PostgreSQL cluster wide auditing is set by pgaudit params in cnpg-cluster-deploy.yaml
2. Object auditing is set in owl db/\_\_init\_\_.py

---

## 1) CNPG Cluster Config (role + pgaudit parameters)

- Can customize the logging option in the parameters, ref. https://github.com/pgaudit/pgaudit/blob/main/README.md
- jamaibase_auditor is the role required for object auditing

```yaml
spec:
  managed:
    roles:
      - name: jamaibase_auditor
        ensure: present
        comment: pgaudit role for jamaibase
        login: false

  postgresql:
    parameters:
      # pgaudit for logging DDL and role changes; include useful context
      # NOTE: Ensure pgaudit is actually loaded via shared_preload_libraries in your cluster.
      # If not already set elsewhere, add:
      # shared_preload_libraries: "pgaudit"
      pgaudit.log: "ddl, role"
      pgaudit.log_catalog: "off"
      pgaudit.log_parameter: "on"
      pgaudit.log_client: "on"
      pgaudit.role: "jamaibase_auditor" # object-based auditing role
```

---

## 2) Object Auditing Grants (in db/\_\_init\_\_.py)

- customize audit_statement based on the level of DML statement you would want to monitor

```python
async def _grant_auditor_privilege(engine: AsyncEngine) -> bool:
    """
    Apply the necessary grants to allow the auditor role to audit the database.
    """
    auditor_role = "jamaibase_auditor"
    audit_statement = "UPDATE, DELETE"

    async with engine.connect() as conn:
        role_exists = await conn.scalar(
            text(f"SELECT 1 FROM pg_roles WHERE rolname = '{auditor_role}'")
        )
        if role_exists is None:
            return False

        # FUTURE tables in this schema
        await conn.execute(
            text(
                f'ALTER DEFAULT PRIVILEGES IN SCHEMA "{SCHEMA}" '
                f"GRANT {audit_statement} ON TABLES TO {auditor_role};"
            )
        )

        # EXISTING tables now
        await conn.exec_driver_sql(
            f'GRANT {audit_statement} ON ALL TABLES IN SCHEMA "{SCHEMA}" TO {auditor_role};'
        )
        await conn.commit()

    return True
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.