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

Support JFrog Apps Config file #2199

Merged
merged 2 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jedib0t/go-pretty/v6 v6.4.7 // indirect
github.com/jfrog/jfrog-apps-config v1.0.1 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
Expand Down Expand Up @@ -105,7 +106,7 @@ require (
github.com/subosito/gotenv v1.4.2 // indirect
github.com/ulikunitz/xz v0.5.9 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
Expand All @@ -126,7 +127,7 @@ require (

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230828134416-f0db33dd9344

//replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.15.3-0.20230919052701-996d96513bc8
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230928113028-e2aca0fa17f8

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27

Expand Down
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ github.com/jfrog/build-info-go v1.9.10 h1:uXnDLVxpqxoAMpXcki00QaBB+M2BoGMMpHODPk
github.com/jfrog/build-info-go v1.9.10/go.mod h1:ujJ8XQZMdT2tMkLSMJNyDd1pCY+duwHdjV+9or9FLIg=
github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk=
github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0=
github.com/jfrog/jfrog-cli-core/v2 v2.43.2 h1:ii8fj8tqbGwgU1yxNpfDECtXJe2wC2YzAQrCzIpIVyw=
github.com/jfrog/jfrog-cli-core/v2 v2.43.2/go.mod h1:DKTOX9TsPkyI68GM4XdDTD7XDr+tOBqeK70DZZmu+4Q=
github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY=
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230928113028-e2aca0fa17f8 h1:k7MGAQKMUFRAhmStrGCn0pt5CN4sqyqh8wjnjdcTuCo=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230928113028-e2aca0fa17f8/go.mod h1:hq9KM+5WlZ6CCXuItLcZVrgpHk1mKjicSgcMFQPNRcQ=
github.com/jfrog/jfrog-client-go v1.32.3 h1:B2M8Gu8EMrokbHWPPDgN1b7YRWwf0oe746epvQASK6c=
github.com/jfrog/jfrog-client-go v1.32.3/go.mod h1:UewnwkIf/77HzBgwCPzOHZCK6V/Nw5/JwdzN/tRb4aU=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
Expand Down Expand Up @@ -397,8 +399,9 @@ github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
Expand Down
11 changes: 11 additions & 0 deletions testdata/xray/jas-config/.jfrog/jfrog-apps-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "1.0"

modules:
- source_root: "."
scanners:
secrets:
exclude_patterns:
- "**/*secret_generic*/**"
iac:
exclude_patterns:
- "**/*gcp*/**"
116 changes: 116 additions & 0 deletions testdata/xray/jas-config/iac/azure/vpc/module.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@

#Azure Generic vNet Module
resource "azurerm_resource_group" "network" {
count = var.module_enabled ? 1 : 0
name = var.short_region != " " ? var.short_region : "${var.deploy_name}-${var.region}"
location = var.region

tags = {
environment = var.environment
}
}

resource "azurerm_virtual_network" "vnet" {
count = var.module_enabled ? 1 : 0
name = "${var.deploy_name}-${var.region}"
location = var.region
address_space = [var.vpc_cidr]
resource_group_name = azurerm_resource_group.network[0].name

tags = {
environment = var.environment
costcenter = "${var.deploy_name}-${var.region}"
}
}

resource "azurerm_subnet" "subnet" {
count = var.module_enabled ? length(var.subnet_names) : 0
name = var.subnet_names[count.index]
virtual_network_name = azurerm_virtual_network.vnet[0].name
resource_group_name = azurerm_resource_group.network[0].name
address_prefixes = [var.subnet_prefixes[count.index]]
# service_endpoints = [
# "Microsoft.KeyVault"
# ]

dynamic "delegation"{
for_each =var.subnet_names[count.index] == "flexible-dbs" ? ["exec"] : []
content {
name = "dlg-Microsoft.DBforPostgreSQL-flexibleServers"
service_delegation {
name = "Microsoft.DBforPostgreSQL/flexibleServers"
actions = [
"Microsoft.Network/virtualNetworks/subnets/join/action"
]
}
}
}

enforce_private_link_endpoint_network_policies = var.subnet_names[count.index] == "data"
enforce_private_link_service_network_policies = var.subnet_names[count.index] == "private" && var.enforce_pl_svc_net_private
lifecycle {
ignore_changes = [
service_endpoints,
delegation[0].name
]
}
}


resource "azurerm_private_dns_zone" "postgres_private_dns" {
count = var.module_enabled ? 1 : 0
name = "privatelink.postgres.database.azure.com"
resource_group_name = azurerm_resource_group.network[0].name
}

resource "random_string" "postgres_private_dns_net_link_name" {
count = var.module_enabled ? 1 : 0
length = 8
special = false
number = false
upper = false
}

resource "azurerm_private_dns_zone_virtual_network_link" "postgres_private_dns_net_link" {
count = var.module_enabled ? 1 : 0
name = random_string.postgres_private_dns_net_link_name[0].result
resource_group_name = azurerm_resource_group.network[0].name
private_dns_zone_name = azurerm_private_dns_zone.postgres_private_dns[0].name
virtual_network_id = azurerm_virtual_network.vnet[0].id
}

//resource "azurerm_network_security_group" "nsg" {
// count = "${var.module_enabled ? length(var.subnet_names) : 0}"
// name = "${var.subnet_names[count.index]}-sg"
// location = "${var.region}"
// resource_group_name = "${var.deploy_name}-${var.region}"
//}
//
//resource "azurerm_subnet_network_security_group_association" "nsg" {
// count = "${var.module_enabled ? length(var.subnet_names) : 0}"
// subnet_id = "${element(azurerm_subnet.subnet.*.id, count.index)}"
// network_security_group_id = "${element(azurerm_network_security_group.nsg.*.id, count.index)}"
//}
//resource "azurerm_subnet_route_table_association" "nat" {
// count = "${var.module_enabled ? length(var.nat_subnets) : 0}"
// subnet_id = "${element(azurerm_subnet.subnet.*.id, count.index + 1)}"
// route_table_id = "${azurerm_route_table.nattable.id}"
//}
# UDR
//resource "azurerm_route_table" "nattable" {
// count = "${var.module_enabled}"
// name = "${var.deploy_name}-${var.region}"
// location = "${var.region}"
// resource_group_name = "${azurerm_resource_group.network.name}"
//
// route {
// name = "all-traffic-via-nat"
// address_prefix = "0.0.0.0/0"
// next_hop_type = "VirtualAppliance"
// next_hop_in_ip_address = "${var.natgw_private_ip}"
// }
//
// tags = {
// environment = "${var.environment}"
// }
//}
79 changes: 79 additions & 0 deletions testdata/xray/jas-config/iac/azure/vpc/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
##################################################################################
# OUTPUT
##################################################################################

output "resource_group_id" {
value = azurerm_resource_group.network[0].id
}

output "resource_group_name" {
value = azurerm_resource_group.network[0].name
}

output "vnet_id" {
value = element(concat(azurerm_virtual_network.vnet.*.id, [""]), 0)
}

output "vnet_location" {
value = element(concat(azurerm_virtual_network.vnet.*.location, [""]), 0)
}

output "vnet_name" {
value = element(concat(azurerm_virtual_network.vnet.*.name, [""]), 0)
}

output "private_dns_id" {
value = element(
concat(azurerm_private_dns_zone.postgres_private_dns.*.id, [""]),
0,
)
}

output "private_dns_name" {
value = element(
concat(azurerm_private_dns_zone.postgres_private_dns.*.name, [""]),
0,
)
}

//output "vnet_subnets" {
// value = "${azurerm_subnet.subnet.*.id}"
//}

### subnets ids ###
output "public_subnet" {
value = element(concat(azurerm_subnet.subnet.*.id, [""]), 0)
}

output "private_subnet" {
value = element(concat(azurerm_subnet.subnet.*.id, [""]), 1)
}
output "flexible_subnet" {
value = element(concat(azurerm_subnet.subnet.*.id, [""]), 4)
}
output "data_subnet" {
value = element(concat(azurerm_subnet.subnet.*.id, [""]), 2)
}

output "mgmt_subnet" {
value = element(concat(azurerm_subnet.subnet.*.id, [""]), 3)
}

### subnets names ###
output "public_subnet_name" {
value = element(concat(azurerm_subnet.subnet.*.name, [""]), 0)
}

output "private_subnet_name" {
value = element(concat(azurerm_subnet.subnet.*.name, [""]), 1)
}

output "data_subnet_name" {
value = element(concat(azurerm_subnet.subnet.*.name, [""]), 2)
}

output "mgmt_subnet_name" {
value = element(concat(azurerm_subnet.subnet.*.name, [""]), 3)
}


39 changes: 39 additions & 0 deletions testdata/xray/jas-config/iac/azure/vpc/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
variable "module_enabled" {
default = true
}

variable "region" {
}

variable "deploy_name" {
}

variable "vpc_cidr" {
}

variable "short_region" {
default = " "
}

variable "subnet_prefixes" {
type = list(string)
}

variable "ssh_source_ranges" {
type = list(string)
}

variable "environment" {
}

variable "subnet_names" {
type = list(string)
}

variable "enforce_pl_svc_net_private" {
default = false
}
//variable "natgw_private_ip" {}
//variable "nat_subnets" {
// type = "list"
//}
4 changes: 4 additions & 0 deletions testdata/xray/jas-config/iac/azure/vpc/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

terraform {
required_version = ">= 0.12"
}
34 changes: 34 additions & 0 deletions testdata/xray/jas-config/iac/azure/vpc_pp/module.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#Azure Generic vNet Module
resource "azurerm_resource_group" "network" {
count = var.module_enabled ? 1 : 0
name = var.short_region != " " ? var.short_region : "${var.deploy_name}-${var.region}"
location = var.region

tags = {
environment = var.environment
}
}

resource "azurerm_virtual_network" "vnet" {
count = var.module_enabled ? 1 : 0
name = "${var.deploy_name}-${var.region}"
location = var.region
address_space = [var.vpc_cidr]
resource_group_name = azurerm_resource_group.network[0].name

tags = {
environment = var.environment
costcenter = "${var.deploy_name}-${var.region}"
}
}

resource "azurerm_subnet" "subnet" {
count = var.module_enabled ? length(var.subnet_names) : 0
name = var.subnet_names[count.index]
virtual_network_name = azurerm_virtual_network.vnet[0].name
resource_group_name = azurerm_resource_group.network[0].name
address_prefixes = [var.subnet_prefixes[count.index]]
enforce_private_link_endpoint_network_policies = var.subnet_names[count.index] == "private" && var.enforce_private_subnet

}
Loading
Loading