<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Julien Topçu</title>
    <description>The latest articles on DEV Community by Julien Topçu (@julientopcu).</description>
    <link>https://dev.to/julientopcu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F218409%2F7501b510-7590-4144-9db4-687b24dff961.jpg</url>
      <title>DEV Community: Julien Topçu</title>
      <link>https://dev.to/julientopcu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/julientopcu"/>
    <language>en</language>
    <item>
      <title>DDD/Hexagonal Architecture Tips &amp; Tricks: Binding the Domain to the Spring Context with ComponentScan</title>
      <dc:creator>Julien Topçu</dc:creator>
      <pubDate>Sun, 28 Jul 2019 00:30:42 +0000</pubDate>
      <link>https://dev.to/julientopcu/ddd-hexagonal-architecture-tips-tricks-binding-the-domain-to-the-spring-context-with-componentscan-kj3</link>
      <guid>https://dev.to/julientopcu/ddd-hexagonal-architecture-tips-tricks-binding-the-domain-to-the-spring-context-with-componentscan-kj3</guid>
      <description>&lt;p&gt;&lt;a href="https://dev.to/julientopcu/hexagonal-architecture-decoupling-your-technical-code-from-your-business-logic-hexarch-2o89-temp-slug-2516502"&gt;Hexagonal Architecture&lt;/a&gt; tells us no framework should be present inside the domain to avoid technical accidental complexity and to ease the migration to a new structural framework (or major version) without redeveloping parts of business logics. This means that when you are using &lt;a href="https://spring.io/"&gt;Spring&lt;/a&gt;, you cannot rely on any stereotype annotations such as &lt;a href="https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/stereotype/Service.html"&gt;@Service&lt;/a&gt; or &lt;a href="https://docs.spring.io/spring/docs/current/javadoc-api/index.html?org/springframework/stereotype/Component.html"&gt;@Component&lt;/a&gt; inside your domain.&lt;/p&gt;

&lt;h1&gt;
  
  
  Beans declaration marathon
&lt;/h1&gt;

&lt;p&gt;As a result, we typically end up with bean factory methods inside Spring Configurations with a lot of boilerplate code for instantiating domain services, repositories and stubs because we think we cannot use the &lt;a href="https://www.baeldung.com/spring-component-scanning"&gt;ComponentScan&lt;/a&gt; for domain objects.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This article will show you how to take advantage of the component scanning without violating the hexagonal architecture rules with code samples in Koltin. If you are working with Java, don’t worry, the code will be around the same, you’ll have to adjust a bit the syntax. Be aware that the maven part of this article is specific to Koltin, you can ignore it if you are not using this language.&lt;/p&gt;

&lt;h1&gt;
  
  
  The Secret: Dependency Inversion
&lt;/h1&gt;

&lt;p&gt;Spring component scanning looks for annotated classes with Spring stereotypes to identify the objects you want to register in the &lt;a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-basics"&gt;ApplicationContext&lt;/a&gt;. So these objects will inevitably have a dependency on the Spring Framework, and this is basically an issue inside the domain. To get rid off this limitation, we will use the same trick used by the hexagonal architecture to ensure that your domain will never be dependent on your persistence layer: a dependency inversion.&lt;/p&gt;

&lt;p&gt;The trick is simple, create descriptive annotations inside your domain that will identify the objects you want to expose to the ApplicationContext – usually DomainServices and Stubs.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The retention policy is set to &lt;a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/annotation/RetentionPolicy.html#RUNTIME"&gt;RUNTIME&lt;/a&gt; to allow Spring to discover them. With the other policies, the annotation would have been discarded at run time, which is not helpful in our case. You can now safely annotate with your custom annotations the domain objects you want to expose.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can also create descriptive annotations for the other DDD objects such as Aggregate, Entity, ValueType, Repository even if you don’t expose them to the ApplicationContext. This is a great technic to onboard people into Domain Driven Design (with some javadoc, see the example below) or simply to better understand your business and how it was modeled.&lt;/p&gt;

&lt;p&gt;This has sometimes been useful to detect some bugs in code reviews. Like a ValueType containing an Entity, a ValueType with side effects… It is sometimes difficult to determine the nature of object we are working on, especially in  &lt;strong&gt;rich&lt;/strong&gt; business domains.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We will now tell Spring to treat those objects like &lt;em&gt;@Service&lt;/em&gt;, &lt;em&gt;@Component&lt;/em&gt; annotated ones, by configuring our custom domain annotation for scanning in the infrastructure. Simply create a DomainConfiguration and annotate as follow:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Beware that the ComponentScan looks by default only in the SpringBootApplication package, including its child packages. Thus, if your domain is not in this inverted hierarchy, you will need to specify a base package class that will identify the root package of your domain (see commented code above). Usually, we use the main domain &lt;strong&gt;Aggregate&lt;/strong&gt; here since a common DDD convention encourages us to name the root domain package after him.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can also use basePackages and give the package name as a String. But this practice is discouraged because not resilient to package refactoring.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And if you are use Java this is pretty much it, you can go directly to the &lt;strong&gt;Limitations&lt;/strong&gt; section. If you are use Kotlin, you’ll be disappointed if you try to run this code. Kotlin follows the &lt;a href="https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle"&gt;open-close principle,&lt;/a&gt; so every class is by default  &lt;strong&gt;final&lt;/strong&gt; , which means it cannot be extended. And for some reasons, maybe for bytecode injection, Spring needs bean classes to be open.&lt;/p&gt;

&lt;p&gt;We will not use the &lt;code&gt;open&lt;/code&gt; keyword of Kotlin to solve this issue because it would be a workaround within the domain to allow the Spring integration. Instead, we will use an out-of-the box solution using Maven.&lt;/p&gt;

&lt;h1&gt;
  
  
  Make SOLID lose its ‘O’
&lt;/h1&gt;

&lt;p&gt;The kotlin maven plugin offers a compilation option named &lt;a href="https://kotlinlang.org/docs/reference/compiler-plugins.html#all-open-compiler-plugin"&gt;all-open&lt;/a&gt;. In this option, you can configure the classes that the kotlin compiler will open out-of-the-box and let Spring do its dirty stuff at run time. To do this, in the pom of your domain, specify the following build plugin with the full qualified name of the annotations you created above:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And now it should work with Kotlin.&lt;/p&gt;

&lt;h1&gt;
  
  
  Limitations
&lt;/h1&gt;

