tag:blogger.com,1999:blog-89680853595180596462024-03-13T18:27:44.891+01:00La vie tortueuse d'un DevopsFabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.comBlogger27125tag:blogger.com,1999:blog-8968085359518059646.post-59287730986947084622018-07-23T16:36:00.000+02:002018-07-23T16:36:00.729+02:00Gradle erreur : the trustAnchors parameter must be non-empty<h2>
Problème</h2>
<div>
Lancement de build gradle lance l'erreur suivante : </div>
<div>
<div>
<span style="font-size: xx-small;">Exception in thread "main" javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.Alerts.getSSLException(Alerts.java:214)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1974)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1926)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1909)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1436)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:567)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1581)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:245)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at org.gradle.wrapper.Download.downloadInternal(Download.java:66)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at org.gradle.wrapper.Download.download(Download.java:51)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at org.gradle.wrapper.Install$1.call(Install.java:62)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at org.gradle.wrapper.Install$1.call(Install.java:48)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at org.gradle.wrapper.Install.createDist(Install.java:48)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)</span></div>
<div>
<span style="font-size: xx-small;">Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:89)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.validator.Validator.getInstance(Validator.java:181)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:330)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrustedInit(X509TrustManagerImpl.java:180)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:192)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:133)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.ClientHandshaker.checkServerCerts(ClientHandshaker.java:1947)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.ClientHandshaker.certificateStatus(ClientHandshaker.java:1798)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:276)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.Handshaker.processLoop(Handshaker.java:1098)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.Handshaker.processRecord(Handshaker.java:1026)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.processInputRecord(SSLSocketImpl.java:1137)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1074)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1402)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1429)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>... 14 more</span></div>
<div>
<span style="font-size: xx-small;">Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/java.security.cert.PKIXBuilderParameters.<init>(PKIXBuilderParameters.java:104)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>at java.base/sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:86)</span></div>
<div>
<span style="font-size: xx-small;"><span style="white-space: pre;"> </span>... 29 more</span></div>
</div>
<div>
<br /></div>
<h2>
Solution</h2>
<div>
Le problème venait de la version du jdk que j'utilise (version 10), après installation d'un jdk 8 et modification dans le path de la version de java le build se fait correctement. </div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-75125588073960860202018-06-08T14:25:00.004+02:002018-06-08T14:25:53.749+02:00Mettre en place le plugin OWASP dependency check dans les projets SONAR<h2>
Problématique</h2>
<div>
Comment mesurer les potentielles failles de sécurité induites par les dépendances présentes dans le projet Java que je développe ? </div>
<div>
<br /></div>
<h2>
Solution </h2>
<div>
Utilisation du plugin <a href="https://github.com/jeremylong/DependencyCheck" target="_blank">maven dependency check</a> et du <a href="https://github.com/stevespringett/dependency-check-sonar-plugin" target="_blank">plugin sonar associé</a> afin d'avoir un indicateur dans sonarqube :</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga-Idk7STu7K1OzA5qtrYKVkptow02lhwjp3c5OtqJJhPqhcKbnPLe6Fb5BV93hNwnG-RCk69PCEtmF7EwteRV4aodjhc4ujGF_hJ9z8AEvuH2dTTH_Trxihp8lmA80HQ3acuDpWI0tO5A/s1600/Capture+du+2018-06-08+13-17-24.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="176" data-original-width="566" height="196" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga-Idk7STu7K1OzA5qtrYKVkptow02lhwjp3c5OtqJJhPqhcKbnPLe6Fb5BV93hNwnG-RCk69PCEtmF7EwteRV4aodjhc4ujGF_hJ9z8AEvuH2dTTH_Trxihp8lmA80HQ3acuDpWI0tO5A/s640/Capture+du+2018-06-08+13-17-24.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Cette solution a été sur les version de composants suivants : </div>
<div>
<ul>
<li>Sonarqube 1.1</li>
<li>Maven 3.3.9</li>
<li>dependency-check-maven 3.2.1</li>
<li>sonar-maven-plugin 3.2</li>
<li>sonar-dependency-check-plugin 1.1.0</li>
</ul>
<div>
<br /></div>
</div>
<h3>
Mise en place dans Maven</h3>
<div>
Dans le pom du projet ajouter les plugin suivants ainsi que les propriétés : </div>
<div>
<br /></div>
<div>
<span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">properties</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
...
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">sonar.dependencyCheck.reportPath</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">${dependency.check.report.dir}/dependency-check-report.xml</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">sonar.dependencyCheck.reportPath</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">sonar.dependencyCheck.htmlReportPath</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">${dependency.check.report.dir}/dependency-check-report.html</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">sonar.dependencyCheck.htmlReportPath</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">properties</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">build</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
...
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">plugins</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
...
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">plugin</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">groupId</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">org.codehaus.mojo</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">groupId</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">artifactId</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">sonar-maven-plugin</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">artifactId</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">version</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">3.2</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">version</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">plugin</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">plugin</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">groupId</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">org.owasp</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">groupId</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">artifactId</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">dependency-check-maven</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">artifactId</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">version</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">3.2.1</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">version</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">configuration</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">format</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">ALL</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">format</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">outputDirectory</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">${dependency.check.report.dir}</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">outputDirectory</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">configuration</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">executions</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">execution</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">phase</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">package</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">phase</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">goals</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><<span class="hljs-name">goal</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">check</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">goal</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">goals</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">execution</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">executions</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">plugin</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">plugins</span>></span><span style="background-color: white; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;">
</span><span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></<span class="hljs-name">build</span>></span></div>
<div>
<span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><br /></span></div>
<div>
<br /></div>
<div>
<span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"></span><br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: "Times New Roman"; font-size: medium; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
</div>
<br />
<h3 style="-webkit-text-stroke-width: 0px; color: black; font-family: "Times New Roman"; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; letter-spacing: normal; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
Mise en place dans Sonarqube</h3>
</div>
<div>
1. Cloner le dépôt GIT :</div>
<blockquote class="tr_bq">
git clone git@github.com:stevespringett/dependency-check-sonar-plugin.git</blockquote>
<div>
2. Se positionner sur le tag 1.1.0 :</div>
<blockquote class="tr_bq">
git checkout 1.1.0</blockquote>
3. Builder le plugin :<br />
<blockquote class="tr_bq">
mvn clean package</blockquote>
4. Dans le répertoire {project_dir}/sonar-dependency-check-plugin/target doit se trouver le plugin : <br />
<blockquote class="tr_bq">
sonar-dependency-check-plugin-1.1.0.jar</blockquote>
5. Copier le jar dans le répertoire {sonarqube_install}/extensions/plugins/ de sonarqube<br />
<br />
6. Redémarrer Sonarqube<br />
<br />
<h3>
Création du rapport contenant les vulnérabilités </h3>
<blockquote class="tr_bq">
mvn clean package</blockquote>
Une fois le build effectué vous trouverez dans le /target du projet les fichiers dependency-check-report.* contenant les informations sur les vulnérabilités potentiellement présentes dans le projet.<br />
<blockquote class="tr_bq">
</blockquote>
<h3>
Création du rapport contenant les vulnérabilités dans sonar</h3>
<div>
Il faut que maven soit paramétré et configuré pour accéder à sonarqube.</div>
<blockquote class="tr_bq">
mvn clean package sonar:sonar</blockquote>
Une fois le build effectué vous trouverez dans sonar un nouvel onglet sur le projet contenant le rapport html de l'analyse:<br />
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAqn8DNdp-6f6dH_KgGcKwW2fQcnjqXXldTYTxMq1ZjlpsUrhAosuuE4bknKzvXtTm_0euHTxv_UUlmBPLSG-9QUbs_lmCinCdc9qRerKsznTXZglN7VsdUsiiLHxwyytWpoqeOQJoNmFQ/s1600/Capture+du+2018-06-08+14-15-39.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="89" data-original-width="214" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAqn8DNdp-6f6dH_KgGcKwW2fQcnjqXXldTYTxMq1ZjlpsUrhAosuuE4bknKzvXtTm_0euHTxv_UUlmBPLSG-9QUbs_lmCinCdc9qRerKsznTXZglN7VsdUsiiLHxwyytWpoqeOQJoNmFQ/s1600/Capture+du+2018-06-08+14-15-39.png" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Dans 'Measures' se trouvera une nouvelle 'rubrique' <a href="https://sonar-dsi.inra.fr/component_measures?id=fr.inra.dsi%3Aexpense-mission#" style="border-bottom: none; color: #4b9fd5; cursor: pointer; font-family: "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif; font-size: 13px; font-weight: 600; margin: 0px; outline: none; padding: 0px; text-decoration-line: none; transition: all 0.2s ease; white-space: nowrap;">OWASP-Dependency-Check</a> (provenant du rapport xml) :</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7XlYxZOtY8uRv5QjaxGoKgX0uLffwOqZbtUbhgKL7GI-2c7SmDhn4plRWNbuYUY_o6wsTZw7fcAkqUp9LJnp5ggq4gWDdMrsbHt280jgoCG_cl_2hpy1OmgZS3V_Vz-BFa1oz4fPszPt1/s1600/Capture+du+2018-06-08+14-18-39.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="585" data-original-width="312" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7XlYxZOtY8uRv5QjaxGoKgX0uLffwOqZbtUbhgKL7GI-2c7SmDhn4plRWNbuYUY_o6wsTZw7fcAkqUp9LJnp5ggq4gWDdMrsbHt280jgoCG_cl_2hpy1OmgZS3V_Vz-BFa1oz4fPszPt1/s320/Capture+du+2018-06-08+14-18-39.png" width="170" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<h3 style="clear: both; text-align: left;">
Pour aller plus loin</h3>
<div>
Il est tout a fait possible d'intégrer ce process dans une usine logicielle afin de bénéficier de l'intégration continue (au sein de jenkins par exemple) . </div>
<div>
<br /></div>
<div>
Le plugin dependency check peut être paramétré pour terminer le build en erreur si une dépendance critique est détectée. </div>
<div>
<br /></div>
<div>
Il est aussi possible sur SonarQube de créer des Quality gates contenant des contraintes de sécurité ce qui permettrait de détecter rapidement les failles de sécurité et statuer sur une éventuelle mise en production (selon criticité et choix entre les différents acteurs métiers) du produit logiciel. </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<br />
<div>
<br /></div>
<div>
<span class="hljs-tag" style="color: blue; font-family: "monaco" , "andale mono" , "courier new" , monospace; white-space: pre-wrap;"><br /></span></div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-12481645857380869902018-04-25T22:07:00.002+02:002018-04-25T22:07:46.547+02:00Retours sur les Devoxx France 2018Cette année 2018 a encore été très enrichissante. Le nombre de sujets et de conférences étaient très nombreux. Les participants étaient aussi au rendez-vous, c'est simple si on traine un peu trop on se retrouve a chercher une solution de replis car la salle est pleine (sauf pour l'amphi qui hors keynotes est jamais plein a 100%).<br />
<br />
Voici donc une partie de mes notes :<br />
<br />
<h2>
Les nouveautés autour de Java</h2>
<div>
Présenté par José Paumard & Rémi Forax, cette présentation nous a montré que le cycle de version des releases Java à vraiment accéléré (pour ceux qui l'avaient pas constaté). </div>
<div>
<br /></div>
<div>
Java adopte maintenant un système de fork pour la gestion des version. </div>
<div>
Une fois qu'une version est release un fork est crée et ce fork devient la nouvelle version de java.</div>
<div>
<br /></div>
<div>
Le cycle de version est maintenant de <b>6 mois avec des version LTS</b>. </div>
<div>
La prochaine version LTS étant Java 11 qui devrait sortir en septembre 2018.</div>
<div>
<br /></div>
<div>
Pour les personnes qui souhaiteraient effectuer une montée de version il vaut mieux attendre la version LTS plutôt que de passer de Java 8/9 vers java 10 par exemple. </div>
<div>
<br /></div>
<div>
Etant personnellement pas encore passé a Java 10, j'ai découvert avec bonheur une nouvelle fonctionnalité : </div>
<div>
<div class="crayon-pre" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: none !important; line-height: 18px !important; margin: 0px; outline: 0px; overflow: visible; padding: 0px; tab-size: 4; vertical-align: baseline;">
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; font-family: inherit; font-size: inherit !important; font-weight: inherit !important; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-t" style="border: 0px; color: rgb(128 , 0 , 128); font-family: inherit; font-size: inherit; font-weight: bold; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><br /></span></div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; font-family: inherit; font-size: inherit !important; font-weight: inherit !important; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-t" style="border: 0px; color: rgb(128 , 0 , 128); font-family: inherit; font-size: inherit; font-weight: bold; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">var</span><span class="crayon-h" style="border: 0px; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">users</span><span class="crayon-h" style="border: 0px; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-o" style="border: 0px; font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="crayon-h" style="border: 0px; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-r" style="border: 0px; color: rgb(128 , 0 , 128); font-family: inherit; font-size: inherit; font-weight: bold; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">new</span><span class="crayon-h" style="border: 0px; color: rgb(0 , 111 , 224); font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="crayon-v" style="border: 0px; font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">ArrayList</span><span class="crayon-e " style="border: 0px; font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><User></span><span class="crayon-sy" style="border: 0px; font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="crayon-sy" style="border: 0px; font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">)</span><span class="crayon-sy" style="border: 0px; font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">;</span></div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; font-family: inherit; font-size: inherit !important; font-weight: inherit !important; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline; white-space: pre;">
<span class="crayon-sy" style="border: 0px; font-family: inherit; font-size: inherit; font-weight: inherit; height: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><br /></span></div>
Oui oui, ça ressemble bien a du javascript :) </div>
<div class="crayon-pre" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: none !important; line-height: 18px !important; margin: 0px; outline: 0px; overflow: visible; padding: 0px; tab-size: 4; vertical-align: baseline;">
Ce nouveau mot-clef ne s'utilise qu'au sein d'une fonction (Donc pas en tant que déclaration d'attribut) et permet aussi de mettre dans une variable une fonction exemple : </div>
<div class="crayon-pre" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: none !important; line-height: 18px !important; margin: 0px; outline: 0px; overflow: visible; padding: 0px; tab-size: 4; vertical-align: baseline;">
<br /></div>
<div class="crayon-pre" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: none !important; line-height: 18px !important; margin: 0px; outline: 0px; overflow: visible; padding: 0px; tab-size: 4; vertical-align: baseline;">
<pre style="background: rgb(255, 255, 255);"><span style="color: maroon; font-weight: bold;">public</span> List<String> getUrls () <span style="color: purple;">{</span><span style="color: maroon; font-weight: bold;">return</span> <span style="color: #bb7977; font-weight: bold;">List</span><span style="color: #808030;">.</span>of<span style="color: #808030;">(</span><span style="color: #0000e6;">""</span><span style="color: #808030;">)</span><span style="color: purple;">;</span><span style="color: purple;">}</span>
<span style="color: maroon; font-weight: bold;">protected</span> List<String> sendsUrls()<span style="color: purple;">{</span>
<span style="color: #bb7977; font-weight: bold;">List</span><span style="color: #808030;"><</span><span style="color: #bb7977; font-weight: bold;">String</span><span style="color: #808030;">></span> result <span style="color: #808030;">=</span> <span style="color: maroon; font-weight: bold;">new</span> ArrayList<span style="color: #808030;"><</span><span style="color: #808030;">></span><span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: purple;">;</span>
var maFonction <span style="color: #808030;">=</span> getUrls<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: purple;">;</span>
result<span style="color: #808030;">.</span>addAll<span style="color: #808030;">(</span>maFonction<span style="color: #808030;">)</span><span style="color: purple;">;</span>
<span style="color: maroon; font-weight: bold;">return</span> result<span style="color: purple;">;</span>
<span style="color: purple;">}</span></pre>
<pre style="background: rgb(255, 255, 255);"><span style="color: purple;">
</span></pre>
</div>
<div class="crayon-pre" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: none !important; line-height: 18px !important; margin: 0px; outline: 0px; overflow: visible; padding: 0px; tab-size: 4; vertical-align: baseline;">
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
<span style="border-color: initial; border-image: initial; border-style: initial; height: inherit; line-height: inherit; outline-color: initial; outline-style: initial;">Et voici rapidement les nouveautés a venir dans les prochaines versions (sous réserve de du suivi de la roadmap)</span><br />
<br />
<br />
<span class="crayon-sy" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; white-space: pre;"><span style="border-color: initial; border-image: initial; border-style: initial; height: inherit; line-height: inherit; outline-color: initial; outline-style: initial; white-space: pre;">Java 11:
var as type in Lamba Parameters
Constant Dynamic
Raw string
Condy
Java 12:
Nouveaux Switch
Preconditions : ex: Preconditions.requireNonNull(variable);
Java 14:
Sealed interface : defini l'ensemble des classes qui implementent l'interface.
Generalized pattern maching
</span></span><br />
<h2>
Authentification et autorisation décentralisée avec jwt et macaroo</h2>
</div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
<span class="crayon-sy" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><span style="font-family: inherit;"><span style="font-weight: inherit !important; white-space: pre;">Présenté par </span></span>Julien Tanguy, l</span>ors ce cette présentation il a été rappelé la différence entre l'autorisation et l'authentification. </div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
<span class="crayon-sy" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">L'authentification: Qui suis je ? </span></div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
<span class="crayon-sy" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">L'autorisation: Qu'est je le droit de faire ? </span></div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
<span class="crayon-sy" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><br /></span></div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
<span class="crayon-sy" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Pour ces deux notion , deux outils, JWT pour l'authentification et Macaroons pour les autorisation. </span></div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
Ces deux outils fonctionnent avec des tokens, une signature basée par un secret et une Payload. </div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
<br /></div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
De ce que j'ai pu voir lors de la démo ça à l'air simple à utiliser </div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
<br /></div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
Pour regarder plus près macaroons.io et jwt.io<br />
<h2>
Chaos Engineering</h2>
<div>
Présenté par Julien Gakic.</div>
<div>
<br />
Dashboard à l'appui lors de la présentation, le chaos engineering est une pratique qui prends de plus en plus d'ampleur. </div>
<div>
<br /></div>
<div>
Cette pratique vise à accroire la résilience des applications afin que la production soit toujours stable malgré les aléas du backend.</div>
<div>
<br /></div>
<div>
Le concept est d'introduire des dysfonctionnements sur la production (oui oui) afin de voir comment se comporte le système dans sa globalité.<br />
Cela permet notamment de détecter les effets de bords d'un dysfonctionnement d'une application (une application qui impacterait par exemple une autre application qui n'aurait pas de lien direct avec celle en défaut).</div>
<div>
<br /></div>
<div>
Pour induire ces défauts sur la production il existe un outil qui s'appelle Chaos monkey. </div>
<div>
Enfin voici un site qui en parle plus en détail <a href="https://principlesofchaos.org/" target="_blank">Principle of chaos</a>.</div>
</div>
<div class="crayon-line" id="crayon-5acb7ef13a69c022642236-1" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: 0px center; background-repeat: initial; background-size: initial; border: 0px; height: inherit; line-height: inherit !important; margin: 0px; outline: 0px; padding: 0px 5px; vertical-align: baseline;">
<br /></div>
<br /><h2>
Swagger 2 est mort vive openapi 3 !</h2>
Présenté par Sébastien Lecacheur<br /><br />Voici ce qu'apporte Openapi 3 par rapport à Swagger 2:<br /><br />Ajout de la balise servers (permets de mettre plusieurs liens d'envs par ex)<br />Ajout de la balise components</div>
<div class="crayon-pre" style="background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border: none !important; line-height: 18px !important; margin: 0px; outline: 0px; overflow: visible; padding: 0px; tab-size: 4; vertical-align: baseline;">
Ajout sheme et bearer format<br />Modification de la balise Basic qui devient http<br />Wilcard pour les codes http<br />Ajout de Content et media type<br />Possibilité de mettre plusieurs exemples<br />Support d'openid connect<br /><br /><br /></div>
</div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-9364069123272674252018-02-26T10:05:00.000+01:002018-02-26T10:05:37.679+01:00Unassigned shards in Elasticsearch<h2>
Problème</h2>
Suite à la montée de version d'elasticsearch 5 vers 6 les shards n'étant pas alloués ce qui provoquait un dysfonctionnement du cluster elastic (j'avais 50% des shards alloués et donc un cluster 'Jaune' -> Pas fonctionnel)<br />
<br />
<br />
<h2>
Solution </h2>
Il fallait simplement lire la <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rolling-upgrades.html" target="_blank">doc de migration</a> ...<br />
Dans la doc de migration d'elastic 5 vers 6 on désactive le setting d'allocation de shards et a la fin de la migration il faut simplement la réactiver (une étape qui a du être oubliée). <br />
<br />
Sur un des nœud : <br />
<pre style="-webkit-text-stroke-width: 0px; background-color: white; border-color: rgb(221, 221, 221) rgb(221, 221, 221) rgb(221, 221, 221) rgb(107, 55, 162); border-image: initial; border-radius: 4px; border-style: solid; border-width: 1px 1px 1px 3px; box-sizing: border-box; color: #333333; direction: ltr; font-family: monospace, monospace; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 200; letter-spacing: normal; line-height: 20px; margin: 40px auto; max-width: 857px; orphans: 2; overflow: auto; padding: 10px 188.984px 10px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px;"><code style="background-color: white; border-radius: 4px; border: none; box-sizing: border-box; color: #555555; display: inline; font-family: monospace, monospace; font-size: 0.8em; line-height: 20px; white-space: pre; word-break: normal;">curl -XPUT 'localhost:9200/_cluster/settings' -d
'{ "transient":
{ "cluster.routing.allocation.enable" : "all"
}
}'</code></pre>
Après avoir activé l'allocation, les shards ont été automatiquement activés et le cluster est passé en Vert (fonctionnel a 100%).Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-721188108984223852018-02-13T09:41:00.002+01:002018-02-13T09:41:56.373+01:00ElasticSearch 6 Systemd configuration memory lock pour Redhat 7<h2>
Problème</h2>
Suite à la mise a jour d'elasticsearch 5.x vers 6.x, il m'était impossible de démarrer le demon via systemd car j'avais l'erreur suivante :<br />
<br />
[1] bootstrap checks failed<br />[1]: memory locking requested for elasticsearch process but memory is not locked<br />
<br />
<h2>
Solution</h2>
C'est tout simplement écrit <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-system-settings.html#systemd" target="_blank">dans la doc d'elasticsearch</a> mais il faut fouiller un peu.<br />
<br />
Dans le fichier de configuration systemd elasticsearch.service rajouter apres [Service] , LimitMEMLOCK=infinity:<br />
<br />
<pre class="programlisting prettyprint lang-sh prettyprinted" style="-webkit-text-stroke-width: 0px; background-color: #f0f0f0; border-radius: 4px 5px 5px 4px; border: none; box-sizing: border-box; color: #333333; display: inline-block; font-family: Consolas, Menlo, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Lucida Console"; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 1.5em; margin: 0px; max-width: 10000px; orphans: 2; overflow: auto; padding: 8px 0px 8px 18px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; width: auto; word-break: break-word; word-spacing: 0px; word-wrap: break-word;"><span class="pun" style="box-sizing: border-box; color: #666600; font-size: 16px; font-weight: normal;">[</span><span class="typ" style="box-sizing: border-box; color: #660066; font-size: 16px; font-weight: normal;">Service</span><span class="pun" style="box-sizing: border-box; color: #666600; font-size: 16px; font-weight: normal;">]</span><span class="pln" style="box-sizing: border-box; color: black; font-size: 16px; font-weight: normal;">
</span><span class="typ" style="box-sizing: border-box; color: #660066; font-size: 16px; font-weight: normal;">LimitMEMLOCK</span><span class="pun" style="box-sizing: border-box; color: #666600; font-size: 16px; font-weight: normal;">=</span><span class="pln" style="box-sizing: border-box; color: black; font-size: 16px; font-weight: normal;">infinity</span></pre>
<br />
Puis recharger le demon systemctl<br />
<br />
<pre class="programlisting prettyprint lang-sh prettyprinted" style="-webkit-text-stroke-width: 0px; background-color: #f0f0f0; border-radius: 4px 5px 5px 4px; border: none; box-sizing: border-box; color: #333333; display: inline-block; font-family: Consolas, Menlo, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Lucida Console"; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 1.5em; margin: 0px; max-width: 10000px; orphans: 2; overflow: auto; padding: 8px 0px 8px 18px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; width: auto; word-break: break-word; word-spacing: 0px; word-wrap: break-word;"><span class="pln" style="box-sizing: border-box; color: black; font-size: 16px; font-weight: normal;">sudo systemctl daemon</span><span class="pun" style="box-sizing: border-box; color: #666600; font-size: 16px; font-weight: normal;">-</span><span class="pln" style="box-sizing: border-box; color: black; font-size: 16px; font-weight: normal;">reload</span></pre>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-54815006145221303082018-02-12T11:20:00.002+01:002018-02-12T11:20:28.192+01:00Alternative a la commande tree avec find<h2>
Problème</h2>
Afficher l'arborescence d'un filesystem quand la commande tree n'est pas disponible et qu'on a pas les droit d'admin sur la machine<br />
<br />
<h2>
Solution</h2>
<h3>
Afficher que les répertoires</h3>
find . -type d | sed 's/[^/]*\//| /g;s/| *\([^| ]\)/+--- \1/'<br />
<br />
<h3>
Tout afficher (répertoires + fichiers)</h3>
find . | sed 's/[^/]*\//| /g;s/| *\([^| ]\)/+--- \1/' <br />
<h3>
<br /></h3>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-33441004463823535392017-11-06T13:58:00.001+01:002017-11-06T13:58:05.531+01:00Ajouter la date et les secondes dans gnome shell Dans un terminal exécuter :<br />
<br />
<pre style="background-color: #eff0f1; border: 0px; color: #111111; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;">gsettings set org.gnome.desktop.interface clock-show-date true
gsettings set org.gnome.desktop.interface clock-show-seconds true</code></pre>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-83301210682647277712017-10-27T15:57:00.001+02:002017-11-06T13:17:15.208+01:00Grok pattern conditionnel check<h2>
Problème</h2>
<div>
Lorsque l'ont veut appliquer un pattern grok sur une chaine envoyée par filebeat par exemple, il arrive que certains champs qui doivent respecter un pattern donné soit vide ce qui se traduit coté grok par un pattern qui ne correspond pas et donc par un parsing qui n'est pas envoyé correctement à elastic search. </div>
<div>
<br /></div>
<h3>
Exemple</h3>
<div>
Soit la chaine suivante : </div>
<div>
<pre class="brush: shell">[27/Oct/2017:15:38:48 +0200] 127.0.0.1 - 200 80 212 GET /show HTTP/1.1</pre>
</div>
<div>
<br /></div>
<div>
Et le pattern grock suivant : </div>
<div>
\[%{MONTHDAY}[./-]%{WORD}[./-]%{YEAR}[:]%{TIME}%{SPACE}[+]%{INT}\]%{SPACE}%{IP:[parameters][remoteip]}%{SPACE}%{USER:[parameters][user]}%{SPACE}%{INT:[parameters][httpcode]}%{SPACE}%{INT:[parameters][localport]}%{SPACE}%{INT:[parameters][processtime]}%{SPACE}%{GREEDYDATA:[parameters][requestfistline]}<br />
<br />
Le résultat attendu :<br />
<br /></div>
<pre class="brush: bash">{
"MONTHDAY": [
[
"27"
]
],
"WORD": [
[
"Oct"
]
],
"YEAR": [
[
"2017"
]
],
"TIME": [
[
"15:38:48"
]
],
"HOUR": [
[
"15"
]
],
"MINUTE": [
[
"38"
]
],
"SECOND": [
[
"48"
]
],
"SPACE": [
[
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
],
"INT": [
[
"0200"
]
],
"[parameters][remoteip]": [
[
"127.0.0.1"
]
],
"IPV6": [
[
null
]
],
"IPV4": [
[
"127.0.0.1"
]
],
"[parameters][user]": [
[
"-"
]
],
"USERNAME": [
[
"-"
]
],
"[parameters][httpcode]": [
[
"200"
]
],
"[parameters][localport]": [
[
"80"
]
],
"[parameters][processtime]": [
[
"212"
]
],
"[parameters][requestfistline]": [
[
"GET /show HTTP/1.1"
]
]
}
</pre>
<br />
<div>
Si dans la chaîne récupérée l'ip n’apparaît plus alors le pattern ne sera pas correspondant:<br />
<pre class="brush: bash">[27/Oct/2017:15:38:48 +0200] - 200 80 212 GET /show HTTP/1.1
</pre>
<pre class="brush: bash"></pre>
<h2>
Solution</h2>
</div>
<div>
Utiliser le terme conditionnel pour la vérification du pattern.</div>
<div>
Cela se traduit par l'utilisation de (?:le terme a mettre en conditionnel |).</div>
<h3>
Exemple : </h3>
<div>
\[%{MONTHDAY}[./-]%{WORD}[./-]%{YEAR}[:]%{TIME}%{SPACE}[+]%{INT}\]%{SPACE}<span style="color: red;">(?:%{IP:[parameters][remoteip]}|)</span>%{SPACE}%{USER:[parameters][user]}%{SPACE}%{INT:[parameters][httpcode]}%{SPACE}%{INT:[parameters][localport]}%{SPACE}%{INT:[parameters][processtime]}%{SPACE}%{GREEDYDATA:[parameters][requestfistline]}</div>
<div>
<br /></div>
<div>
Maintenant le pattern est bien correspondant et la chaîne traitée correctement. </div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-63433917219597311062016-04-07T15:32:00.001+02:002016-04-07T15:41:46.255+02:00Docker registry avec certificat auto-signé (--insecure-registry)<h2>
Démarrer le registry sur le serveur
</h2>
<pre class="brush: bash">docker run -d -p 5000:5000 --restart=always --name registry \
-v {chemin_du_fs_stockage_des_donnes}/data:/var/lib/registry \
registry:2f
</pre>
<br />
<h2>
Authentification auto-signé (Voir https://docs.docker.com/registry/insecure/ ) </h2>
myregistrydomain => ip, dns du serveur hébergeant le registry<br />
<span style="color: red;">Attention! Pas du tout adapté pour un environnement de PROD ! </span><br />
<br />
<h3>
Génération du certificat sur le serveur hébergeant le registry</h3>
<pre class="brush: bash"> mkdir -p certs && openssl req \
-newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key \
-x509 -days 365 -out certs/domain.crt
</pre>
Be sure to use the name <b><i>myregistrydomain.com</i></b> as a CN.<br />
<br />
<br />
<h3>
Démarrage du registry avec les certificats
</h3>
<pre class="brush: bash">docker run -d -p 5000:5000 --restart=always --name registry \
-v {chemin_contenant_les_crt_key}:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key registry:2
</pre>
<br />
<h3>
Coté client</h3>
Attention testé uniquement sur <span style="color: red;">Ubuntu</span>, la facon diffère selon les distributions.
Cela doit fonctionner sur distribution qui sont basés Debian sur car Ubuntu est développé a partir de celui-ci.<br />
RedHat & les autres distribution ont leur propre facon d'ajout de certificat.<br />
<br />
<br />
<ol>
<li>Récupérer le certificat généré utilisé par le registry</li>
<li>Sous Ubuntu aller dans /usr/local/ca-certificates</li>
<li>Déposer le certificat
update-ca-certificates</li>
<li>service docker stop </li>
<li>vi /etc/default/docker</li>
<li>Ajouter DOCKER_OPTS="--insecure-registry {url-registry}:5000" (Ex: DOCKER_OPTS="--insecure-registry myregistrydomain.com:5000" )</li>
<li>service docker start </li>
</ol>
<br />
<br />
<h2>
Commandes </h2>
<br />
myregistrydomain => ip, dns du serveur hébergeant le registry<br />
<br />
<h3>
Déposer une image sur le registry</h3>
<pre class="brush: bash">docker push myregistrydomain.com:5000/{images}/{tag}
</pre>
<br />
<h3>
Obtenir une image du registry</h3>
<pre class="brush: bash">docker pull myregistrydomain.com:5000/{images}/{tag}
</pre>
<br />
<h3>
Lister les images dans le docker repository</h3>
<div>
Sur le serveur hébergeant le registry ont peut trouver les repositories correspondant aux images déposés dans le registry</div>
<div>
<br /></div>
<pre class="brush: bash">ls -l {chemin_du_fs_stockage_des_donnes}/data/docker/registry/v2/repositories
</pre>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-41711765543100323142015-10-26T08:10:00.000+01:002015-10-26T08:10:10.816+01:00Page blanche lors de l'installation de testlink <h2>
Problème</h2>
<div>
Après avoir installé (migration testlink 1.9.13 > 1.9.14) testlink j'avais une page blanche sur tout le site.</div>
<div>
La page blanche survenait lorsque je copias le fichier config_db.inc.php contenant les infos de connexion à la base de donnée.</div>
<h2>
Solution</h2>
<div>
Après avoir déclaré un incident mantis a l'équipe gérant testlink (http://mantis.testlink.org/view.php?id=7311) il s'avère que c'était bêtement un problème de droits sur deux répertoires.</div>
<div>
<br /></div>
<div>
Il m'a suffit de changer les droits pour les répertoires en 775: </div>
<div>
<br /></div>
<div>
{testlink_install}/gui/templates_c</div>
<div>
{testlink_install}/logs</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-76244614935371037172015-02-10T16:37:00.002+01:002015-02-10T16:37:34.190+01:00Stubber des classes dans une chaine d'appel pour cloisonner les test d'intégration<h2>
Problème</h2>
<div>
Dans le code applicatif une classe qui faisait un appel web service vers une autre application. </div>
<div>
<br /></div>
<div>
Je voulais tester ma méthode a travers un test d'intégration sans pour autant faire l'appel réel vers le web service afin de ne pas créer de couplage pendant l’exécution de mon test.</div>
<div>
<br /></div>
<div>
J'ai voulu utiliser Mockito et PowerMock afin de stubber la classe mais cette classe était utilisée très loin dans la chaine d'appel (Le TI que je faisait était de haut niveau). </div>
<div>
<br /></div>
<div>
Mon test était donc dépendant du service distant.</div>
<div>
<br /></div>
<h2>
Solution</h2>
<h3>
Exclure les classes gênantes</h3>
<div>
J'ai exclu dans ShrinkWrap les classes gênantes dans la construction de l'archive java pour Arquillian : </div>
<div>
<br /></div>
<pre class="brush: java">package fr.ftravaglia;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Filters;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.runner.RunWith;
import fr.ftravaglia.RemoteServiceMails;
import fr.ftravaglia.RemoteServiceAdresses;
@RunWith(Arquillian.class)
public class ArquillianInit {
@Deployment
public static final JavaArchive createArchive() {
return ShrinkWrap
.create(JavaArchive.class, "demo-ftravaglia.jar")
.addPackages(true, Filters.exclude(RemoteServiceMails.class, RemoteServiceAdresses.class), "fr.ftravaglia")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsResource("META-INF/persistence.xml",
"META-INF/persistence.xml");
}
}
</pre>
<div>
<br />
<h3>
Ajouter les stubs coté test</h3>
</div>
<div>
Dans la partie test du projet (src/test/java) j'ai crée deux classe remplaçant celle qui ont été exclues.</div>
<div>
Dans mon projet j'utilise CDI. Les classes injectés le sont a travers des qualifiers car les instances sont représenté par des interfaces pour l'IOC.</div>
<div>
<br /></div>
<div>
Voici une des classes (la deuxième a la même structure) </div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<pre class="brush: java">package fr.ftravaglia;
import fr.ftravaglia.RemoteServiceMailsEAO;
import fr.ftravaglia.RemoteServiceMailsImplWS.RemoteServiceMailsQualifier;
/**
* Use for not call remote app.
*/
@RemoteServiceMailsQualifier
public class RemoteServiceMailsMock implements RemoteServiceMailsEAO {
/**
* Default constructor
*/
public RemoteServiceMailsMock() {
super();
}
/**
* {@inheritDoc}
*/
@Override
public boolean isMailValid(String mail){
boolean result = false;
if (mail != null && !mail.isEmpty()) {
result = true;
}
return result;
}
}
</pre>
<br /></div>
Dans le code applicatif réel l'injection se fait par :
<br />
<br />
<pre class="brush: java">@Inject
@RemoteServiceMailsQualifier
private transiant RemoteServiceMailsEAO serviceMailEAO;
</pre>
<br />
<div>
Du coup lorsque d'Arquillian se lance et publie l'application dans le serveur d'application embarqué, les classes sont supprimés de l'archive et celles définies en tant que stubs sont utilisés a la place des classes réelles.<br />
<br />
En cas de questions n'hésitez pas ;)<br />
<br />
<br /></div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-52577882035081355682015-02-05T14:51:00.003+01:002015-02-06T10:53:23.268+01:00Insufficient privileges avec SonarQube 5.0 et Jenkins<h2>
Problème</h2>
<div>
Suite au passage a SonarQube 5.0 les jobs jenkins qui étaient responsable de faire l'analyse Sonar ne fonctionnaient plus. </div>
<div>
<br /></div>
<div>
J'avais comme erreur : </div>
<div>
<span style="background-color: white; color: #333333; white-space: pre-wrap;">Caused by: java.lang.IllegalStateException: {"errors":[{"msg":"Insufficient privileges"}]}</span></div>
<div>
<span style="background-color: white; color: #333333; font-size: 13px; white-space: pre-wrap;"><br /></span></div>
<div>
Après quelque recherche je me suis rendu compte que c'était lié au changement de profil qualité (Quality Profiles).</div>
<div>
<br /></div>
<h2>
Solution</h2>
<div>
<i><span style="color: red;">Prérequis:</span></i></div>
<div>
<i><span style="color: red;">Avoir les accès admin sur Sonar et Jenkins</span></i></div>
<div>
<ul>
<li>Créer dans Sonar un utilisateur </li>
<li>Aller dans le fichier sonar.properties sur le file system</li>
<li>Ajouter dans le fichier : sonar.security.localUsers: {utilisateur-technique-crée}</li>
<li>Aller dans la configuration Jenkins (Adminstrer Jenkins > Configurer le système)</li>
<li>Puis dans la partie 'Installations de Sonar'</li>
<li>Dans 'Login du compte Sonar' mettre le <span style="color: red;">login de l'utilisateur sonar crée</span></li>
<li>Dans 'Mot de passe du compte Sonar' mettre le mdp associé au login</li>
<li>Aller dans l'interface web de Sonar</li>
<li>Cliquer sur 'Settings' puis 'Global Permissions'</li>
<li>Ajouter <span style="color: red;">l'utilisateur défini dans Jenkins</span> pour les permissions de : <b style="background-color: whitesmoke; color: #444444; font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.0029983520508px;">Execute Analysis <span style="color: black; font-family: 'Times New Roman'; font-size: small; font-weight: normal; line-height: normal;">et</span> </b><b style="background-color: white; color: #444444; font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 16.0029983520508px;">Execute Preview Analysis</b></li>
<li>Ensuite pour chaque projets il faut attribuer le droit de '<span style="background-color: white; color: #444444; font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 12px; line-height: 16.9260005950928px; text-transform: uppercase;">BROWSE</span>' à l'utilisateur technique</li>
</ul>
<div>
Après ces modifications mes builds sonar fonctionnaient de nouveau.</div>
</div>
<div>
<br />
Plus d'infos sur les utilisateurs techniques de sonar : http://docs.sonarqube.org/display/SONAR/Authentication#Authentication-TechnicalUsers<br />
<br /></div>
<div>
Enjoy !</div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-73697092959470373402015-01-19T12:14:00.001+01:002015-01-19T12:15:17.708+01:00Postgresql 8 GRANT ALL PRIVILEGE sur tables et séquences <h2>
Problème</h2>
Sur Postgresql 8 il n'existe pas de moyen d'accorder des droits sur toutes les tables et séquences facilement.<br />
<br />
<h2>
Solution</h2>
<h3>
<span style="font-size: small; font-weight: normal;">{user} > Utilisateur pour lequel on veut donner les droits</span></h3>
<div>
<span style="font-size: small; font-weight: normal;"><br /></span></div>
<div>
Ci-dessous les commandes SQL permettant de générer les commandes nécessaires pour donner les droits.
Exécuter les commandes générés pour donner les droits sur l'utilisateur.
</div>
<h3>
Pour les tables</h3>
<div>
<pre class="brush: sql">SELECT 'GRANT ALL PRIVILEGES ON ' || quote_ident(schemaname) || '.' || quote_ident(tablename) || ' TO {user};' FROM pg_tables WHERE schemaname = 'public';</pre>
</div>
<div>
<br /></div>
<h3>
Pour les séquences</h3>
<div>
<pre class="brush: sql">SELECT 'GRANT ALL PRIVILEGES ON ' || quote_ident(sequence_name) || ' TO {user};' FROM information_schema.sequences WHERE sequence_schema = 'public';</pre>
</div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-41563487228421201032014-11-05T15:52:00.002+01:002014-11-24T17:50:15.779+01:00Injecter des mocks dans un objet sans impacter le code pour le test en utilisant la reflexion<h2>
Problème</h2>
Comment injecter des mocks sur une classe contenant des champs privés sans modifier cette classe en y ajoutant un setter ou un constructeur spécialisé ???! <br />
<h2>
</h2>
<h2>
Solution</h2>
<h3>
Au tout début ... </h3>
<h3>
</h3>
Dépendances nécessaire:<br />
<br />
<pre class="brush: xml">dependencies
dependency
groupidjunit/groupid
artifactidjunit/artifactid
version4.5/version
scopetest/scope
/dependency
dependency
groupidorg.mockito/groupid
artifactidmockito-all/artifactid
version1.9.5/version
scopetest/scope
/dependency
/dependencies
</pre>
<br />
<br />
Soit la classe MyClass :<br />
<br />
<pre class="brush: java">package fr.ftravaglia.demo.mokitoinjection;
/**
* Use for test with reflexion
* @author ftravaglia
*/
public class MyClass {
// Field that haven't setter !
private transient Foo myFoo;
/**
* Default constructor
*/
public MyClass(){
super();
myFoo = new Foo();
}
/**
* Return the Foo name.
* @return
*/
public String printMyFooName(){
return myFoo.printMyName();
}
}
</pre>
<br />
Et la classe Foo :<br />
<br />
<pre class="brush: java">package fr.ftravaglia.demo.mokitoinjection;
/**
* Object to mock
* @author ftravaglia
*/
public class Foo {
/**
* Default constructor
*/
public Foo(){
super();
}
/**
* Method used for demonstrate mock
* @return
*/
public String printMyName(){
return this.getClass().getName();
}
}
</pre>
<br />
On veut mocker le résultat de 'printMyName' de la classe Foo par 'MyMockedResult' et injecter Foo dans MyClass sans utiliser de setter.<br />
<br />
Utilisons un test pour valider le résultat :<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPEY-CBUxO7rAWLBKfdC93LzpnvLopqTv0HurMN6gkBgM46ne02Hhwi127lgh0guSGULhww-XHwpUU_-v1pZECsXrChbFnla37HXGKRdaJJ_oxTPiQuAnWLjAdEReXyyr-Qo7FBDdgJyAk/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPEY-CBUxO7rAWLBKfdC93LzpnvLopqTv0HurMN6gkBgM46ne02Hhwi127lgh0guSGULhww-XHwpUU_-v1pZECsXrChbFnla37HXGKRdaJJ_oxTPiQuAnWLjAdEReXyyr-Qo7FBDdgJyAk/s1600/4.png" height="225" width="320" /></a></div>
<br />
<br />
Le test plante bien ce qui est normal :)<br />
<br />
<br />
<h3>
Utilisation de la réflexion </h3>
Dans les sources contenant le code des test implémenter une classe permettant de faire la réflexion (on pourrait faire sans la classe mais dans le but de réutiliser ce code dans les test c'est mieux :) )<br />
<br />
<br />
<pre class="brush: java">package fr.ftravaglia.demo.mokitoinjection.util;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
/**
* Use reflexion for change value of attribut.
* @author ftravaglia
*
*/
public class InjectionHelper {
/**
* Set 'newFieldValue' as value for the field 'fieldName' on the object 'object'.
*
* @param object
* @param fieldName
* @param newFieldValue
* @throws SecurityException
* @throws NoSuchFieldException
* @throws IllegalAccessException
* @throws IllegalArgumentException
*/
public static void setField(Object object, String fieldName, Object newFieldValue) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
final Field field = object.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
// Use for modify the final attribut
final Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(object, newFieldValue);
}
}
</pre>
<br />
<br />
<br />
<h3>
Modification du test unitaire pour utiliser la reflexion avec mockito</h3>
<h3>
</h3>
<pre class="brush: java">package fr.ftravaglia.demo.mokitoinjection;
import junit.framework.Assert;
import org.junit.Test;
import org.mockito.Mockito;
import fr.ftravaglia.demo.mokitoinjection.util.InjectionHelper;
/**
* Test the class {@link MyClass}
* @author ftravaglia
*
*/
public class MyClassTest {
private transient MyClass myClass;
private transient Foo foo;
public MyClassTest() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
super();
myClass = new MyClass();
foo = Mockito.mock(Foo.class);
InjectionHelper.setField(myClass, "myFoo", foo);
}
@Test
public void printMyFooNameMustReturnMyMockedResult(){
final String valueMock = "MyMockedResult";
Mockito.when(foo.printMyName()).thenReturn(valueMock);
Assert.assertEquals(valueMock, myClass.printMyFooName());
}
}
</pre>
<br />
On relance le test:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjur0OOZXwsZ2z5eXRq8O8sX9tnoHNqKBhqgBdvxANsQnmCo0mZAatA8oP3ux_4klfq27QNnVWPwMrMd2jfz1nc5vRauc94VJ1feg6YyCEUxqM6j3fquwndX5WHOpbGzTAPI5urBHPeSor6/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjur0OOZXwsZ2z5eXRq8O8sX9tnoHNqKBhqgBdvxANsQnmCo0mZAatA8oP3ux_4klfq27QNnVWPwMrMd2jfz1nc5vRauc94VJ1feg6YyCEUxqM6j3fquwndX5WHOpbGzTAPI5urBHPeSor6/s1600/2.png" height="191" width="320" /></a></div>
<br />
<br />
<br />
<br />
C'est vert !<br />
<br />
Ca marche même avec les champs static final ;) <br />
<br />
<a href="https://github.com/ftravaglia/veille" target="_blank">Code source dispo : https://github.com/ftravaglia/veille</a>Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-19818382757069091472014-07-28T10:59:00.002+02:002014-07-28T11:42:06.135+02:00Lecture des listes de paquets… Erreur !<br />
<h2>
Problème </h2>
Lecture des listes de paquets... Erreur !</br>
E: Encountered a section with no Package: header</br>
E: Problem with MergeList /var/lib/apt/lists/fr.archive.ubuntu.com_ubuntu_dists_trusty_universe_i18n_Translation-en</br>
E: Les listes de paquets ou le fichier « status » ne peuvent être analysés ou lus.</br>
<h2>
Solution </h2>
sudo rm /var/lib/apt/lists/* -vf</br>
sudo apt-get update</br>
Solution tiré du blog : http://wiki.vanessalionel.fr/lecture-des-listes-de-paquets-erreur/
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-31637725858061077322014-07-09T16:23:00.002+02:002014-07-09T16:23:45.031+02:00Convertir mp4 en 3gp avec Linux (débian)sudo add-apt-repository ppa:jon-severinsson/ffmpeg <br />
sudo apt-get update<br />
sudo apt-get install ffmpeg<br />
<br />
ffmpeg -y -i video.mp4 -r 20 -s 352x288 -b 400k -acodec aac -strict experimental -ac 1 -ar 8000 -ab 24k video.3gp<br />
<br />
<br />Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-47304331749372967882014-05-05T10:45:00.000+02:002014-05-05T10:46:54.428+02:00Convertir fichiers .flac en .mp3 avec LinuxDans un terminal :
for file in *.flac; do $(flac -cd "$file" | lame -h -V 0 - "${file%.flac}.mp3"); done
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-25233700319463197952014-04-09T13:16:00.001+02:002014-04-09T13:36:25.045+02:00@Any ou comment utiliser CDI pour récupérer les implémentations d'une interface<h2>
Problème</h2>
<div>
<br /></div>
Itérer sur des implémentation d'interface afin d'appeler une méthode commune a toutes les implémentations car partagé par l'interface. (Implémentations différentes pour chaque classe)
Imaginons l'interface AnimalIfc ayant une méthode getType() :
<pre class="brush: java">
public interface AnimalIfc {
String getType();
}
</pre>
Et des implémentations :
<pre class="brush: java">
@ChienQualifier
public class Chien extends AnimalIfc{
public Chien(){
super();
}
@Qualifier
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Target({ java.lang.annotation.ElementType.TYPE,
java.lang.annotation.ElementType.METHOD,
java.lang.annotation.ElementType.PARAMETER,
java.lang.annotation.ElementType.FIELD })
public @interface ChienQualifier {
}
@Override
public String getType() {
return this.getClass().getSimpleName();
}
}
</pre>
<pre class="brush: java">
@ChatQualifier
public class Chat extends AnimalIfc{
public Chat(){
super();
}
@Qualifier
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Target({ java.lang.annotation.ElementType.TYPE,
java.lang.annotation.ElementType.METHOD,
java.lang.annotation.ElementType.PARAMETER,
java.lang.annotation.ElementType.FIELD })
public @interface ChatQualifier {
}
@Override
public String getType() {
return this.getClass().getSimpleName();
}
}
</pre>
<pre class="brush: java">
@OiseauQualifier
public class Oiseau extends AnimalIfc{
public Oiseau(){
super();
}
@Qualifier
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Target({ java.lang.annotation.ElementType.TYPE,
java.lang.annotation.ElementType.METHOD,
java.lang.annotation.ElementType.PARAMETER,
java.lang.annotation.ElementType.FIELD })
public @interface OiseauQualifier {
}
@Override
public String getType() {
return this.getClass().getSimpleName();
}
}
</pre>
Dans une classe on voudrait récupérer le type de tous les animaux simplement sans rien faire si jamais une nouvelle classe implémentant AnimalIfc est crée
<div>
<br /></div>
<h2>
Solution</h2>
<div>
<br /></div>
A l'aide de CDI c'est très simple. Il suffit d'utiliser l'annotation @Any qui permet de récupérer les instances implémentant l'interface demandé :
<pre class="brush: java">
public class AnimauxService {
@Inject @Any
private transient Instance<AnimalIfc> animalImplList;
public AnimauxService(){
super();
}
public List<String> listTypes() {
final List<String> result = new ArrayList<String>();
for (AnimalIfc animal : animalImplList) {
result.add(animal.getType());
}
return result;
}
}
</pre>
<br />Avec cette méthode si l'on rajoute un type 'Poisson' il suffit de créer la classe correspondant en implémentant l'interface AnimalIfc.
<br />L'intéret est que dans la méthode de liste on n'a rien a changé. Le code reste le même.
<br />N'hésitez pas en cas de question :) !
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-1537570138437459202014-04-09T08:55:00.003+02:002014-04-09T13:36:42.705+02:00Utilisation d'attribut injecté avec CDI dans le constructeur d'un objet injecté lui même avec CDI avec @PostConstruct<h2>
Problème</h2>
Lors d'un test d'intégration je me suis retrouvé avec un nullpointer lors de l'exécution de celui-ci.<br />
Le nullpointer venait du fait que CDI n'avais pas achevé son injection dans l'attribut que j'utilisais et qui était donc null lors de son utilisation.<br />
<br />
Imaginons une classe 'Developpeur' et dans cette classe un attribut qui serait une classe 'LieuDeTravail'.<br />
<br />
La classe LieuDeTravail:
<br />
<pre class="brush: java">
public class LieuDeTravail {
private String ville;
public Travail(){
super();
}
public String getVille(){
return ville;
}
public String setVille(String ville){
this.ville = ville;
}
}
</pre>
<br />
La classe Developpeur:
<br />
<pre class="brush: java">
public class Developpeur {
@Inject
private transient LieuDeTravail lieu;
private String ville;
public Developpeur(){
super();
ville = lieu.getVille();
}
...
}
</pre>
--> Le traitement va planter a l'instruction lieu.getVille(); car lieu sera null.<br />
<br />
<h2>
Solution </h2>
<br />
Utiliser l'annotation @PostConstruct :
<br />
<pre class="brush: java">
public class Developpeur {
@Inject
private transient LieuDeTravail lieu;
private String ville;
public Developpeur(){
super();
}
...
@PostConstruct
private void chargerVille() {
ville = lieu.getVille();
}
}
</pre>
Et voilà, le tour est joué !
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-46840419282970208132014-03-21T14:45:00.002+01:002014-03-21T14:57:09.900+01:00Injection de configuration avec CDIIl suffit de créer une factory pour CDI et une annotation (tiré du blog http://codebias.blogspot.fr/2013/04/environment-configuration-property.html) .<br />
<br />
<h2>
Création de l'annotation</h2>
<pre class="brush: java">
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.util.Nonbinding;
import javax.inject.Qualifier;
@Qualifier
@Retention(RUNTIME)
@Target({METHOD, FIELD, PARAMETER, TYPE})
public @interface Configuration {
@Nonbinding
String value() default "";
}
</pre>
<h2>
Création de la factory</h2>
<pre class="brush: java">
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
@ApplicationScoped
public class ConfigurationFactory {
private static final String ENVIRONMENT_NAME_KEY = "environment.name";
private static final String DEFAULT_PROPS_FILENAME = "environment.properties";
private static final String PROPS_FILENAME_FORMAT = "environment_%s.properties";
private Properties environmentProps;
@PostConstruct
public void initEnvironmentProps() throws IOException {
environmentProps = new Properties();
String propsFilename = DEFAULT_PROPS_FILENAME;
String environmentName = System.getProperty(ENVIRONMENT_NAME_KEY);
if (environmentName != null) {
propsFilename = String.format(PROPS_FILENAME_FORMAT, environmentName);
}
try(InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propsFilename)){
if (inputStream == null) {
throw new FileNotFoundException("Properties file for environment " + environmentName + " not found in the classpath.");
}
environmentProps.load(inputStream);
}
}
@Produces
@Configuration
public String getConfigValue(InjectionPoint ip) {
Configuration config = ip.getAnnotated().getAnnotation(Configuration.class);
String configKey = config.value();
if (configKey.isEmpty()) {
throw new IllegalArgumentException("Properties value key is required.");
}
return environmentProps.getProperty(configKey);
}
}
</pre>
<h2>
Comment on l'appel ? </h2>
<pre class="brush: java">
//Usage
@Inject
@Configuration("url")
private String testUrl;
//...
</pre>
<br />Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-47005673188559991652014-02-18T08:36:00.000+01:002014-05-26T16:14:20.373+02:00Edition video simple sur Linux avec pitivi et contournement du problème de blocage sur l'estimation.<h2>
Choix de l'outil</h2>
J'ai cherché sur Ubuntu un logiciel simple permettant de faire de l'édition.<br />
<br />
Je me suis d'abord penché sur <b>avidemux</b> mais il plantait dès que je voulait faire un traitement.<br />
<br />
Je suis tombé ensuite sur <b>pitivi</b> et ce logiciel a parfaitement fonctionné.<br />
<br />
Voici l'url du site : http://www.pitivi.org/<br />
<br />
Avec celui ci j'ai pu assembler facilement des morceaux de vidéo en coupant les morceaux qui m’intéressaient pas et exporter le tout afin de créer une vidéo dans l'encodage désiré.<br />
<br />
<h2>
Contournement du problème de blocage sur l'estimation de rendu</h2>
<div>
Une fois mes traitements fait je voulais exporter la vidéo. </div>
<div>
<br /></div>
<div>
J'ai donc cliqué sur rendering puis là une fenêtre s'ouvre. Cette fenêtre restait bloquée avec le message 'estimation' (de mémoire).</div>
<div>
<br /></div>
<div>
Afin de contourner ce problème j'ai : </div>
<div>
<br /></div>
<div>
<ol>
<li>Installé les paquets pour les transformations et effets manquant</li>
<li>Mis le pointeur dans la timeline de la vidéo au début de la timeline</li>
</ol>
<div>
Ça a fonctionné parfaitement.</div>
</div>
<div>
<br />
[EDIT]<br />
Je me suis rendu compte au fil des utilisation que le logiciel a du mal a supporter l'écrasement de fichier lors du rendu.<br />
Je m'explique: Si on fait un rendu une premiere fois ca marche par contre si on refait un rendu en laissant le même nom de fichier (il y a une alerte visuelle sous forme d'icone dans le logiciel qui nous prévient que l'on va écraser le fichier), le rendu reste dur "A propos des 1 secondes restantes" et ne bouge plus (Sur mon environnement.)<br />
<br />
Bref, en ayant mis un autre nom de fichier ça a fonctionné de nouveau.<br />
[/EDIT]</div>
<div>
N'hésitez pas a me contacter via le formulaire a droite en cas de question.</div>
<div>
<br /></div>
<div>
<br /></div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-23581623424743968182014-02-14T14:26:00.000+01:002014-03-11T13:34:25.016+01:00Installation de VirtualBox sur FedoraAyant galéré sur Fédora pour installer VirtualBox, voici la procédure simplifiée que j'ai suivi afin que celui-ci fonctionne.<br />
Tiré du site http://doc.fedora-fr.org/wiki/VirtualBox_:_installation,_configuration,_utilisation<br />
<br />
<h2>
Prérequis</h2>
<div>
<h3>
Mettre a jour le système</h3>
</div>
<pre class="brush: java">$ su -
# yum update
</pre>
<h3>
Outils de compilation et bibliothèques</h3>
<pre class="brush: java">$ su -
# yum groupinstall "Development Tools"
# yum install kernel-devel
</pre>
<div>
Ou si noyau PAE</div>
<pre class="brush: java">$ su -
# yum groupinstall "Development Tools"
# yum install kernel-PAE-devel
</pre>
<div>
Savoir si on a un noyau PAE</div>
<pre class="brush: java">$ uname -r
</pre>
<h2>
Installation</h2>
<pre class="brush: java"># cd /etc/yum.repos.d/
# urlgrabber http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
# yum install VirtualBox
</pre>
<div>
<br />
Ne bien mettre que VirtualBox et non un nom du genre VirtualBox-{version}<br />
<br />
<span style="color: red;">Attention: Si le noyeau système de Fédora est mis a jour VirtualBox ne fonctionnera plus.</span><br />
Si cela arrive il faut désinstaller VirtualBox avec<br />
<b>sudo yum remove VirtualBox.{version achi}</b><br />
puis<br />
<b>sudo yum install VirtualBox </b></div>
<div>
<br /></div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-57297969944466564452014-02-13T11:35:00.003+01:002014-02-14T11:07:38.567+01:00Debug a distance sur une application déployée sur Glassfish<h2>
Prérequis</h2>
<div>
<ul>
<li>Le projet correspondant a l'application déployée doit être dans le workspace actif d'éclipse</li>
<li>Glassfish doit être installé et lancé</li>
<li>Avoir le droit d'écouter le port de débug sur le glassfish (Sera décris plus bas)</li>
<li>Avoir des notions d'utilisation de glassfish (opérations standard de stop/start domain)</li>
</ul>
<h2>
Configurer Glassfish</h2>
</div>
<div>
<ul>
<li>Se connecter à l'interface d'administration de glassfish</li>
<li>Aller dans Configurations> server-config> JVM Settings (Sur cette page se trouve le port écouté dans 'Debug Options', il faut que ce port ne soit pas bloqué par un éventuel pare-feu)</li>
<li>Cocher la case 'Enabled'</li>
</ul>
Voici ce que vous devez avoir puis il faut redémarrer le domaine glassfish afin qu'il soit en mode débug:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge15O_H9kZ95D3raI60oUo8ZRruBEJJHFSJW_bC9Kb14oHL8q79Qxn-I896gp3v9hjEvS1PRbvzNCp8P0XdNeP-33d4qfOXSaT1Ua-XP_Yc62FnHefzJWpMuw87vMOe0_IOvBlSnU5P4tT/s1600/glassfish-debug.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge15O_H9kZ95D3raI60oUo8ZRruBEJJHFSJW_bC9Kb14oHL8q79Qxn-I896gp3v9hjEvS1PRbvzNCp8P0XdNeP-33d4qfOXSaT1Ua-XP_Yc62FnHefzJWpMuw87vMOe0_IOvBlSnU5P4tT/s1600/glassfish-debug.png" height="160" width="400" /></a></div>
<div>
<ul>
<li>Stopper le domaine glassfish</li>
<li>Lancer le domaine glassfish</li>
</ul>
<h2>
Configurer Eclipse</h2>
</div>
<div>
<ul>
<li>Cliquez sur Run --> Debug Configurations ...</li>
<li>Aller dans la partie 'Remote Java Application</li>
<li>Faire clic droit puis 'New'</li>
</ul>
Une fenêtre comme ci-dessous devrait s'ouvrir :</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE3P6VNNYYe2cd-G8bCKp4IDXwLlcayNHGkGi2AiDNpDxgciSuakd7SCTWUJNTkjSi7g7gpT0jZOcUygPlIaxbF_HYvq1qTWCLjZS8uM_bQbdicZq-BIecD4YY6rVhOard2Onrc93-o5PU/s1600/eclipse-debug-01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE3P6VNNYYe2cd-G8bCKp4IDXwLlcayNHGkGi2AiDNpDxgciSuakd7SCTWUJNTkjSi7g7gpT0jZOcUygPlIaxbF_HYvq1qTWCLjZS8uM_bQbdicZq-BIecD4YY6rVhOard2Onrc93-o5PU/s1600/eclipse-debug-01.png" height="295" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<ul>
<li>Dans le champ 'Project', mettre le projet que vous voulez débugger a distance</li>
<li>Dans 'Host', l'hôte hébergeant l'applicatif. Ici donc l'url du glassfish (sans http/https ni le port)</li>
<li>Dans 'Port' mettre le port hébergeant l'applicatif. Ici donc le port d'écoute du glassfish. C'est celui qui se trouve dans Configurations> server-config> JVM Settings, champ 'Debug Options'</li>
<li>Laisser 'Connection Type' sur 'Standard (Socket Attach)</li>
<li>Cliquez sur 'Debug'</li>
</ul>
<div>
Si tout se passe bien, dans la vue Debug d'éclipse (vue et non perspective) vous devez pouvoir visualiser les thread sur le glassfish distant.</div>
<div>
<br /></div>
<h2>
C'est parti pour le débug!</h2>
<div>
Maintenant tout est en place pour pouvoir débug, il suffit de placer des points d'arrêts dans le projet sous éclipse. Lors de l'utilisation du programme déployé sur le glassfish distant, si le programme rencontre un point d'arrêt, il s'arrêtera. Vous n'avez plus qu'a regarder dans éclipse ce qui vous intéresse pour le débug de votre application.</div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-68054519257354033552014-02-12T19:49:00.004+01:002014-02-14T11:07:00.247+01:00Assembler des fichiers .xtm simplement sous Linux<div style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 16px;">
<span style="color: #242c2d;">Aller dans le répertoire contenant les xtm a assembler</span></div>
<div style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 16px;">
<br /></div>
<div style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 16px;">
cd {chemin du répertoire contenant les fichiers}</div>
<div style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 16px;">
<br /></div>
<div style="color: #242c2d; font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 16px;">
Puis :<br />
<br />
cat * > {nomdufichiersouhaité}<br />
<br />
Simple et efficace :)<br />
<br />
Enjoy!<br />
<br /></div>
Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0tag:blogger.com,1999:blog-8968085359518059646.post-50078001790775390392014-02-11T16:53:00.000+01:002014-02-12T13:13:21.645+01:00Modification de clé composés avec JPA2 (Solution)<h2>
Mise a jour d'une valeur de clé composée JPA</h2>
Après avoir cherché un peu partout, je n'ai pas trouvé de solution élégante pour modifier une valeur d'une clé composée JPA.<br />
<br />
<h2>
Problème</h2>
Soit les classes A, B, C, D qui correspondent aux tables A_ B_ C_ D_ avec les relations suivantes:<br />
<br />
A -> mappé sur la clé primaire sur de la table A_<br />
B -> mappé sur la clé primaire sur de la table B_<br />
C -> mappé sur la clé primaire sur de la table C_<br />
D -> mappé sur la clé primaire sur de la table A_ B_ C_<br />
<br />
L'objet D a donc comme identifiant une composition des identifiant des classe A_ B_ et C_ .<br />
<br />
Avec JPA2 si nous voulons mettre a jour la valeur de B_ sur l'objet D_ avec :<br />
D_.setValeurB(50) par exemple<br />
<br />
----> Cela ne fonctionnera pas.<br />
<br />
<h2>
Solution</h2>
<div>
Afin de résoudre ce problème j'ai utilisé les requêtes JPQL de mise a jour étant donné que je n'ai pas pu modifier mon mapping car supprimer la clé composé n'était pas possible a cause de mon modèle.</div>
<div>
<br /></div>
<div>
Voici un exemple de code qui fonctionne: </div>
<pre class="brush: java">Query query = entityManager.createQuery(
"UPDATE D d "
+ "SET d.cleCompose.b =:valeurB "
+ "WHERE d.cleCompose.idD=:id");
query.setParameter("id", key.getIdUniteTypeUnite());
query.setParameter("valeurB", value.getTypeUnite().getIdType());
query.executeUpdate();
</pre>
<br />
<br />
En cas de question je suis disponible :)<br />
<br />Fabien Travagliahttp://www.blogger.com/profile/07868649788132766070noreply@blogger.com0