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

add support for cloudflare_web_analytics_site #632

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

broswen
Copy link
Contributor

@broswen broswen commented Nov 7, 2023

I kept getting time="2023-11-06T23:38:49-06:00" level=fatal msg="failed to detect provider installation" even after initializing the provider so I couldn't test locally.

Copy link

gitguardian bot commented Nov 7, 2023

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id Secret Commit Filename
- Generic High Entropy Secret 8f31489 testdata/cloudflare/cloudflare_web_analytics_site.yaml View secret
- Generic High Entropy Secret 8f31489 testdata/cloudflare/cloudflare_web_analytics_site.yaml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@jacobbednarz
Copy link
Member

I kept getting time="2023-11-06T23:38:49-06:00" level=fatal msg="failed to detect provider installation" even after initializing the provider so I couldn't test locally.

this trips a few people up. the tool requires an initiliased terraform installation to read the schema from so if you're not running it in the same directory, you need to provide that location.

for local testing, i have a ~/src/scratch directory which holds the following terraform.tf

terraform {
  required_providers {
    cloudflare = {
      source = "cloudflare/cloudflare"
    }
  }
}

provider "cloudflare" {}

i run terraform init in ~/src/scratch and then in my tests, set CLOUDFLARE_TERRAFORM_INSTALL_PATH=/Users/jacob/src/scratch make test ...

@@ -44,6 +44,7 @@ var resourceImportStringFormats = map[string]string{
"cloudflare_turnstile_widget": ":account_id/:id",
"cloudflare_waf_override": ":zone_id/:id",
"cloudflare_waiting_room": ":zone_id/:id",
"cloudflare_web_analytics_site": ":account_id/:id",
Copy link
Member

@jacobbednarz jacobbednarz Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll have to manually test this; i'm unsure what id you're using here. i think you may want site_tag given that is what is used in the import command docs (https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/web_analytics_site#import)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...or are import docs wrong and you should use id to import?

}

for i := 0; i < resourceCount; i++ {
jsonStructData[i].(map[string]interface{})["zone_tag"] = jsonStructData[i].(map[string]interface{})["ruleset"].(map[string]interface{})["zone_tag"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated this to include the remapping as site_tag doesn't exist at the top level in the API response but it does in the resource.

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.

2 participants