&lt;p&gt;Since everything comes with a price, here are the limits of this method:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you need some conditional or profile-based bean construction, you will have to switch back to a bean factory.&lt;/li&gt;
&lt;li&gt;Subjective: some people dislike annotations.&lt;/li&gt;
&lt;li&gt;If you are using Kotlin, the classes opened by the maven plugin will be now extendable, so it violates the open-close principle.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to go further in the implementation of a Hexagonal Architecture based application using Maven, Koltin and SpringBoot, you can take a look at this &lt;a href="https://gitlab.com/crafts-records/talkadvisor/talkadvisor-back/"&gt;repository&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>domaindrivendesign</category>
      <category>hexagonalarchitecture</category>
    </item>
    <item>
      <title>You have critical security vulnerabilities in your software but you don’t know it yet!</title>
      <dc:creator>Julien Topçu</dc:creator>
      <pubDate>Mon, 08 Oct 2018 22:36:25 +0000</pubDate>
      <link>https://dev.to/julientopcu/you-have-critical-security-vulnerabilities-in-your-software-but-you-don-t-know-it-yet-4p3m</link>
      <guid>https://dev.to/julientopcu/you-have-critical-security-vulnerabilities-in-your-software-but-you-don-t-know-it-yet-4p3m</guid>
      <description>&lt;p&gt;Let’s start with some figures &lt;sup id="fnref-77-1"&gt;1&lt;/sup&gt;&lt;sup id="fnref-77-2"&gt;2&lt;/sup&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;44% of applications contain critical vulnerabilities in open source components.&lt;/p&gt;

&lt;p&gt;88% of Java applications have at least one vulnerability in a component.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Pretty scary! Unless you have a tracking process of the vulnerabilities in your third parties, it is very likely that you have critical security vulnerabilities in your software.&lt;/p&gt;

&lt;h1&gt;
  
  
  The food ain’t that bad man!
&lt;/h1&gt;

&lt;p&gt;Remember this &lt;a href="https://www.youtube.com/watch?v=bgXbq93U4J4" rel="noopener noreferrer"&gt;scene&lt;/a&gt; from the Alien movie where you can see people eating around a table and one of the guy was feeling really really bad. All the people around him didn’t undestand what was going on. And suddenly an infant form of the Alien just burst his chest! Horrible, isn’t it?&lt;/p&gt;

&lt;p&gt;You should see hidden vulnerabilities like an Alien embryo lurking inside the chest of your application. And when it will come out, it may hurt very badly.&lt;/p&gt;

&lt;p&gt;To avoid that, here you’ll learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how to know to identify those aliens and evaluates their dangerousness.&lt;/li&gt;
&lt;li&gt;how to detect if they have infested your dependencies and also how to track them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Know your ennemy…
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F08%2Flineup.jpg%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F08%2Flineup.jpg%3Fw%3D1000" alt="Lineup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All publicly know vulnerabilities are published on the internet as  &lt;strong&gt;Common&lt;/strong&gt;  &lt;strong&gt;Vulnerabilities&lt;/strong&gt;  &lt;strong&gt;and&lt;/strong&gt;  &lt;strong&gt;Exposures&lt;/strong&gt; also called CVE. This is basically a structured report normalized by the &lt;a href="https://www.mitre.org/" rel="noopener noreferrer"&gt;MITRE Corporation&lt;/a&gt; which has an unique ID e.g. &lt;a href="https://nvd.nist.gov/vuln/detail/CVE-2014-0160" rel="noopener noreferrer"&gt;CVE-2014-0160&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In those reports you can find:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The description of the vulnerability which also lists the impacted components with their vulnerable versions.&lt;/li&gt;
&lt;li&gt;Its criticity (we will talk about that later) and impact on the infected software – how bad it can hurt you.&lt;/li&gt;
&lt;li&gt;A list of hyperlinks giving more details on the vulnerability, it can be the analysis of the people who found it and/or an official advisory of the owner of the component which may include a fix.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The US government indexes those CVEs  into the &lt;strong&gt;&lt;a href="https://nvd.nist.gov/" rel="noopener noreferrer"&gt;NIST National Vulnerability Database&lt;/a&gt;&lt;/strong&gt; (totally public) and exposes it through the SCAP protocol. SCAP enables security tools like &lt;a href="https://www.owasp.org/index.php/OWASP_Dependency_Check" rel="noopener noreferrer"&gt;OWASP Dependency-Check&lt;/a&gt; &amp;amp; &lt;a href="https://dependencytrack.org/" rel="noopener noreferrer"&gt;OWASP Dependency-Track&lt;/a&gt; to detect the vulnerabilities inside your third-parties.&lt;/p&gt;

&lt;p&gt;The MITRE corporation also maintain a &lt;a href="https://cwe.mitre.org/" rel="noopener noreferrer"&gt;dictionary&lt;/a&gt; of software weakness types (&lt;strong&gt;Common Weakness Enumeration)&lt;/strong&gt; e.g.:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://cwe.mitre.org/data/definitions/326.html" rel="noopener noreferrer"&gt;CWE-326&lt;/a&gt;:&lt;/strong&gt;  &lt;strong&gt;Inadequate&lt;/strong&gt;  &lt;strong&gt;Encryption&lt;/strong&gt;  &lt;strong&gt;Strength&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://cwe.mitre.org/data/definitions/321.html" rel="noopener noreferrer"&gt;CWE-321&lt;/a&gt;: Use of Hard-coded Cryptographic&lt;/strong&gt;  &lt;strong&gt;Key&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In each CVE reports, you will have a list of CWE weaknesses the vulnerability is exploiting. It is also used by &lt;a href="https://www.gartner.com/it-glossary/static-application-security-testing-sast" rel="noopener noreferrer"&gt;SASTs&lt;/a&gt; to provide you in a standard way the weaknesses of your application. For each weakness, the CWE website provides you a description and some demonstrative examples.&lt;/p&gt;

&lt;p&gt;Reporting of vulnerabilities is great but how could you know how important a vulnerability is ?&lt;/p&gt;

&lt;h2&gt;
  
  
  The Richter Scale
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fgreen_man_x_thanos_3.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fgreen_man_x_thanos_3.png%3Fw%3D1000" alt="Green_Man_X_Thanos_3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to evaluate the criticity of a vulnerability, we have a kind of “Richter Scale” named  &lt;strong&gt;Common&lt;/strong&gt;  &lt;strong&gt;Vulnerability&lt;/strong&gt;  &lt;strong&gt;Scoring&lt;/strong&gt;  &lt;strong&gt;System&lt;/strong&gt;. CVSS is an open industry standard provided by &lt;a href="https://www.first.org/" rel="noopener noreferrer"&gt;first.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It uses some criteria – like do we need to be authenticated to exploit the vulnerability or how confidential are the disclosed information – to compute a vulnerability score between 0 and 10. Where 0 means “that’s nothing” and 10 means “you got big troubles”.&lt;/p&gt;

&lt;p&gt;A &lt;a href="https://www.first.org/cvss/calculator/3.0" rel="noopener noreferrer"&gt;CVSS calculator&lt;/a&gt; is available on internet.&lt;/p&gt;

&lt;h1&gt;
  
  
  The tactical backpack
&lt;/h1&gt;

