Skip to content

Commit b444ac1

Browse files
chore: add trivy and tflint
1 parent d4a2283 commit b444ac1

File tree

10 files changed

+108
-16
lines changed

10 files changed

+108
-16
lines changed

.github/workflows/tflint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: TFlint
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
branches:
7+
- main
8+
- rc
9+
10+
jobs:
11+
tflint:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
name: Checkout source code
17+
18+
- uses: terraform-linters/setup-tflint@v4
19+
name: Setup TFLint
20+
with:
21+
tflint_version: v0.58.0
22+
23+
- name: Show version
24+
run: tflint --version
25+
26+
- name: Init TFLint
27+
run: tflint --init
28+
29+
- name: Run TFLint
30+
run: tflint -f compact

.github/workflows/trivy.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Run Trivy
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
branches:
7+
- main
8+
- rc
9+
10+
jobs:
11+
build:
12+
name: Scan
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Run Trivy vulnerability scanner in config mode
19+
uses: aquasecurity/trivy-action@master
20+
with:
21+
scan-type: 'config'
22+
exit-code: '1'
23+
trivy-config: trivy.yaml

.trivyignore

Whitespace-only changes.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Prerequisites
22

3-
* Create a `terraform.tfvars` file, fill your `fastly_api_key`, `integration_domain`, `main_host`, `get_result_path`, `agent_script_download_path`
3+
* Create a `terraform.tfvars` file, fill your `fastly_api_key`, `integration_domain`, `get_result_path`, `agent_script_download_path`
44
* Create an empty Fastly Compute service and copy the id
55
* Paste the id in `terraform.tfvars` file like this:
66
```terraform

main.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
terraform {
2+
required_version = ">=1.5"
23
required_providers {
34
fastly = {
45
source = "fastly/fastly"
@@ -14,10 +15,10 @@ provider "fastly" {
1415
module "compute_asset" {
1516
count = var.download_asset ? 1 : 0
1617
source = "./modules/download_asset"
17-
asset_version_min = var.asset_version_min
18+
asset_version = var.asset_version
1819
compute_asset_name = var.compute_asset_name
19-
repository_name = var.repository_name
20-
repository_organization_name = var.repository_organization_name
20+
repository_name = var.asset_repository_name
21+
repository_organization_name = var.asset_repository_organization_name
2122
}
2223

2324
locals {

modules/download_asset/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ terraform {
1010
data "github_release" "selected" {
1111
repository = var.repository_name
1212
owner = var.repository_organization_name
13-
retrieve_by = var.asset_version_min
13+
retrieve_by = var.asset_version
1414
}
1515

1616
locals {

modules/download_asset/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ variable "repository_name" {
88
default = "fingerprint-pro-fastly-compute-proxy-integration"
99
}
1010

11-
variable "asset_version_min" {
11+
variable "asset_version" {
1212
type = string
1313
default = "latest"
1414
}

terraform.tfvars.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
fastly_api_key = "" # Your Fastly API Key comes here
22
integration_domain = "metrics.mydomain.com" # Set here to the subdomain you have chosen for the integration, for example metrics.yourwebsite.com. Avoid terms commonly blocked by ad blockers like fingerprint, fpjs, etc.
3-
main_host = "metrics-origin.mydomain.com" # Set here to something like metrics-origin.yourwebsite.com. This origin does not need to exist because the VCL template will forward all valid requests to the appropriate Fingerprint servers.
43
integration_path = "" # Main path to serve this proxy integration from. Please use random string minimum 6 characters long, no special characters like `w2kz84h`
54
agent_script_download_path = "" # Fingerprint Javascript Agent download path. Please use random string minimum 6 characters long, no special characters like `w2kz84h`
65
get_result_path = "" # Fingerprint Identification endpoint path. Please use random string minimum 6 characters long, no special characters like `w2kz84h`

trivy.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
timeout: 10m
2+
format: table
3+
dependency-tree: true
4+
list-all-pkgs: true
5+
exit-code: 1
6+
severity:
7+
# - LOW
8+
# - MEDIUM
9+
- HIGH
10+
- CRITICAL
11+
scan:
12+
skip-dirs:
13+
- assets/
14+
15+
config:
16+
misconfig-scanners: Terraform
17+
18+
ignorefile: .trivyignore

variables.tf

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,72 @@
11
variable "integration_domain" {
22
type = string
3-
}
4-
5-
variable "main_host" {
6-
type = string
3+
nullable = false
74
}
85

96
variable "integration_name" {
107
type = string
118
default = "fingerprint-fastly-compute-proxy-integration"
9+
nullable = false
10+
validation {
11+
condition = can(regex("^([a-zA-Z0-9\\-])+$", var.integration_name))
12+
error_message = "value should only consist of alphanumeric values and dashes"
13+
}
1214
}
1315

1416
variable "config_store_prefix" {
1517
type = string
1618
default = "Fingerprint_Compute_Config_Store_"
19+
nullable = false
20+
validation {
21+
condition = can(regex("^([a-zA-Z0-9\\_])+$", var.config_store_prefix))
22+
error_message = "value should only consist of alphanumeric values and underscores"
23+
}
1724
}
1825

1926
variable "secret_store_prefix" {
2027
type = string
2128
default = "Fingerprint_Compute_Secret_Store_"
29+
nullable = false
30+
validation {
31+
condition = can(regex("^([a-zA-Z0-9\\_])+$", var.secret_store_prefix))
32+
error_message = "value should only consist of alphanumeric values and underscores"
33+
}
2234
}
2335

2436
variable "fastly_api_key" {
2537
type = string
38+
nullable = false
2639
}
2740

2841
variable "agent_script_download_path" {
2942
type = string
30-
default = "agent"
43+
nullable = false
44+
validation {
45+
condition = can(regex("^([a-zA-Z0-9\\-])+$", var.agent_script_download_path))
46+
error_message = "value should only consist of alphanumeric values and dashes"
47+
}
3148
}
3249

3350
variable "get_result_path" {
3451
type = string
35-
default = "result"
52+
nullable = false
53+
validation {
54+
condition = can(regex("^([a-zA-Z0-9\\-])+$", var.get_result_path))
55+
error_message = "value should only consist of alphanumeric values and dashes"
56+
}
3657
}
3758

38-
variable "repository_organization_name" {
59+
variable "asset_repository_organization_name" {
3960
type = string
4061
default = "fingerprintjs"
4162
}
4263

43-
variable "repository_name" {
64+
variable "asset_repository_name" {
4465
type = string
4566
default = "fingerprint-pro-fastly-compute-proxy-integration"
4667
}
4768

48-
variable "asset_version_min" {
69+
variable "asset_version" {
4970
type = string
5071
default = "latest"
5172
}

0 commit comments

Comments
 (0)