-
Notifications
You must be signed in to change notification settings - Fork 6
improve webhook collection testing #1085
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
base: rc-v0.5.17
Are you sure you want to change the base?
Changes from all commits
37ac682
3bd0d86
f2c59b4
6a117f1
eba33fc
61cef1c
05f5bbc
205bd2b
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 |
|---|---|---|
|
|
@@ -235,6 +235,9 @@ locals { | |
| secrets_to_grant_access_to = { | ||
| AUTH_ISSUER = { | ||
| secret_id = module.auth_issuer_secret.secret_ids_within_project["AUTH_ISSUER"] | ||
| }, | ||
| SERVICE_URL = { | ||
| secret_id = module.auth_issuer_secret.secret_ids_within_project["SERVICE_URL"] | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -501,6 +504,9 @@ resource "local_file" "test_script" { | |
| example_payload = coalesce(var.example_payload, "{\"test\": \"data\"}") | ||
| example_identity = var.example_identity | ||
| collection_path = "/" | ||
| scheduler_job_name = google_cloud_scheduler_job.trigger_batch_processing.id | ||
| bucket_name = module.sanitized_webhook_output.bucket_name | ||
| output_path_prefix = var.output_path_prefix | ||
|
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. Template parameter
|
||
| }) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import { Command, Option } from 'commander'; | |
| import _ from 'lodash'; | ||
| import { createRequire } from 'module'; | ||
| import { callDataSourceEndpoints } from './data-sources/runner.js'; | ||
| import gcp from './lib/gcp.js'; | ||
| import getLogger from './lib/logger.js'; | ||
| import psoxyTestCall from './psoxy-test-call.js'; | ||
|
|
||
|
|
@@ -39,6 +40,8 @@ const AWS_ACCESS_DENIED_EXCEPTION_REGEXP = new RegExp(/(?<arn>arn:aws:iam::\d+:\ | |
| .option('--request-no-response', "Request 'No response body' back from proxy (tests side-output case)", false) | ||
| .option('--async', 'Process request asynchronously (adds X-Psoxy-Process-Async header)', false) | ||
| .option('-b, --body <body>', 'Body to send in request (it expects a JSON string)') | ||
| .option('--verify-collection <bucket>', 'Verify that the posted data appears in the specified bucket (GCS/S3)') | ||
| .option('--scheduler-job <name>', 'GCP: Cloud Scheduler job name to trigger batch processing') | ||
| .addOption(new Option('-d, --data-source <name>', | ||
| 'Data source to test all available endpoints').choices([ | ||
| //TODO: pull this list from terraform console or something?? | ||
|
|
@@ -82,11 +85,41 @@ const AWS_ACCESS_DENIED_EXCEPTION_REGEXP = new RegExp(/(?<arn>arn:aws:iam::\d+:\ | |
|
|
||
| let result; | ||
| try { | ||
| const startTime = Date.now(); | ||
| if (options.dataSource) { | ||
| result = await callDataSourceEndpoints(options); | ||
| } else { | ||
| result = await psoxyTestCall(options); | ||
| } | ||
|
|
||
| if (options.verifyCollection && result.status === 200) { | ||
| // Delegate based on cloud provider logic | ||
| const url = new URL(options.url); | ||
|
|
||
|
|
||
| const isGcp = options.force?.toLowerCase() === 'gcp' || gcp.isValidURL(url); | ||
| const isAws = options.force?.toLowerCase() === 'aws' || (!isGcp && (url.hostname.endsWith('amazonaws.com') || url.hostname.endsWith('on.aws'))); // rough check or rely on fallback | ||
|
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. Unused
|
||
|
|
||
| if (isGcp) { | ||
| await gcp.verifyCollection({ | ||
eschultink marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ...options, | ||
| bucketName: options.verifyCollection, | ||
| startTime: startTime | ||
| }, logger); | ||
| } else { | ||
| // Assume AWS or fallback | ||
| const aws = (await import('./lib/aws.js')).default; | ||
| await aws.verifyCollection({ | ||
| verifyCollection: options.verifyCollection, | ||
| url: options.url, | ||
| body: options.body, | ||
| startTime: startTime, | ||
| role: options.role, | ||
| region: options.region, | ||
| }, logger); | ||
| } | ||
| } | ||
|
|
||
| } catch (error) { | ||
| if (error?.name === 'AccessDenied' && error.message && | ||
| AWS_ACCESS_DENIED_EXCEPTION_REGEXP.test(error.message)) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing IAM grant for Cloud Scheduler run permission
High Severity
The test script passes
--scheduler-jobto trigger the Cloud Scheduler job viatriggerScheduler(), which callsclient.runJob(). This requirescloudscheduler.jobs.runpermission. However, the Terraform grants test principals only KMS signing and bucket read permissions—there's no IAM binding for Cloud Scheduler. Test principals will receive a permission denied error when the test attempts to trigger the scheduler.Additional Locations (1)
infra/modules/gcp-webhook-collector/test_script.tftpl#L18-L19