&lt;p&gt;Now you know everything on “how to identify those aliens and evaluates their dangerousness”. Let’s see now how to build our first #DevSecOps Continuous-Security pipeline using &lt;a href="https://www.owasp.org/index.php/OWASP_Dependency_Check" rel="noopener noreferrer"&gt;OWASP Dependency-Check&lt;/a&gt;, &lt;a href="https://dependencytrack.org/" rel="noopener noreferrer"&gt;OWASP Dependency-Track&lt;/a&gt; and Jenkins, in order to detect those aliens and track them down!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F08%2Fdependencytrack.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F08%2Fdependencytrack.png%3Fw%3D1000" alt="dependencytrack .png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;All of those tools are &lt;strong&gt;open-source&lt;/strong&gt; software, so fork them on github!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/jeremylong/DependencyCheck" rel="noopener noreferrer"&gt;https://github.com/jeremylong/DependencyCheck&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/DependencyTrack/dependency-track" rel="noopener noreferrer"&gt;https://github.com/DependencyTrack/dependency-track&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Dependency-Check is a tool dedicated in the analysis of your dependencies. For each of them, it queries the National Vulnerability Database in order to verify if some CVEs have been reported. Dependency-Check currently supports Java and .NET dependencies analyzis and has experimental analyzers for Python, Ruby, PHP and Node.js applications. This tool is available in different forms: a command line, an Ant task, a Maven/Graddle plugin and a Jenkins plugin. To build our first Continuous-Security pipeline, we will focus here only on the Jenkins plugin which is really easy to use and to setup.&lt;/p&gt;

&lt;p&gt;DependencyCheck reports can be published to SonarQube or Dependency-Track. We will also focus on Dependency-Track, a brand new tool dedicated – like you can imagine – to tracking the detected vulnerabilities inside your application.&lt;/p&gt;

&lt;h1&gt;
  
  
  Introducing Dependency-Track
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-overview.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-overview.png%3Fw%3D1000" alt="DT-overview"&gt;&lt;/a&gt;Dependency-Track overview&lt;/p&gt;

&lt;p&gt;Dependency-Track is a &lt;a href="https://resources.whitesourcesoftware.com/blog-whitesource/software-composition-security-analysis" rel="noopener noreferrer"&gt;Software Composition Analysis (SCA)&lt;/a&gt; tool. For the short story, it brings you visibility on all the open-source components (vulnerabilities and licenses) your porfolio of application uses.  We will focus here only on his vulnerabilities management system. This system integrates with multiple vulnerability databases suc as the &lt;a href="https://nvd.nist.gov/" rel="noopener noreferrer"&gt;National Vulnerability Database&lt;/a&gt;  and the &lt;a href="https://www.npmjs.com/advisories" rel="noopener noreferrer"&gt;NPM Public Advisories&lt;/a&gt; used for the javascript-based projects. The homepage of Dependency-Track is a global &lt;code&gt;Dashboard&lt;/code&gt; summaring the indicators and the analysis trends of the whole portfolio. What will interest us the most is the &lt;code&gt;Projets&lt;/code&gt; page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-projects.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-projects.png%3Fw%3D1000" alt="DT-projects"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you’ll find all the analyzed applications of your portfolio. For each of them you got a sum-up of the potential vulnerabilities found. In red you have the number of the critical ones, orange for the highs and yellow for the mediums.&lt;/p&gt;

&lt;p&gt;Let’s click on an application name to discover its related dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-project-dashboard.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-project-dashboard.png%3Fw%3D1000" alt="DT-project-dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On this page dedicated to a single application, you got a view on all its &lt;code&gt;Dependencies&lt;/code&gt; and also an &lt;code&gt;Audit&lt;/code&gt; view to manage the vulnerabilities. When visiting the&lt;code&gt;Dependencies&lt;/code&gt; tab you’ll get all the libraries with their version used in your software.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-project-dependencies.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-project-dependencies.png%3Fw%3D1000" alt="DT-project-dependencies.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For each of them, the version embedded inside your application is displayed with the number of known vulnerabilities. One cool feature here is the yellow warning symbol which appears when a newer version of the dependency is available. As you can noticed, the analyzed project in the screenshot is a maven one, Dependency-Track is querying the &lt;a href="https://search.maven.org" rel="noopener noreferrer"&gt;maven central repository&lt;/a&gt; to retrieve the last published version of an artefact.&lt;/p&gt;

&lt;p&gt;The sinews of war is the &lt;code&gt;Audit&lt;/code&gt; view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-project-audit.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-project-audit.png%3Fw%3D1000" alt="DT-project-audit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All known vulnerabilities of the versions of your dependencies are listed here with their CVE identifier and their criticity. You have to know &lt;strong&gt;this is not because a known vulnerability exist on a component that you are actually vulnerable&lt;/strong&gt;. You have to review each of them to determine if the vulnerability is exploitable in your own case.&lt;/p&gt;

&lt;p&gt;By clicking on a vulnerability line, you are starting the review process. The description of the vulnerability is displayed and after your review you can set a status in the &lt;code&gt;Analysis&lt;/code&gt;. You can choose between the analysis states documented &lt;a href="https://docs.dependencytrack.org/triage/analysis-states/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When you have determined a vulnerability is a false positive or doesn’t affect your software, you can &lt;a href="https://docs.dependencytrack.org/triage/suppression/" rel="noopener noreferrer"&gt;suppress&lt;/a&gt; it by clicking the Suppress button. As a result this will no longer be taken into account in the different dashboards.&lt;/p&gt;

&lt;p&gt;In your application, if you update a dependency to a version which is fixing a vulnerability, this vulnerability will no longer be reported by Dependency-Check and will disappear from Dependency-Track.&lt;/p&gt;

&lt;p&gt;You can as well get more information on the vulnerability if you click on its CVE identifier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-cve.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-cve.png%3Fw%3D1000" alt="DT-cve"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s mainly the information of the CVE report. The CVSS score is displayed as the &lt;code&gt;Base Score&lt;/code&gt; on the right.&lt;/p&gt;

&lt;p&gt;Dependency-Track also offers an aggregated view of all the dependencies used of the whole portfolio inside the &lt;code&gt;Components&lt;/code&gt; tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-components.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-components.png%3Fw%3D1000" alt="DT-components"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The main feature of this view is the ability to review a vulnerability for the entire portfolio. This is really helpful when you want to suppress false positive/not affected vulnerabilities which are reported on several applications. For that, click on the name of the dependency, go to the &lt;code&gt;Vulnerabilites&lt;/code&gt; tab and activate the &lt;code&gt;Audit Mode&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-components-audit.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-components-audit.png%3Fw%3D1000" alt="DT-components-audit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;be careful of what you are doing to avoid any scaled false negative&lt;/strong&gt;! Note that you cannot choose the projects on which the analysis status will be set, the status will be set globally for the entire portfolio. The &lt;code&gt;Projects&lt;/code&gt;tab will show you all the projects on which this vulnerability has been found.&lt;/p&gt;

