Repository navigation
feat: set up some Postgres experiments to be used for API testing #6150
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
The head ref may contain hidden characters: "\u{1F9EA}\u{1F4BD}"
Changes from all commits
5560b26
ee53a25
e4cd631
f5dce1a
ba25e66
a5f7361
ff7c186
0efea3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| -- +goose Up | ||
| CREATE TABLE vulnerabilities ( | ||
| id TEXT PRIMARY KEY, -- NB: This should have COLLATE "C" | ||
| data JSONB NOT NULL, | ||
| proto BYTEA NOT NULL | ||
| ); | ||
| -- vuln_id does not reference vulnerabilities(id) because there is no index on (vuln_id) | ||
| -- (to save space/writes), which would cause a full table scan on vulnerability deletes. | ||
| -- Use vuln_commits to look up commits and delete by (commit_sha, vuln_id). | ||
| CREATE TABLE affected_commits ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need references for vulnerabilities here as well? just like vuln_commits and affected_versions?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't for a bit of an optimisation reason: I've added a comment here to explain also |
||
| commit_sha BYTEA NOT NULL, | ||
| vuln_id TEXT NOT NULL, | ||
| PRIMARY KEY (commit_sha, vuln_id) | ||
| ); | ||
| CREATE TABLE vuln_commits ( | ||
| vuln_id TEXT PRIMARY KEY REFERENCES vulnerabilities(id) ON DELETE CASCADE, | ||
| commits BYTEA[] | ||
| ); | ||
|
|
||
| CREATE TABLE affected_versions ( | ||
| id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, | ||
| vuln_id TEXT NOT NULL REFERENCES vulnerabilities(id) ON DELETE CASCADE, | ||
| name TEXT NOT NULL, | ||
| base_ecosystem TEXT NOT NULL, | ||
| ecosystems TEXT[] NOT NULL, | ||
| coarse_min TEXT COLLATE "C" NOT NULL, | ||
| coarse_max TEXT COLLATE "C" NOT NULL, | ||
| versions TEXT[], | ||
| events JSONB | ||
| ); | ||
|
|
||
| -- Primary index for typical queries (with ecosystem provided) | ||
| CREATE INDEX idx_affected_versions_match | ||
| ON affected_versions (name, base_ecosystem, vuln_id, id, coarse_min, coarse_max) | ||
| INCLUDE (ecosystems); | ||
|
|
||
| -- Secondary index for queries without ecosystems | ||
| CREATE INDEX idx_affected_versions_name_only | ||
| ON affected_versions (name, vuln_id, id); | ||
|
|
||
| -- Index for worker updates/deletes by vuln_id | ||
| CREATE INDEX idx_affected_versions_vuln_id ON affected_versions (vuln_id); | ||
|
|
||
|
|
||
| -- +goose Down | ||
| DROP TABLE affected_versions; | ||
| DROP TABLE vuln_commits; | ||
| DROP TABLE affected_commits; | ||
| DROP TABLE vulnerabilities; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| variable "project_id" { | ||
| description = "The GCP project ID to deploy the experimental Cloud SQL database to." | ||
| type = string | ||
| default = "oss-vdb-test" | ||
| } | ||
|
|
||
| resource "google_sql_database_instance" "experiment" { | ||
| project = var.project_id | ||
| name = "experiment-db" | ||
| database_version = "POSTGRES_18" | ||
| region = "us-west2" | ||
|
|
||
| settings { | ||
| tier = "db-perf-optimized-N-4" | ||
| availability_type = "ZONAL" | ||
|
|
||
| connection_pool_config { | ||
| connection_pooling_enabled = true | ||
| } | ||
|
|
||
| ip_configuration { | ||
| ipv4_enabled = true | ||
| private_network = data.google_compute_network.default.id | ||
| enable_private_path_for_google_cloud_services = true | ||
| ssl_mode = "ENCRYPTED_ONLY" | ||
| } | ||
|
|
||
| database_flags { | ||
| name = "cloudsql.iam_authentication" | ||
| value = "on" | ||
| } | ||
| database_flags { | ||
| name = "temp_file_limit" | ||
| value = "2147483647" # maximum allowed (2TiB, measured in KiB) | ||
| } | ||
| } | ||
|
|
||
| deletion_protection = false | ||
| depends_on = [google_service_networking_connection.private_vpc_connection] | ||
| } | ||
|
|
||
| resource "google_sql_database" "osv" { | ||
| name = "osv" | ||
| instance = google_sql_database_instance.experiment.name | ||
| project = var.project_id | ||
| } | ||
|
|
||
|
|
||
| resource "google_project_service" "service_networking" { | ||
| project = var.project_id | ||
| service = "servicenetworking.googleapis.com" | ||
| disable_on_destroy = false | ||
| } | ||
|
|
||
| resource "google_compute_global_address" "private_ip_address" { | ||
| project = var.project_id | ||
| name = "google-managed-services-default" | ||
| purpose = "VPC_PEERING" | ||
| address_type = "INTERNAL" | ||
| prefix_length = 16 | ||
| network = data.google_compute_network.default.id | ||
| } | ||
|
|
||
| resource "google_service_networking_connection" "private_vpc_connection" { | ||
| network = data.google_compute_network.default.id | ||
| service = "servicenetworking.googleapis.com" | ||
| reserved_peering_ranges = [google_compute_global_address.private_ip_address.name] | ||
|
|
||
| depends_on = [google_project_service.service_networking] | ||
| } | ||
|
|
||
| data "google_compute_network" "default" { | ||
| project = var.project_id | ||
| name = "default" | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.