<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jessica Roxana Arguello Espinola on Medium]]></title>
        <description><![CDATA[Stories by Jessica Roxana Arguello Espinola on Medium]]></description>
        <link>https://medium.com/@jessica.arguello?source=rss-58b473f4de7f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Sgs5rIRSZn2EXVH4</url>
            <title>Stories by Jessica Roxana Arguello Espinola on Medium</title>
            <link>https://medium.com/@jessica.arguello?source=rss-58b473f4de7f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:53:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jessica.arguello/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to deploy Azure Key Vaults with Terraform]]></title>
            <link>https://medium.com/globant/how-to-deploy-azure-key-vaults-with-terraform-94b04031fa0e?source=rss-58b473f4de7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/94b04031fa0e</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[azure-key-vault]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Jessica Roxana Arguello Espinola]]></dc:creator>
            <pubDate>Fri, 08 Jul 2022 15:39:36 GMT</pubDate>
            <atom:updated>2022-07-08T15:39:36.293Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*7d3f5IX7n0uGc5YZYzMagA.png" /></figure><h3>Introduction</h3><p>When we are developing our applications it is important to take special care of the way we guard our secrets and how we control the access to them. From an unintentional mistake till a malicious attack, there are many reasons why we need to manage our secrets correctly.</p><p>If you are using Azure stack technology, Azure Key Vault is a great cloud service to guard your secrets. It allows you to store secrets like passwords, certificates or cryptographic keys, and you can manage who or what services can access your secrets and you can control which types of permissions they will have.</p><p>In large projects, you will probably work with different products and every product will work with different environments like DEV, TST, UAT and PROD. Therefore you will need a key vault per application and per environment if you follow the best practices. This will allow you to manage your secrets properly and it also will reduce the impact in case of a breach.</p><p>If you have a small amount of projects they are relatively easy to manage, but what happens when you have large projects? Fortunately, today we have different tools and services that can help us. Today, I will talk about Terraform and how we can use it to manage our key vaults.</p><p>Quoting the Terraform official site: “HashiCorp Terraform is an infrastructure as code tool that lets you define both cloud and on-prem resources in human-readable configuration files that you can version, reuse, and share.” Basically it helps you configure your infrastructure as code in a more efficient way. It keeps track of your real infrastructure in a state file, which acts as a source of truth for your environment. Then, you create and configure your terraform files with the changes you want to make to your real infrastructure.</p><p>Considering the above, I will share the scripts I use to maintain our infrastructure for creating the necessary key vaults, assigning the permissions and generating the service connections to integrate it with Azure DevOps.</p><p>In this article, we will discuss the following points:</p><p>1- Requirements: Software that should be running to test this article.</p><p>2- Terraform scripts: all the files with its scripts.</p><p>3-Conclusion: The outcome of this article!</p><p>4-References: If you want to know more about this.</p><h3>Requirements</h3><ol><li>Basic knowledge of Azure</li><li>You will need to have:</li></ol><ul><li>An Azure subscription</li><li>An Azure Devops project</li><li>A resource group already created</li><li>A storage account with one container</li><li>A Personal Access Token(PAT) generated from azure devops</li><li>A client ID and a client secret</li></ul><p>3. Terraform should be installed and configured in the machine where the scripts will run</p><h3>Terraform Scripts</h3><p>The main objectives of these scripts are:</p><ul><li>Creating one key vault per project, one for development and one for testing environment only.</li><li>Creating the service connections needed for Azure Devops.</li><li>Assigning all the permissions for the users who will administrate the key vaults.</li></ul><p>In order to work in a efficient manner, we will have different terraform files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/162/1*_U-wIBtB3y3DLYnkZxMLkw.png" /></figure><h4>variable.tfvars</h4><p>A .tfvars file is a terraform file where you declare your variables. Then in your scripts files, you reference them writing var.$(variable_name).</p><p>So, in this file we are going to write all the variables to use:</p><p>pat= “xxxxxx” → personal access token created at azure devops</p><p>sub_id_dev= “xxxxxx” → your suscription id in azure</p><p>tenant_id= “xxxxxx” → your tenant id</p><p>client_id= “xxxxxx” → your client id</p><p>client_secret= “xxxxxx” → your client secret</p><p>sa_resource_group = “xxxxxx” → storage account resource group</p><p>storage_account= “xxxxxxx” → storage account name</p><p>container_name = “xxxxxx” → container name</p><p>key = “xxxxxx” → name of the file going to be saved at the container</p><p>org_service_url = “xxxxxx” → your organization URL in azure devops</p><h4>00-main.tf</h4><p>We configure our terraform required providers :</p><pre>terraform {<br>  required_providers {<br>    azuredevops = {<br>      source = &quot;microsoft/azuredevops&quot;<br>      version = &quot;0.1.0&quot;<br>    }<br>    <br>    azurerm = {<br>      source  = &quot;hashicorp/azurerm&quot;<br>      version = &quot;=2.46.0&quot;<br>    }</pre><pre>azuread = {<br>      source  = &quot;hashicorp/azuread&quot;<br>      version = &quot;=2.11.0&quot;<br>    }<br>  }<br>  backend &quot;azurerm&quot; {<br>  resource_group_name  = var.sa_resource_group<br>  storage_account_name = var.storage_account<br>  container_name       = var.container_name<br>  key                  = var.key<br>  subscription_id      = var.sub_id_dev<br>  tenant_id            = var.tenant_id<br>  }<br>}</pre><pre>provider &quot;azurerm&quot; {<br>  features {}<br>}</pre><h4>01-providers.tf</h4><p>Configuration of azure devops and azurerm providers:</p><pre>provider &quot;azuredevops&quot; {<br>  org_service_url = var.org_service_url<br>  personal_access_token = var.pat<br>}</pre><pre>provider &quot;azurerm&quot; {<br>  features {}<br>  subscription_id =  var.sub_id_dev<br>  tenant_id = var.tenant_id<br>  client_id       = var.client_id <br>  client_secret   = var.client_secret<br>  alias = &quot;non-prod&quot;<br>}</pre><h4>02-variables.tf</h4><p>Here we define the variables about each one of the projects. We can add the amount of projects we need:</p><ul><li>kv_name = key vault name we will assign for that particular project</li><li>rg_dev = development resource group</li><li>rg_tst = testing resource group</li><li>proyecto_ado = azure devops project’s name</li><li>devops = user’s emails who will have access to modify the key vault.</li></ul><p>This is an example, you have to replace all those variables according to your projects:</p><pre>variable &quot;p_data&quot; {<br>    type = list(object({<br>      kv_name = string,<br>      rg_dev = string,<br>      rg_tst = string,<br>      proyecto_ado = string,<br>      devops = list(string)<br>  <br>  }))<br>  default = [<br>     {<br>      kv_name = &quot;akvname&quot; <br>      rg_dev = &quot;a-dev-rg&quot;<br>      rg_tst = &quot;a-tst-rg&quot;<br>      proyecto_ado = &quot;A_PROJECT&quot;<br>      devops = [&quot;<a href="/service/mailto:devops1@gmail.com">devops1@gmail.com</a>&quot;, &quot;<a href="/service/mailto:devops2@gmail.com">devops2@gmail.com</a>&quot;]<br>      },<br>     {<br>      kv_name = &quot;bkvname&quot; <br>      rg_dev = &quot;b-dev-rg&quot;<br>      rg_tst = &quot;b-tst-rg&quot;<br>      proyecto_ado = &quot;B_PROJECT&quot;<br>      devops = [&quot;<a href="/service/mailto:devops1@gmail.com">devops11@gmail.com</a>&quot;]<br>     },<br>     {<br>      kv_name = &quot;ckvname&quot; <br>      rg_dev = &quot;c-dev-rg&quot;<br>      rg_tst = &quot;c-tst-rg&quot;<br>      proyecto_ado = &quot;C_PROJECT&quot;<br>      devops = [&quot;<a href="/service/mailto:devops3@gmail.com">devops3@gmail.com</a>&quot;, &quot;<a href="/service/mailto:devops4@gmail.com">devops4@gmail.com</a>&quot;, &quot;<a href="/service/mailto:devops5@gmail.com">devops5@gmail.com</a>&quot;]<br>     }<br>  ]<br>}</pre><pre>data &quot;azurerm_subscription&quot; &quot;s_non_prod&quot; {<br>  subscription_id = var.sub_id_dev<br>  provider = azurerm.non-prod<br>}</pre><h4>03-servicep.tf</h4><p>To generate the integration between key vaults and azure devops projects, we will need to create a service principal for each key vault. This will allows us to create the service connections later.</p><pre>data &quot;azuread_client_config&quot; &quot;current&quot; {}</pre><pre>#Service principal<br>resource &quot;azuread_application&quot; &quot;app-non-prod&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p} <br>  display_name = &quot;KV-${each.value.kv_name}&quot;<br>  owners       = [data.azuread_client_config.current.object_id]<br>}</pre><pre>resource &quot;azuread_service_principal&quot; &quot;sp-non-prod&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}<br>  application_id               = azuread_application.app-non-prod[each.value.kv_name].application_id<br>  app_role_assignment_required = false<br>  owners                       = [data.azuread_client_config.current.object_id]</pre><pre>feature_tags {<br>    enterprise = true<br>    gallery    = true<br>  }<br>}</pre><pre>resource &quot;azuread_service_principal_password&quot; &quot;sp-non-prod-passwd&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}<br>  service_principal_id = azuread_service_principal.sp-non-prod[each.value.kv_name].object_id<br>}</pre><h4>04-roleAssign.tf</h4><p>We must assign the role “Contributor” to the previous service principals created in each one of the key vaults.</p><pre>#Resource group from each environment</pre><pre>data &quot;azurerm_resource_group&quot; &quot;dev-rg&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}<br>  name = each.value.rg_dev<br>  provider = azurerm.non-prod<br>}</pre><pre>data &quot;azurerm_resource_group&quot; &quot;tst-rg&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}<br>  name = each.value.rg_tst<br>  provider = azurerm.non-prod<br>}</pre><pre># Assign Contributor permission to the service principals</pre><pre>resource &quot;azurerm_role_assignment&quot; &quot;sp-dev-roleassignment&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}<br>  scope              = data.azurerm_resource_group.dev-rg[each.value.kv_name].id<br>  role_definition_name = &quot;Contributor&quot;<br>  principal_id       = azuread_service_principal.sp-non-prod[each.value.kv_name].object_id<br>  depends_on = [resource.azuread_service_principal.sp-non-prod]<br>  provider = azurerm.non-prod<br>}</pre><pre>resource &quot;azurerm_role_assignment&quot; &quot;sp-tst-roleassignment&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}<br>  scope              = data.azurerm_resource_group.tst-rg[each.value.kv_name].id<br>  role_definition_name = &quot;Contributor&quot;<br>  principal_id       = azuread_service_principal.sp-non-prod[each.value.kv_name].object_id<br>  depends_on = [resource.azuread_service_principal.sp-non-prod]<br>  provider = azurerm.non-prod<br>}</pre><h4>05-keyvaults.tf</h4><p>In this file, we will create the key vaults per project. One per environment: dev and tst.</p><pre>data &quot;azurerm_resource_group&quot; &quot;rg_dev&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}<br>  name = each.value.rg_dev<br>  provider = azurerm.non-prod<br>}</pre><pre>data &quot;azurerm_resource_group&quot; &quot;rg_tst&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}<br>  name = each.value.rg_tst<br>  provider = azurerm.non-prod</pre><pre>}</pre><pre>resource &quot;azurerm_key_vault&quot; &quot;kv-dev&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}  <br>  name                        = &quot;${each.value.kv_name}-dev&quot;<br>  location                    = data.azurerm_resource_group.rg_dev[each.value.kv_name].location<br>  resource_group_name         = data.azurerm_resource_group.rg_dev[each.value.kv_name].name<br>  enabled_for_disk_encryption = true<br>  tenant_id                   = data.azurerm_subscription.s_non_prod.tenant_id<br>  soft_delete_retention_days  = 14<br>  purge_protection_enabled    = true<br>  provider = azurerm.non-prod <br>  sku_name = &quot;standard&quot;<br>  depends_on = [azuread_service_principal.sp-non-prod]</pre><pre>}</pre><pre>resource &quot;azurerm_key_vault&quot; &quot;kv-tst&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}  <br>  name                        = &quot;${each.value.kv_name}-tst&quot;<br>  location                    = data.azurerm_resource_group.rg_tst[each.value.kv_name].location<br>  resource_group_name         = data.azurerm_resource_group.rg_tst[each.value.kv_name].name<br>  enabled_for_disk_encryption = true<br>  tenant_id                   = data.azurerm_subscription.s_non_prod.tenant_id<br>  soft_delete_retention_days  = 14<br>  purge_protection_enabled    = true<br>  provider = azurerm.non-prod<br>  sku_name = &quot;standard&quot;<br>  depends_on = [azuread_service_principal.sp-non-prod]</pre><pre>}</pre><h4>06-sc.tf</h4><p>Creation of the service connections in each Azure DevOps Project.</p><pre>resource &quot;azuredevops_serviceendpoint_azurerm&quot; &quot;sc-akv-non-prod&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}<br>  project_id            = each.value.proyecto_ado<br>  service_endpoint_name     = upper(&quot;KV-${each.value.kv_name}-NON-PROD&quot;)<br>  description = &quot;Managed by Terraform&quot; <br>  azurerm_spn_tenantid      = data.azurerm_subscription.s_non_prod.tenant_id<br>  azurerm_subscription_id   = data.azurerm_subscription.s_non_prod.subscription_id<br>  azurerm_subscription_name = data.azurerm_subscription.s_non_prod.display_name<br>  credentials {<br>    serviceprincipalid  = azuread_service_principal.sp-non-prod[each.value.kv_name].application_id<br>    serviceprincipalkey = azuread_service_principal_password.sp-non-prod-passwd[each.value.kv_name].value<br>  }<br>}</pre><h4>07-accesspolicy.tf</h4><p>The access policy is the permission we give at each key vault to create, get, delete secrets and more.</p><p>In this file, we assign the access policy to all the users we defined in the 02-variables.tf with the list of permissions we require.</p><p>And we also assign the access policy to the service principals of the service connections with “get” and “list” permissions.</p><pre>locals {</pre><pre>flattened-pdata =  flatten([<br>    for pos, kv in var.p_data : [<br>      for pos2, devops in var.p_data[pos].devops : {<br>        kv_name = kv.kv_name<br>        devops_name = kv.devops[pos2]<br>    }]<br>  ])<br>}</pre><pre>data &quot;azuread_user&quot; &quot;user-ad&quot; {<br>   for_each = {<br>    for devops in local.flattened-pdata : &quot;${devops.kv_name}.${devops.devops_name}&quot; =&gt; devops<br>    }</pre><pre>user_principal_name = each.value.devops_name<br>}</pre><pre>#Access policy assign to devops</pre><pre>#DEV<br>resource &quot;azurerm_key_vault_access_policy&quot; &quot;kv-pol-devops-dev&quot; {</pre><pre>for_each = {<br>    for devops in local.flattened-pdata : &quot;${devops.kv_name}.${devops.devops_name}&quot; =&gt; devops<br>    }</pre><pre>key_vault_id = azurerm_key_vault.kv-dev[each.value.kv_name].id<br>      tenant_id = data.azurerm_subscription.s_non_prod.tenant_id<br>      object_id = data.azuread_user.user-ad[&quot;${each.value.kv_name}.${each.value.devops_name}&quot;].object_id</pre><pre>key_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,&quot;update&quot;,&quot;create&quot;,&quot;import&quot;,&quot;delete&quot;,&quot;recover&quot;,&quot;backup&quot;,&quot;restore&quot;,<br>      ]</pre><pre>secret_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,&quot;set&quot;,&quot;delete&quot;,&quot;recover&quot;,&quot;backup&quot;,&quot;restore&quot;,<br>      ]</pre><pre>storage_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,<br>      ]  <br>      depends_on = [<br>        azurerm_key_vault.kv-dev<br>      ]<br>      provider = azurerm.non-prod<br>}</pre><pre>#TST<br>resource &quot;azurerm_key_vault_access_policy&quot; &quot;kv-pol-devops-tst&quot; {</pre><pre>for_each = {<br>    for devops in local.flattened-pdata : &quot;${devops.kv_name}.${devops.devops_name}&quot; =&gt; devops<br>    }</pre><pre>key_vault_id = azurerm_key_vault.kv-tst[each.value.kv_name].id<br>      tenant_id = data.azurerm_subscription.s_non_prod.tenant_id<br>      object_id = data.azuread_user.user-ad[&quot;${each.value.kv_name}.${each.value.devops_name}&quot;].object_id</pre><pre>key_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,&quot;update&quot;,&quot;create&quot;,&quot;import&quot;,&quot;delete&quot;,&quot;recover&quot;,&quot;backup&quot;,&quot;restore&quot;,<br>      ]</pre><pre>secret_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,&quot;set&quot;,&quot;delete&quot;,&quot;recover&quot;,&quot;backup&quot;,&quot;restore&quot;,<br>      ]</pre><pre>storage_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,<br>      ]<br>    <br>     depends_on = [<br>        azurerm_key_vault.kv-tst<br>      ]<br>      provider = azurerm.non-prod<br>}</pre><pre>#Access policy assign to service connection&#39;s service principals.</pre><pre>#DEV<br>resource &quot;azurerm_key_vault_access_policy&quot; &quot;kv-pol-sp-dev&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}</pre><pre>key_vault_id = azurerm_key_vault.kv-dev[each.value.kv_name].id<br>  tenant_id = data.azurerm_subscription.s_non_prod.tenant_id<br>  object_id = azuread_service_principal.sp-non-prod[each.value.kv_name].object_id</pre><pre>key_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,<br>    ]</pre><pre>secret_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,<br>    ]</pre><pre>storage_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,<br>    ]</pre><pre>depends_on = [<br>        azurerm_key_vault.kv-dev<br>    ]</pre><pre>provider = azurerm.non-prod<br>}<br>#TST</pre><pre>resource &quot;azurerm_key_vault_access_policy&quot; &quot;kv-pol-sp-tst&quot; {<br>  for_each = {for p in var.p_data:  p.kv_name =&gt; p}</pre><pre>key_vault_id = azurerm_key_vault.kv-tst[each.value.kv_name].id<br>  tenant_id = data.azurerm_subscription.s_non_prod.tenant_id<br>  object_id = azuread_service_principal.sp-non-prod[each.value.kv_name].object_id<br>  <br>   key_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,<br>    ]</pre><pre>secret_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,<br>    ]</pre><pre>storage_permissions = [<br>      &quot;get&quot;,&quot;list&quot;,<br>    ]<br>  <br>   depends_on = [<br>        azurerm_key_vault.kv-tst<br>    ]<br>   provider = azurerm.non-prod<br>}</pre><h3>Script execution</h3><p>To execute these scripts you have to write in the command line the following steps:</p><ol><li>terraform init → it initializes the terraform.</li><li>terraform plan -var-file=variables.tfvars → it generates a plan in the command line about the changes it would do, using the file with your variables “variables.tfvars”.</li><li>terraform apply -var-file=variables.tfvars → it will apply your changes if you confirm to “yes”. See the example:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*bKptI5WGN7EFPfRRmlotYg.png" /></figure><h3>Conclusions</h3><p>Terraform is a powerful tool to maintain a big amount of services in our infraestructure. This was only one example about how we can use Terraform to mantain key vaults but we can apply this solution in any other services. In this way, we are efficient, save a lot of time, and have more control over our key vaults.</p><h3>References</h3><ol><li><a href="https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs">https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs</a></li><li><a href="https://docs.microsoft.com/en-us/azure/key-vault/general/overview">https://docs.microsoft.com/en-us/azure/key-vault/general/overview</a></li></ol><p>Thanks to <a href="https://medium.com/u/f7acacf97957">Pablo Rubini</a> for the help in the creation of this tasks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94b04031fa0e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/how-to-deploy-azure-key-vaults-with-terraform-94b04031fa0e">How to deploy Azure Key Vaults with Terraform</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OWASP ZAP integration with Jenkins]]></title>
            <link>https://medium.com/globant/owasp-zap-integration-with-jenkins-795d65991404?source=rss-58b473f4de7f------2</link>
            <guid isPermaLink="false">https://medium.com/p/795d65991404</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[owaspzap]]></category>
            <dc:creator><![CDATA[Jessica Roxana Arguello Espinola]]></dc:creator>
            <pubDate>Wed, 13 Oct 2021 22:01:32 GMT</pubDate>
            <atom:updated>2021-10-14T13:30:39.956Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*GquNoYKcrLxjNM8pyPxUgw.png" /></figure><h3>Introduction</h3><p>For developing applications, today we have different tools that can help us to achieve building a secure application. They can be grouped into categories according to their functionality like SS (Secret Search), DAST (Dynamic Application Security Testing), SAST (Static Application Security Testing), SCA (Software Composition Analysis), etc.</p><p>Those tools can be used separately to test applications, but we can also integrate them into orchestration tools that nowadays are used to compile, test and deploy our software, automating and facilitating the continuous integration and continuous delivery/deployment of our applications.</p><p>This article will be focusing on describing how to integrate one of those security tools into an orchestration pipeline. We are talking about OWASP ZAP (Zed Attack Proxy) and Jenkins.</p><p>OWASP ZAP is one of the options we have as part of the DAST (Dynamic Application Security Testing) security techniques. It is a free and open-source scanner that performs penetration tests on web applications/services during runtime in order to detect vulnerabilities.</p><p>Although OWASP ZAP is a tool that can be used manually and punctually for testing a specific web application, we can integrate and automate it within a Continuous Integration pipeline taking the advantages of doing this. With the continuous testing in each building phase, it will allow us to detect vulnerabilities earlier.</p><p>On the other side we have Jenkins, a continuous integration server, free, open-source and a very popular tool being used nowadays.</p><p>In this article, we will discuss the below points:<br><strong>1- Requirements:</strong> Software that should be running to test this article<br><strong>2- Integration of OWASP ZAP</strong>: A baseline script that will enable the integration<br><strong>3- Pipeline in Jenkins:</strong> The configurations that you should be doing<br><strong>4- Conclusions:</strong> The outcome of this article!<br><strong>5- References:</strong> If you want to know more about this</p><h3>Requirements</h3><ol><li>You will need to have Jenkins installed.</li><li>Docker should be installed in the Jenkins machine</li></ol><h3>Integration of OWASP ZAP</h3><h4>Creating a script</h4><p>We will use the following script that will be incorporated when creating the pipeline in Jenkins.</p><pre>def scan_type<br> def target<br> pipeline {<br>     agent any<br>     parameters {<br>         choice  choices: [&quot;Baseline&quot;, &quot;APIS&quot;, &quot;Full&quot;],<br>                 description: &#39;Type of scan that is going to perform inside the container&#39;,<br>                 name: &#39;SCAN_TYPE&#39;<br> <br>         string defaultValue: &quot;https://example.com&quot;,<br>                 description: &#39;Target URL to scan&#39;,<br>                 name: &#39;TARGET&#39;<br> <br>         booleanParam defaultValue: true,<br>                 description: &#39;Parameter to know if wanna generate report.&#39;,<br>                 name: &#39;GENERATE_REPORT&#39;<br>     }<br>     stages {<br>         stage(&#39;Pipeline Info&#39;) {<br>                 steps {<br>                     script {<br>                         echo &quot;&lt;--Parameter Initialization--&gt;&quot;<br>                         echo &quot;&quot;&quot;<br>                         The current parameters are:<br>                             Scan Type: ${params.SCAN_TYPE}<br>                             Target: ${params.TARGET}<br>                             Generate report: ${params.GENERATE_REPORT}<br>                         &quot;&quot;&quot;<br>                     }<br>                 }<br>         }<br> <br>         stage(&#39;Setting up OWASP ZAP docker container&#39;) {<br>             steps {<br>                 script {<br>                         echo &quot;Pulling up last OWASP ZAP container --&gt; Start&quot;<br>                         sh &#39;docker pull owasp/zap2docker-stable&#39;<br>                         echo &quot;Pulling up last VMS container --&gt; End&quot;<br>                         echo &quot;Starting container --&gt; Start&quot;<br>                         sh &quot;&quot;&quot;<br>                         docker run -dt --name owasp \<br>                         owasp/zap2docker-stable \<br>                         /bin/bash<br>                         &quot;&quot;&quot;<br>                 }<br>             }<br>         }<br> <br> <br>         stage(&#39;Prepare wrk directory&#39;) {<br>             when {<br>                         environment name : &#39;GENERATE_REPORT&#39;, value: &#39;true&#39;<br>             }<br>             steps {<br>                 script {<br>                         sh &quot;&quot;&quot;<br>                             docker exec owasp \<br>                             mkdir /zap/wrk<br>                         &quot;&quot;&quot;<br>                     }<br>                 }<br>         }<br> <br> <br>         stage(&#39;Scanning target on owasp container&#39;) {<br>             steps {<br>                 script {<br>                     scan_type = &quot;${params.SCAN_TYPE}&quot;<br>                     echo &quot;----&gt; scan_type: $scan_type&quot;<br>                     target = &quot;${params.TARGET}&quot;<br>                     if(scan_type == &quot;Baseline&quot;){<br>                         sh &quot;&quot;&quot;<br>                             docker exec owasp \<br>                             zap-baseline.py \<br>                             -t $target \<br>                             -x report.xml \<br>                             -I<br>                         &quot;&quot;&quot;<br>                     }<br>                     else if(scan_type == &quot;APIS&quot;){<br>                         sh &quot;&quot;&quot;<br>                             docker exec owasp \<br>                             zap-api-scan.py \<br>                             -t $target \<br>                             -x report.xml \<br>                             -I<br>                         &quot;&quot;&quot;<br>                     }<br>                     else if(scan_type == &quot;Full&quot;){<br>                         sh &quot;&quot;&quot;<br>                             docker exec owasp \<br>                             zap-full-scan.py \<br>                             -t $target \<br>                             //-x report.xml<br>                             -I<br>                         &quot;&quot;&quot;<br>                         //-x report-$(date +%d-%b-%Y).xml<br>                     }<br>                     else{<br>                         echo &quot;Something went wrong...&quot;<br>                     }<br>                 }<br>             }<br>         }<br>         stage(&#39;Copy Report to Workspace&#39;){<br>             steps {<br>                 script {<br>                     sh &#39;&#39;&#39;<br>                         docker cp owasp:/zap/wrk/report.xml ${WORKSPACE}/report.xml<br>                     &#39;&#39;&#39;<br>                 }<br>             }<br>         }<br>     }<br>     post {<br>             always {<br>                 echo &quot;Removing container&quot;<br>                 sh &#39;&#39;&#39;<br>                     docker stop owasp<br>                     docker rm owasp<br>                 &#39;&#39;&#39;<br>             }<br>         }<br> }</pre><h4>Script Content</h4><p>This script has two important sections that will be briefly detailed to understand it better.</p><p><strong>PARAMETERS</strong></p><p>Parameters will be the data we must complete each time we want to carry out an execution of the pipeline. We have three types:</p><p><em>SCAN_TYPE:</em><strong> </strong>scan type that will be executed.</p><p>OWASP ZAP offers three different scan types. We must choose the one we need in every case: Baseline Scan, Full Scan or API Scan.</p><p><a href="https://www.zaproxy.org/docs/docker/about/">ZAP Docker User Guide</a></p><p><em>TARGET:</em> the URL of the web page or API that we want to analyze.</p><p><em>GENERATE_REPORT:</em><strong> </strong>the option to choose if we want to obtain a report at the end of the execution.</p><p><strong>STAGES</strong></p><p>Below, there are the stages that we are going to include in Jenkins’s pipeline:</p><p><em>PIPELINE INFO:</em><strong> </strong>parameter data.</p><p><em>SETTING UP OWASP ZAP DOCKER CONTAINER:</em> pull from the OWASP ZAP docker image.</p><p>There are different types of docker images: stable-release, latest weekly release, live release, bare release. We must choose the one that best suits our needs. These images can be found on Docker Hub:</p><p><a href="https://hub.docker.com/u/owasp">Docker Hub</a></p><p><em>PREPARE WRK DIRECTORY: </em>This stage will create a folder called “wrk” which will save the results when the option to generate reports is chosen. We do this because the OWASP ZAP docker image does not have a folder.</p><p><em>SCANNING TARGET ON OWASP CONTAINER:</em><strong> </strong>It is the execution of the scan according to the scan type we choose.</p><p><em>COPY REPORT TO WORKSPACE:</em><strong> </strong>If we choose the option to generate a report, this stage will copy the report into our repository within Jenkins.</p><h3>Pipeline in Jenkins</h3><p>Now we must complete the following steps to create a pipeline in Jenkins:</p><ol><li>Create a new pipeline</li></ol><p>Let’s tick the option <em>“This project is parameterized”.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*xm1Ml9QpsV4XydBbi69PNA.png" /></figure><p>2. We add the script mentioned at the beginning (copy &amp; paste the script)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*V910dGmI4tsa-R1H7q8zFA.png" /></figure><p>3. We save and execute by selecting “build now”. Once the “build with Parameters” option appears, we proceed to cancel it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/221/1*fMA6ezD6hL4xKxKrvthMnA.png" /></figure><p>4. Select “Build with parameters”, add the scan options and execute the build until it is finished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*wNJ6vx6zW3fCKmkSiFASAg.png" /></figure><p>5. If we previously chose the option to generate a report, it will be found in the Workspace folder when the pipeline is executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*4CpRqCcRJ0oZeu4Qp28QUQ.png" /></figure><h3>Conclusions</h3><p>Performing this OWASP ZAP integration with Jenkins is simple and free. You can start using it from the beginning of your project with no cost and obtaining great benefits. You will detect vulnerabilities earlier and you will deliver a safer application for your clients.</p><p>Take into account that you can also complement this tool with other vulnerabilities scan.</p><h3>References</h3><ol><li><a href="https://www.zaproxy.org/docs/">https://www.zaproxy.org/docs/</a></li><li><a href="https://www.zaproxy.org/docs/docker/about/">https://www.zaproxy.org/docs/docker/about/</a></li><li><a href="https://www.jenkins.io/">https://www.jenkins.io/</a></li><li><a href="https://www.globant.com/studio/cybersecurity">https://www.globant.com/studio/cybersecurity</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=795d65991404" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/owasp-zap-integration-with-jenkins-795d65991404">OWASP ZAP integration with Jenkins</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>