&lt;p&gt;Dependency-Track is updating regularly its mirror of the NVD database. As a result it will automatically update the vulnerabilities report of a software if a new vulnerability has been reported. Obviously, if a new dependency or a dependency version has changed in your code base,  Dependency-Track will not know about it. A new Dependency-Check analysis will be required to notify Dependency-Track.&lt;/p&gt;

&lt;p&gt;Need some ChatOps capabilities ? Dependency-Track can &lt;a href="https://docs.dependencytrack.org/integrations/notifications/" rel="noopener noreferrer"&gt;notify your favorite chat tool&lt;/a&gt;!&lt;/p&gt;

&lt;h1&gt;
  
  
  Review Tips &amp;amp; Tricks
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;False Positive ?&lt;/strong&gt; You might have seen that you can set a vulnerability as false positive, but how can it be possible? Well sometimes the CVE report is not enough precise regarding the impacted components. As a result a vulnerability regarding a database server can be reported on your software because you are using the related database driver.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Struggling with the vulnerabilities.&lt;/strong&gt; You’ll see that sometimes this is really hard to figure out if a vulnerability is actually exploitable on your software. Instead of investing a lot in the investigation, you can simply update your dependency to the version where the vulnerability is fixed. In fact, it should be the default behavior to adopt if the new version doesn’t require to rewrite large parts of your application. The older a dependency is, higher is the risk.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;A vulnerability has been found, but you got the very last version of the impacted component. *&lt;/em&gt; The first thing to do, is to look for the criticity and the exploitability of the vulnerability, this is basically given by Dependency-Track on the CVE dedicated page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-cvss.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-cvss.png%3Fw%3D1000" alt="DT-cvss"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might risk waiting for the new version of the component if the vulnerability has a low score, low impact and is difficult to exploit. But if this is critical, you may be able to find a workaround in the links of the CVE report.&lt;/p&gt;

&lt;p&gt;You should also reconsider the use of frameworks that are no longer maintained or are not responsive enough to correct known vulnerabilities.&lt;/p&gt;

&lt;h1&gt;
  
  
  Do your first step into the #DevSecOps!
&lt;/h1&gt;

&lt;h3&gt;
  
  
  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F08%2Fdc.png%3Fw%3D351%26h%3D111" alt="Dependency-Check"&gt;
&lt;/h3&gt;

&lt;p&gt;Install this &lt;a href="https://wiki.jenkins.io/display/JENKINS/OWASP+Dependency-Check+Plugin" rel="noopener noreferrer"&gt;plugin&lt;/a&gt; in your Jenkins instance. If you don’t have any Jenkins yet, you can easily set up one using &lt;a href="https://github.com/jenkinsci/docker/blob/master/README.md" rel="noopener noreferrer"&gt;docker&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By default, Dependency-Check will download a local copy of the NVD database &lt;strong&gt;for every Jenkins job&lt;/strong&gt;. This process can be long (&amp;gt;10 minutes) so it is recommended to configure a dedicated job to download and update a shared database. You can skip the shared database setup for testing purpose.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In &lt;strong&gt;Manage Jenkins&lt;/strong&gt; &amp;gt; &lt;strong&gt;Configure System&lt;/strong&gt; &amp;gt; &lt;strong&gt;Dependency-Check &amp;gt; Global Data Directory&lt;/strong&gt; , Set the path of a shared directory by all your jobs to store the database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F08%2Fdc-globalshareddir.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F08%2Fdc-globalshareddir.png%3Fw%3D1000" alt="DC-globalshareddir"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Setup a dedicated NVD database update job using &lt;strong&gt;a free-form jenkins job&lt;/strong&gt; , and configure it like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-nvd-update-trigger.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-nvd-update-trigger.png%3Fw%3D1000" alt="DC-nvd-update-trigger"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The build trigger will ensures the job will be launched nightly only once a day. It is not required to update the local NVD database more frequently. Now add a new build step &lt;code&gt;Invoke Dependency-Check update only&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-nvd-update-build.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-nvd-update-build.png%3Fw%3D1000" alt="DC-nvd-update-build"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This build step will only update the local NVD database. You don’t need to specify the _Data directory _containing the database dump since you have previously set it globally.&lt;/p&gt;

&lt;p&gt;Run it manually to initiate the database.&lt;/p&gt;

&lt;p&gt;Thanks to this you have a local NVD database instance which is shared among all your jobs.&lt;/p&gt;

&lt;p&gt;Now you can create your first analysis job! Here you just need a job which gather all the dependencies of your application, you can directly download them using the &lt;code&gt;maven-dependency-plugin&lt;/code&gt; using &lt;code&gt;mvn dependency:copy-dependencies&lt;/code&gt; or by unpacking your Spring Boot jar.&lt;/p&gt;

&lt;p&gt;Even better: you don’t have to specify anything if you are using a NPM or a Maven based application. The plugin will automatically detects and scan the &lt;code&gt;package.json&lt;/code&gt;or the &lt;code&gt;pom.xml&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Assuming all yours dependencies are gathered inside  &lt;strong&gt;target/deps/lib/&lt;/strong&gt; , simply add the following *&lt;em&gt;post-build step *&lt;/em&gt; to specify the path to be scanned by Dependency-Check.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-postbuildstep.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-postbuildstep.png%3Fw%3D1000" alt="DC-postbuildstep"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: If you are building a SpringBoot application, you can unpack your jar and your dependencies will be bundled inside the &lt;strong&gt;BOOT-INF/lib/&lt;/strong&gt; (spring-boot-maven-plugin ≥ 1.4) or directly *&lt;em&gt;lib/ *&lt;/em&gt; (spring-boot-maven-plugin &amp;lt; 1.4).&lt;/p&gt;

&lt;p&gt;As an alternative, you can use the &lt;a href="https://jeremylong.github.io/DependencyCheck/dependency-check-maven/index.html" rel="noopener noreferrer"&gt;dependency-check-maven-plugin&lt;/a&gt; which requires a bit more configurations. Additional Dependency-Check integrations are available &lt;a href="https://www.owasp.org/index.php/OWASP_Dependency_Check" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At the end of the analysis, &lt;em&gt;dependency-check-report.xml&lt;/em&gt; will be generated. You can ask the Dependency-Check plugin to publish it inside the jenkins job by adding this following &lt;strong&gt;Post-build Action&lt;/strong&gt; :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-postbuildaction.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-postbuildaction.png%3Fw%3D1000" alt="DC-postbuildaction"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a result, you’ll get a new menu *&lt;em&gt;Dependency-Check Vulnerabilities *&lt;/em&gt; inside your job. You will be able to see here which dependencies have known vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-published-report.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdc-published-report.png%3Fw%3D1000" alt="DC-published-report"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We won’t dig much about it here, since the Jenkins view is a lite version of what Dependency-Track offers. In Jenkins you can only explore the content of the report. With Dependency-Track, you’ll be able to triage those vulnerabilities.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F08%2Fdependency-track-logo-large.png%3Fw%3D351%26h%3D111" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F08%2Fdependency-track-logo-large.png%3Fw%3D351%26h%3D111" alt="Dependency-Track-logo-large"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dependency-Track provides a docker image:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Dependency-Track container &lt;strong&gt;requires 4GB of memory&lt;/strong&gt; , make sure to configure docker accordingly (2GB by default).&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker pull owasp/dependency-track
docker volume create --name dependency-track 
​docker run -d -p 8080:8080 --name dependency-track -v dependency-track:/data owasp/dependency-track
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This docker image allows Dependency-Track to be ran in a standalone mode using an embedded h2 database. This is pretty handy for testing purpose but you &lt;strong&gt;should not use it&lt;/strong&gt; for a real continuous-security pipeline. Dependency-Track offers several &lt;a href="https://docs.dependencytrack.org/getting-started/database-support/" rel="noopener noreferrer"&gt;database integrations&lt;/a&gt; for production mode.&lt;/p&gt;

&lt;p&gt;Dependency-Track also requires a local copy of the NVD database. So during the first run, the initial download of the database may take a while.&lt;/p&gt;

&lt;p&gt;You can now integrate Dependency-Track with Jenkins by installing this &lt;a href="https://wiki.jenkins.io/display/JENKINS/OWASP+Dependency-Track+Plugin" rel="noopener noreferrer"&gt;OWASP Dependency-Track Plugin&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Connect to Dependency-Track using &lt;strong&gt;&lt;a href="http://your-container-ip:8080" rel="noopener noreferrer"&gt;http://your-container-ip:8080&lt;/a&gt;&lt;/strong&gt; and login with &lt;strong&gt;admin:admin&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To create a new project in Dependency-Track, click on the second icon on the left and then on the button &lt;code&gt;+ Create Project&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-create-new-project.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-create-new-project.png%3Fw%3D1000" alt="DT-create-new-project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;Create Project&lt;/code&gt;popup should appear. As project name, enter the name of the software you want to analyze; the other fields are optional.&lt;/p&gt;

&lt;p&gt;The Jenkins plugin requires an API Key, to generate one, go to the &lt;strong&gt;Administration&lt;/strong&gt;   &lt;strong&gt;&amp;gt; Access Management &amp;gt; Teams&lt;/strong&gt; page (the gears icon on the left). In this page you’ll be able to manage the users of Dependency-Track with their permissions. You can also setup Teams of users with specific permissions, by default an &lt;strong&gt;Automation&lt;/strong&gt; team is provided for the external tools that needs to interact with Dependency-Track.&lt;/p&gt;

&lt;p&gt;Click on the Automation team, and copy the existing &lt;strong&gt;API Key&lt;/strong&gt; (or generate a new one).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-apikey1.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-apikey1.png%3Fw%3D1000" alt="DT-apikey"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You will be able to generate API Keys for every teams but not all of them share the same permissions. For example, by default, the Automation team provides enough rights to upload a scan to Dependency-Track (SCAN_UPLOAD), which is not the case of the Portfolio Managers team. As a result, an api key of this last team won’t enable an scan upload.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Go back to Jenkins and navigate to  &lt;strong&gt;Manage Jenkins&lt;/strong&gt; &amp;gt; &lt;strong&gt;Configure System&lt;/strong&gt; &amp;gt; &lt;strong&gt;Dependency-Track&lt;/strong&gt; , fill there the URL of Dependency-Track and the API Key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-url.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-url.png%3Fw%3D1000" alt="DT-url"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tips: If you are running both Dependency-Track and Jenkins inside docker containers, make sure they are connected to the same docker network.&lt;/p&gt;

&lt;p&gt;To create a network between two docker containers, create first your network:&lt;/p&gt;


&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network create &amp;lt;network-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Then connect your containers to it&lt;/p&gt;


&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker network connect &amp;lt;network-name&amp;gt; &amp;lt;container-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;

&lt;p&gt;Now update your Dependency-Check job to add a post-build action in order to publish the vulnerability report to Dependency-Track.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-publish-results.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-publish-results.png%3Fw%3D1000" alt="DT-publish-results"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Dependency-Track project&lt;/strong&gt; , select the name of the project you just created.&lt;br&gt;&lt;br&gt;
Inside &lt;strong&gt;Artifact&lt;/strong&gt; put the path of the Dependency-Check report, usually &lt;code&gt;dependency-check-report.xml&lt;/code&gt; and make sure the &lt;strong&gt;Artifact Type&lt;/strong&gt; is set to &lt;code&gt;Dependency-Check Scan Result (XML)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Run your analysis job and go back to the projects view of Dependency-Track. You should now see the result of the report in the &lt;code&gt;Vulnerabilities&lt;/code&gt; column.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-project-summary.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Fdt-project-summary.png%3Fw%3D1000" alt="DT-project-summary"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dependency-Track also offers a &lt;a href="https://docs.dependencytrack.org/datasources/nvd/" rel="noopener noreferrer"&gt;NVD mirroring feature&lt;/a&gt;, which helps to optimize the Dependency-Check database download process.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Congratulation!!! You just set-up your first Continuous-Security pipeline, #devSecOps FTW! *&lt;/em&gt; And now you can be compliant with one of the best practices of the OWASP TOP10&lt;sup id="fnref-77-3"&gt;3&lt;/sup&gt; &lt;a href="https://www.owasp.org/index.php/Top_10-2017_A9-Using_Components_with_Known_Vulnerabilities" rel="noopener noreferrer"&gt;A9-Using Components with Known Vulnerabilities&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Foptimus_x_garbage_border.png%3Fw%3D1000" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Foptimus_x_garbage_border.png%3Fw%3D1000" alt="Optimus_X_Garbage_border"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Faxel-e1538900952594.png%3Fw%3D368" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.files.wordpress.com%2F2018%2F09%2Faxel-e1538900952594.png%3Fw%3D368" alt="Axel"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Special thanks to Axel Ayigbede from &lt;a href="https://highergroundz.wordpress.com/" rel="noopener noreferrer"&gt;highergroundz&lt;/a&gt; who has made the illustrations!&lt;/p&gt;




&lt;ol&gt;
&lt;li&gt; &lt;a href="https://info.veracode.com/state-of-software-security-2017-top-takeaways-infographic-resource.html" rel="noopener noreferrer"&gt;https://info.veracode.com/state-of-software-security-2017-top-takeaways-infographic-resource.html&lt;/a&gt;  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fs0.wp.com%2Fwp-content%2Fmu-plugins%2Fwpcom-smileys%2Ftwemoji%2F2%2F72x72%2F21a9.png" alt="↩"&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://www.veracode.com/security/open-source-component-risk" rel="noopener noreferrer"&gt;https://www.veracode.com/security/open-source-component-risk&lt;/a&gt;  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fs0.wp.com%2Fwp-content%2Fmu-plugins%2Fwpcom-smileys%2Ftwemoji%2F2%2F72x72%2F21a9.png" alt="↩"&gt;
&lt;/li&gt;
&lt;li&gt; &lt;a href="https://www.owasp.org/index.php/Top_10-2017_Top_10" rel="noopener noreferrer"&gt;https://www.owasp.org/index.php/Top_10-2017_Top_10&lt;/a&gt;  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fs0.wp.com%2Fwp-content%2Fmu-plugins%2Fwpcom-smileys%2Ftwemoji%2F2%2F72x72%2F21a9.png" alt="↩"&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>security</category>
      <category>devsecops</category>
      <category>owasp</category>
    </item>
    <item>
      <title>Hexagonal Architecture: the practical guide for a clean architecture</title>
      <dc:creator>Julien Topçu</dc:creator>
      <pubDate>Sat, 19 Aug 2017 18:00:22 +0000</pubDate>
      <link>https://dev.to/julientopcu/hexagonal-architecture-the-practical-guide-for-a-clean-architecture-1j8n</link>
      <guid>https://dev.to/julientopcu/hexagonal-architecture-the-practical-guide-for-a-clean-architecture-1j8n</guid>
      <description>&lt;p&gt;&lt;em&gt;Did you ever face problems when comes the time to upgrade the stack of your software?&lt;/em&gt; &lt;em&gt;Are you able to distinguish your functional tests from your integration ones? Migrating your legacy means rewriting everything from scratch?&lt;/em&gt;&lt;br&gt;&lt;br&gt;
Discover how the &lt;strong&gt;Hexagonal Architecture&lt;/strong&gt;, a clean architecture pattern also known as Ports and Adapters, can help!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;span&gt;Business logic overboard!&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Separation of concerns: isolating the business logic&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;No frameworks allowed in the domain&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;The Hexagonal Architecture Inversion of Control&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Protecting the domain with an anti-corruption layer&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;The modularity strength of the Hexagonal Architecture&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;How to implement the Hexagonal Architecture?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;A Test-Driven implementation&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Hexagonal Architecture in a nutshell&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;h2 id="businesslogic-overboard"&gt;Business logic overboard!&lt;/h2&gt;

&lt;p&gt;In a previous experience, my team had to port an old application on a brand-new stack. The software was moving from an EAR/SQL app to a self-contained JAR using NoSQL. By studying it, we quickly realized that we had to redo the entire infrastructure. In fact, the only thing that didn’t have to change was the business logic. So, it makes sense to reuse it, right?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fclassic-layered-architecture.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fclassic-layered-architecture.png" alt="a classic layered architecture implementation"&gt;&lt;/a&gt;a classic layered architecture implementation&lt;/p&gt;

&lt;p&gt;After a deeper look, the maven module named model was POJOs with only getters and setters, totally &lt;a href="https://martinfowler.com/bliki/AnemicDomainModel.html" rel="noopener noreferrer"&gt;anemic&lt;/a&gt;… Although there is also service module, the business logic is shared across all the layers. It was drowned in a lot of technical code such as DAOs creation, Serialization, etc. There were no ways to extract the business logic! Some parts of it were relying on the technical behavior of the old framework we tried to remove. And why? Because there was no clean separation between the business logic and the technical code.&lt;/p&gt;

&lt;h2 id="isolating-the-business-logic"&gt;Separation of concerns: isolating the business logic&lt;/h2&gt;

&lt;p&gt;The Hexagonal Architecture created by &lt;a href="https://alistair.cockburn.us/hexagonal-architecture/" rel="noopener noreferrer"&gt;Alistair Cockburn&lt;/a&gt; ensures the re-usability of the business logic by making it technical-agnostic. So, changing the stack will have no impact on the domain code.&lt;/p&gt;

&lt;p&gt;One key concept of this architecture is to put &lt;strong&gt;all the business&lt;/strong&gt;  &lt;strong&gt;logic into a single place&lt;/strong&gt; named the Domain. Let’s update the previous schema:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Foverview-of-a-layered-architecture-1024x488.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Foverview-of-a-layered-architecture-1024x488.png" alt="overview of a layered architecture"&gt;&lt;/a&gt;overview of a layered architecture&lt;/p&gt;

&lt;p&gt;Important constraint: &lt;strong&gt;the domain depends on nothing but itself&lt;/strong&gt; ; this is the only way to ensure that the business logic is decoupled from the technical layers. How do we achieve that on the previous schema? The domain clearly depends on the persistence layer! Well, by using a pattern you may know: the inversion of control. By calling the domain the Hexagon, it will look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Foverview-of-a-hexagonal-architecture.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Foverview-of-a-hexagonal-architecture.png" alt="Overview of a Hexagonal Architecture"&gt;&lt;/a&gt;Overview of a Hexagonal Architecture&lt;/p&gt;

&lt;p&gt;The inversion of control was pretty magic, let’s see later how it works. Now you got an overview of what is the Hexagonal Architecture:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only two worlds, inside and outside the Hexagon. &lt;strong&gt;Inside: all&lt;/strong&gt;  &lt;strong&gt;the business logic&lt;/strong&gt; , &lt;strong&gt;Outside: the infrastructure –&lt;/strong&gt; meaning all your technical code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The dependencies always go from outside toward the inside of the Hexagon&lt;/strong&gt;. It ensures the isolation of the business domain from the technical part.&lt;/li&gt;
&lt;li&gt;One corollary of this is &lt;strong&gt;the Hexagon depends on nothing but itself&lt;/strong&gt;. And not only regarding your own layers: &lt;strong&gt;It must not depend on any technical framework&lt;/strong&gt;. That includes external annotations like Jackson or JPA. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id="no-frameworks"&gt;No frameworks allowed in the domain (almost)&lt;/h2&gt;

&lt;p&gt;Let me explain you a bit more the last point, which is a really important one. In another experience, my team had to port an application from the “classic” Spring framework to Spring Boot. The main (painful) problem we had: leveraging too much on the Spring Integration Tests to validate our functionalities. Furthermore, those functionalities were also too coupled with Spring.&lt;/p&gt;

&lt;p&gt;At the first try of our Spring Boot migration, all functional tests were failing. We were not able to determine if the business logic was broken somewhere or if the reason was purely technical. We eventually figured out that it was an integration problem at test level. So we fixed all the tests one by one by crossing our fingers… Hoping the domain was still correct.&lt;/p&gt;

