Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude template DBs from discovery and schema-qualify discovery query #50

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

ringerc
Copy link
Collaborator

@ringerc ringerc commented Jun 17, 2024

When doing database auto-discovery, exclude all databases marked as templates and any databases that do not allow connections.

It's conceivable, but not very likely, that someone could want to scrape metrics from a template DB, but pg_exporter currently defaults to excluding template1 anyway. postgres_exporter also has the same behaviour of excluding template DBs from discovery. So I did not add a CLI option to override this behaviour.

Additionally, schema-qualify references to pg_database and the pg_is_in_recovery function call in the database discovery query to guarantee protection against any possible search_path based attacks. I can't immediately see how it'd be possible in this case, so it's not a vulnerability, but it's best practice to always schema-qualify everything in any query that could possibly be run as a privileged role.

Schema-qualify all object references in queries to `pg_database`.
When doing database auto-discovery, exclude all databases marked as
templates and any databases that do not allow connections.

It's conceivable, but not very likely, that someone could want to scrape
metrics from a template DB, but pg_exporter currently defaults to
excluding template1 anyway. postgres_exporter also has the same
behaviour of excluding template DBs from discovery. So I did not add a
CLI option to override this behavour.
@Vonng Vonng merged commit c8d4c39 into Vonng:master Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants