block_copy_command
block_copy_command : Block COPY commands via a configurable ProcessUtility hook
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 7405 | block_copy_command
|
block_copy_command
|
0.1.5 |
SEC
|
BSD 3-Clause
|
Rust
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd--
|
No
|
Yes
|
Yes
|
Yes
|
no
|
no
|
Requires shared_preload_libraries = block_copy_command.
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
0.1.5 |
18
17
16
15
14
|
block_copy_command |
- |
| RPM | PIGSTY
|
0.1.5 |
18
17
16
15
14
|
block_copy_command_$v |
- |
| DEB | PIGSTY
|
0.1.5 |
18
17
16
15
14
|
postgresql-$v-block-copy-command |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
el8.aarch64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
el9.x86_64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
el9.aarch64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
el10.x86_64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
el10.aarch64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
d12.x86_64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
d12.aarch64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
d13.x86_64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
d13.aarch64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
u22.x86_64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
u22.aarch64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
u24.x86_64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
u24.aarch64
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
PIGSTY 0.1.5
|
Source
pig build pkg block_copy_command; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install block_copy_command; # install via package name, for the active PG version
pig install block_copy_command -v 18; # install for PG 18
pig install block_copy_command -v 17; # install for PG 17
pig install block_copy_command -v 16; # install for PG 16
pig install block_copy_command -v 15; # install for PG 15
pig install block_copy_command -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'block_copy_command';Create this extension with:
CREATE EXTENSION block_copy_command;Usage
- GitHub Repo:
rustwizard/block_copy_command - README: rustwizard/block_copy_command/blob/master/README.md
block_copy_command blocks COPY commands cluster-wide by installing a ProcessUtility hook. It is loaded with shared_preload_libraries, and CREATE EXTENSION only registers the extension metadata in each database.
This extension is intended for deployments that want to stop COPY TO and COPY FROM by default for non-superusers, while still allowing finer-grained policy through GUCs and an audit table.
Setup
shared_preload_libraries = 'block_copy_command'CREATE EXTENSION block_copy_command;The README says the hook becomes active for the whole cluster as soon as the library is loaded.
Blocking Rules
By default, non-superusers are blocked from running COPY.
COPY my_table TO STDOUT;
COPY my_table FROM STDIN;
COPY (SELECT * FROM my_table) TO '/tmp/out.csv';Superusers bypass the block unless they are listed in block_copy_command.blocked_roles or block_copy_command.block_program is enabled. COPY ... PROGRAM is blocked for everyone by default.
Settings
block_copy_command.enabledtoggles blocking for non-superusers.block_copy_command.block_tocontrols whetherCOPY TOis blocked.block_copy_command.block_fromcontrols whetherCOPY FROMis blocked.block_copy_command.block_programblocksCOPY TO/FROM PROGRAMfor all users.block_copy_command.hintappends a customHINT:to blocked commands.block_copy_command.blocked_rolespermanently blocks named roles, including superusers.block_copy_command.audit_log_enabledcontrols whether interceptedCOPYevents are written toblock_copy_command.audit_log.
Audit Log
The extension records intercepted COPY activity in block_copy_command.audit_log and also writes blocked events to the PostgreSQL server log at LOG level.
Typical monitoring queries from the README include listing recent events, filtering blocked events, and grouping by user.
Scope
The upstream README covers requirements, enablement, blocking behavior, the main GUCs, the audit table, and test coverage. No separate project homepage or docs site was needed for this stub.