&lt;p&gt;No framework used in the Hexagon means &lt;strong&gt;the business domain can be reused regardless the change of&lt;/strong&gt;  &lt;strong&gt;the technical stack&lt;/strong&gt;. It will as well &lt;strong&gt;increase the testability of your domain&lt;/strong&gt; since you no longer mix it with integration issues. And at the end, you’ll do &lt;strong&gt;real functional tests&lt;/strong&gt; thanks to this constraint of the Hexagonal Architecture. This way the functional tests will directly interact with the Hexagon and only with it.&lt;/p&gt;

&lt;p&gt;NOTE: In Maven, you can ensure this constraint using the &lt;a href="http://maven.apache.org/enforcer/enforcer-rules/bannedDependencies.html" rel="noopener noreferrer"&gt;enforcer plugin&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id="inversion-of-control"&gt;The Hexagonal Architecture Inversion of Control&lt;/h2&gt;

&lt;p&gt;Remember the inversion of control? To ensure the isolation of the Hexagon, the dependencies on downstream layers have been inverted. The trick is in fact pretty simple as you can see:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fimplementation-of-the-hexagonal-architecture-1024x554.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fimplementation-of-the-hexagonal-architecture-1024x554.png" alt="Implementation of the Hexagonal Architecture"&gt;&lt;/a&gt;Implementation of the Hexagonal Architecture&lt;/p&gt;

&lt;p&gt;The outside of the Hexagon (the infrastructure) is divided in two virtual parts, the left side and the right side. On the left, you got everything that will query the domain (the controller, the REST layer, etc.). And on the right, everything that will provide some information/services to the domain (persistence layer, third party services, etc.).&lt;/p&gt;

&lt;h2 id="acl"&gt;Protecting the domain with an anti-corruption layer&lt;/h2&gt;

&lt;p&gt;To let the outside to interact with the domain, the Hexagon provides &lt;strong&gt;business interfaces&lt;/strong&gt; divided in two categories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;API&lt;/strong&gt; gathers all the interfaces for everything that needs to query the domain. Those interfaces are implemented by the Hexagon.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;SPI&lt;/strong&gt; (Service Provider Interface) gathers all the interfaces required by the domain to retrieve information from third parties. Those interfaces are defined in the Hexagon and implemented by the right side of the infrastructure. We will see that on some circumstances, the Hexagon can also implement the SPI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are two important facts here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The API and the SPI are parts of the Hexagon.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;The API and the SPI only manipulate domain objects of the Hexagon. It indeed ensures the isolation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In a layered architecture, &lt;a href="http://www.oracle.com/technetwork/java/dataaccessobject-138824.html" rel="noopener noreferrer"&gt;the Business Object or the service usually creates the DAOs&lt;/a&gt;. In the Hexagonal Architecture, the domain only handles domain objects. Consequently, the persistence is in charge to translate the domain objects into any “DAOs” to be persisted. This is what we call an adaptation.&lt;/p&gt;

&lt;h2 id="modularity"&gt;The modularity strength of the Hexagonal Architecture&lt;/h2&gt;

&lt;p&gt;As mentioned above, the &lt;strong&gt;Ports and Adapters&lt;/strong&gt; architecture is another name of the Hexagonal Architecture. It comes from &lt;strong&gt;the power of the modularity of this architecture&lt;/strong&gt;. Because everything is decoupled, you can have a REST and JMS layers in front of your domain at the same time without having any impacts on it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fhexagonal-architecture-adapters-modularity-1024x397.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fhexagonal-architecture-adapters-modularity-1024x397.png" alt="Adapters modularity in Hexagonal Architecture"&gt;&lt;/a&gt;Adapters modularity in Hexagonal Architecture&lt;/p&gt;

&lt;p&gt;On the SPI side, you can change from a MongoDB driver implementation to Cassandra if needed. Since the SPI won’t change because you change the persistence module, the rest of your software won’t be impacted. The API and the SPI are the Ports and the infrastructure modules using or implementing them are the adapters.&lt;/p&gt;

&lt;h2 id="howto-implement"&gt;How to implement the Hexagonal Architecture?&lt;/h2&gt;

&lt;p&gt;One more rule here: &lt;strong&gt;always start with the inside of the Hexagon&lt;/strong&gt;. This will bring you a lot of advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Focus on the feature&lt;/strong&gt; instead of the technical details. Because only the feature brings value to your company. A developer working on another business domain is able to put in place a Spring Controller. But the double declining balance method will sound like Wookiee for him unless he worked for an accountancy company.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delay choices on technical implementation.&lt;/strong&gt; Sometimes it’s really hard to know which technical implementation you really need at the beginning. Consequently, delaying this choice helps you to focus on what brings the primary values to your company – the feature. Furthermore, after the implementation of the business logic, some new elements can help you to make the best choice regarding your infrastructure. You can discover that the domain is more relational than expected, so SQL is a good choice for your database.&lt;/li&gt;
&lt;li&gt;One corollary is it ensures the &lt;strong&gt;Hexagon is a stand-alone&lt;/strong&gt;. Since you should never write code without tests, it means that the &lt;strong&gt;Hexagon is self-tested&lt;/strong&gt;. Furthermore, we got here real functional tests focusing on the business only.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id="test-driven-implementation"&gt;A Test-Driven implementation&lt;/h2&gt;

&lt;p&gt;With the Hexagonal Architecture, you put your functional tests in your domain. Those tests will call directly the domain API while avoiding any disturbance from the technical part. In a way you are creating an adapter simulating the Controller to test the features of the domain.&lt;/p&gt;
&lt;h3&gt;
  
  
  Starting with the functional tests of the Domain
&lt;/h3&gt;

&lt;p&gt;My advice is writing your functional scenario first using the &lt;a href="https://beyondxscratch.com/2019/05/21/behavior-driven-development-from-scratch/" rel="noopener noreferrer"&gt;Behavior-Driven Development&lt;/a&gt; to describe your feature.&lt;/p&gt;

&lt;p&gt;The first step of the &lt;a href="https://beyondxscratch.com/2019/05/21/behavior-driven-development-from-scratch/#double-loop" rel="noopener noreferrer"&gt;“double-loop” will produce your functional test using ATDD&lt;/a&gt;. And write the API interface which will be the entry point of your feature. Then implement your tests with TDD and finally implement your business logic. While writing it, you might need to retrieve some data from the database for example, so create an SPI. Since the right side is not yet implemented, create a stubbed implementation of this SPI inside your Hexagon. That can be achieved using an in-memory database implemented with a Map.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Ffunctional-tests-in-hexagonal-architecture.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Ffunctional-tests-in-hexagonal-architecture.png" alt="Functional Tests in Hexagonal Architecture"&gt;&lt;/a&gt;Functional Tests in Hexagonal Architecture&lt;/p&gt;

