Skip to main content
Version: 2.0.1-alpha.3

GCP

Provision a GCP Cloud Build trigger that runs JS Recon against any URL. Upload results to a GCS bucket automatically.


View on Terraform Registry →



Quick start

module "js_recon" {
source = "js-recon/js-recon/gcp"
version = "~> 1.0"

project = "my-gcp-project"
url = "https://example.com"
}

After terraform apply, trigger a scan:

gcloud builds triggers run js-recon \
--project=my-gcp-project \
--region=us-central1

Scanning a localhost app

Override substitutions at invocation time to scan an app that starts inside the build:

gcloud builds triggers run js-recon \
--project=my-gcp-project \
--region=us-central1 \
--substitutions=_JSR_URL=http://localhost:3000,_JSR_START_CMD="npm start"

The build waits up to 120 seconds for the URL to respond before scanning.


Inputs

NameRequiredDefaultDescription
projectYesGCP project ID
urlYesTarget URL to scan
regionNous-central1GCP region for Cloud Build trigger and Cloud Scheduler
trigger_nameNojs-reconName prefix for all GCP resources
create_gcs_bucketNotrueWhether the module creates a GCS bucket for artifacts
gcs_bucket_nameNo(auto-generated)Explicit GCS bucket name
gcs_artifact_prefixNojs-recon-outputGCS object prefix for uploaded artifacts
scheduleNo""Cloud Scheduler cron expression (for example, 0 8 * * *). Empty = no schedule.
build_timeoutNo30Maximum build duration in minutes
labelsNo{}Labels applied to all GCP resources

See Common Reference — Common inputs for js_recon_version, break_on_map_files, break_on_vulnerabilities, vulnerability_severity, and output_dir.


Outputs

NameDescription
cloudbuild_trigger_idID of the Cloud Build trigger
cloudbuild_trigger_nameName of the Cloud Build trigger
gcs_bucket_nameName of the GCS artifact bucket
gcs_bucket_urlgs:// URL of the artifact bucket
service_account_emailEmail of the Cloud Build service account

Output files

JS Recon writes the common output files inside the output directory and uploads them to gs://<bucket>/<gcs_artifact_prefix>/ after every scan.


Break conditions

See Common Reference — Break conditions for how break_on_map_files and break_on_vulnerabilities/vulnerability_severity work.

Source maps

module "js_recon" {
source = "js-recon/js-recon/gcp"
project = "my-gcp-project"
url = "https://example.com"

break_on_map_files = true # default
}

Vulnerabilities

module "js_recon" {
source = "js-recon/js-recon/gcp"
project = "my-gcp-project"
url = "https://example.com"

break_on_vulnerabilities = true
vulnerability_severity = "medium"
}

Scheduled scans

module "js_recon" {
source = "js-recon/js-recon/gcp"
project = "my-gcp-project"
url = "https://example.com"

schedule = "0 8 * * *"
}

Standard Unix cron expressions are supported. Requires the Cloud Scheduler API (cloudscheduler.googleapis.com) to be enabled in your project.


Triggering a scan manually

# Run with default substitutions (as configured in Terraform)
gcloud builds triggers run js-recon \
--project=my-gcp-project \
--region=us-central1

# Override the target URL at run time
gcloud builds triggers run js-recon \
--project=my-gcp-project \
--region=us-central1 \
--substitutions=_JSR_URL=https://other.example.com

Pinning to a specific JS Recon version

module "js_recon" {
source = "js-recon/js-recon/gcp"
project = "my-gcp-project"
url = "https://example.com"

js_recon_version = "1.3.1-beta.1"
}

See Common Reference — Pinning for details.