&lt;p&gt;You can choose to keep the Stubs in the test scope of your application. But you can as well temporarily ship it if needed. For example, once we made the first feature on the Hexagon, we stubbed an external service and the database. Because our client needed us to provide an interface contract, we secondly exported the domain through a REST controller. So we shipped a first version with stubbed data on the right side of the infrastructure. This way, the client was able to see the structure of our data and the expected behavior of the feature. It was much more reliable than creating by hand some JSON samples of our requests and responses because it actually deals with real business constraints.&lt;/p&gt;
&lt;h3&gt;
  
  
  Finishing with the adapters
&lt;/h3&gt;

&lt;p&gt;The next step is usually opening the left side first. This way you can put in place some integration tests on the feature. At this time you can provide &lt;a href="https://projects.spring.io/spring-restdocs/" rel="noopener noreferrer"&gt;some live documentation&lt;/a&gt; and ensure an interface contract with your clients.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fhexagonal-architecture-integration-test-of-a-left-adapter.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fhexagonal-architecture-integration-test-of-a-left-adapter.png" alt="Hexagonal Architecture integration test of a left adapter"&gt;&lt;/a&gt;Hexagonal Architecture integration test of a left adapter&lt;/p&gt;

&lt;p&gt;Finally, open on the right by implementing the SPI of your feature by taking advantage of the integration tests. I strongly recommend your tests to be stand-alone to avoid any instability during build time. You should always mock your third parties using something like &lt;a href="http://wiremock.org/" rel="noopener noreferrer"&gt;Wiremock&lt;/a&gt; for external services or &lt;a href="https://github.com/fakemongo/fongo" rel="noopener noreferrer"&gt;Fongo&lt;/a&gt; to simulate a MongoDB.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fhexagonal-architecture-end-to-end-integration-test.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fbeyondxscratch.com%2Fwp-content%2Fuploads%2F2020%2F08%2Fhexagonal-architecture-end-to-end-integration-test.png" alt="Hexagonal Architecture end-to-end integration test"&gt;&lt;/a&gt;Hexagonal Architecture end-to-end integration test&lt;/p&gt;

&lt;p&gt;Loop the same way for your other features.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/v--zkIEciq4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
Architecture Hexagonale Level 2 : Comment bien écrire ses tests ? by Julien Topçu &amp;amp; Jordan Nourry



&lt;p&gt;For more information, an &lt;a href="https://gitlab.com/crafts-records/talkadvisor/talkadvisor-back/blob/master/TestingStrategy.md" rel="noopener noreferrer"&gt;Hexagonal Architecture Testing Strategy&lt;/a&gt; is available on GitLab which is also described in the talk above 🇫🇷!&lt;/p&gt;

&lt;h2 id="in-a-nutshell"&gt;Hexagonal Architecture in a nutshell&lt;/h2&gt;

&lt;p&gt;So, now we have seen what is Hexagonal Architecture! There is a real benefit in &lt;strong&gt;decoupling the business logic from the technical code&lt;/strong&gt;. It ensures your business domain is &lt;strong&gt;durable and robust&lt;/strong&gt; regarding the continuous evolution of the technology.&lt;/p&gt;

&lt;p&gt;The Hexagonal Architecture offers you a real means to achieve this by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Putting all the business logic in a &lt;strong&gt;single place&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The domain is &lt;strong&gt;isolated and agnostic&lt;/strong&gt; regarding the technical part because &lt;strong&gt;it depends on nothing&lt;/strong&gt; but itself. That’s why &lt;strong&gt;the dependencies always go from outside to the inside of the Hexagon.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The Hexagon &lt;strong&gt;is a stand-alone&lt;/strong&gt; module. Thus, It &lt;strong&gt;increases the testability&lt;/strong&gt; of your domain by writing &lt;strong&gt;real functional tests&lt;/strong&gt; which don’t have to deal with technical issues.&lt;/li&gt;
&lt;li&gt;This architecture offers a &lt;strong&gt;powerful modularity&lt;/strong&gt;. It helps you to write as many adapters as needed with a low impact on the rest of the software. And since the domain is agnostic from the stack &lt;strong&gt;, the stack can be changed without any impact on the business&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;By &lt;strong&gt;always starting with the domain&lt;/strong&gt; , you ensure to bring value to your customer by &lt;strong&gt;focusing on the feature development&lt;/strong&gt;. This way you can &lt;strong&gt;delay choices on technical implementation&lt;/strong&gt; to make the best choice at the right time.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Some feedbacks
&lt;/h2&gt;

&lt;p&gt;Hexagonal Architecture is not suitable for all situations. Like Domain-Driven Design, this is really applicable if you got a real business domain. For an application which transform a data to another format, that’s might be overkill.&lt;/p&gt;

&lt;p&gt;To finish on this, always be pragmatic when you adopt a new technology. As stated before, &lt;em&gt;the Hexagon must not depend on any technical framework&lt;/em&gt;, but exceptionally you can. For example, in our case the Hexagon had three exceptions: Apache Commons Lang3 (StringUtils), SLF4J and the JSR305 of Findbugs. Because we didn’t want to create the wheel since those frameworks had very low impacts on the domain. One good side effect of the Hexagonal Architecture, is that you keep challenging yourself before integrating a new framework. By using this architecture, we reduced the number of dependencies from fifty to only three or four for the domain. And this is very good from a security perspective.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Further readings&lt;/strong&gt;&lt;br&gt;
Want to go further? Checkout those &lt;a href="https://beyondxscratch.com/tag/ddd-hexarch-tipstricks/" rel="noopener noreferrer"&gt;Domain-Driven Design and Hexagonal Architecture tips&amp;amp;tricks series&lt;/a&gt;&lt;br&gt;&lt;br&gt;
You can also find here a great article on the Hexagonal Architecture: &lt;a href="https://softwarecampament.wordpress.com/portsadapters/" rel="noopener noreferrer"&gt;https://softwarecampament.wordpress.com/portsadapters/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
And if you to see some code, you can now find on GitLab a Kotlin/Spring Boot &lt;a href="https://gitlab.com/crafts-records/talkadvisor/talkadvisor-back" rel="noopener noreferrer"&gt;Hexagonal Application&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
French version: &lt;a href="https://beyondxscratch.com/fr/2018/09/11/architecture-hexagonale-le-guide-pratique-pour-une-clean-architecture/" rel="noopener noreferrer"&gt;Architecture Hexagonale : le guide pratique pour une clean architecture&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://beyondxscratch.com/2017/08/19/hexagonal-architecture-the-practical-guide-for-a-clean-architecture/" rel="noopener noreferrer"&gt;Hexagonal Architecture: the practical guide for a clean architecture&lt;/a&gt; appeared first on &lt;a href="https://beyondxscratch.com" rel="noopener noreferrer"&gt;BeyondxScratch&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>domaindrivendesign</category>
      <category>hexagonalarchitecture</category>
      <category>cleanarchitecture</category>
    </item>
  </channel>
</rss>
